|
1 |
| -### Lab03 - Sentinel - to be implemented |
| 1 | +### Lab03 - Sentinel Policy as Code |
| 2 | + |
| 3 | +In this Lab we will continue to use your Organization we setup in lab02. Using Sentinel policy-as-code framework we will restrict the AWS EC2 instance type being deployed. |
| 4 | +- The Sentinel policy code is included in lab03 directory: [restrict-aws-instance-type.sentinel](restrict-aws-instance-type.sentinel). |
| 5 | +- You can view [example Sentinel policies on AWS](https://github.com/hashicorp/terraform-guides/tree/master/governance/aws) in terraform-guides repo. |
| 6 | + |
| 7 | +**Tasks:** |
| 8 | +- Task 1: Add Sentinel policy to Organization |
| 9 | +- Task 2: Queue a Plan |
| 10 | +- Task 3: View Sentinel policy failure and Override |
| 11 | +- Task 4: Destroy provisioned infrastructure |
| 12 | + |
| 13 | +### Terraform Enterprise |
| 14 | + |
| 15 | +### Task 1: Add Sentinel policy to Organization |
| 16 | + |
| 17 | +**Steps:** |
| 18 | +- Go to your Organization URL, which is in the format: `https://app.terraform.io/app/<your-organization-name>` |
| 19 | +- Click on Settings at the top |
| 20 | +- Click on "Sentinel policies" from the Organization Settings menu on the left |
| 21 | +- Click "Add New Policy" |
| 22 | + - Set "POLICY NAME" to |
| 23 | + - Set "ENFORCEMENT MODE" to soft-mandatory (can override) |
| 24 | + - In "POLICY CODE", add the contents of [restrict-aws-instance-type.sentinel](restrict-aws-instance-type.sentinel). |
| 25 | + |
| 26 | +- Click "Create policy" |
| 27 | + |
| 28 | +### Task 2: Queue a plan |
| 29 | + |
| 30 | +**Steps:** |
| 31 | +- Click on "Workspaces" from the top, and click on the Workspace you used for lab02. |
| 32 | +- Click on "Queue plan" from the top. |
| 33 | + |
| 34 | +### Task 3: View Sentinel policy failure and Override |
| 35 | + |
| 36 | +**Steps:** |
| 37 | +- The Run should show a Policy failure. View the Allowed EC2 instance types in Sentinel Policy code. You will see it is restricted to `t2.small`. |
| 38 | +- Our [main.tf](../lab02/server/main.tf) is using an instance type of `t2.medium` which is causing the Policy to fail. |
| 39 | +- Since you are the owner of the Organization, you are able to Override this Policy failure. |
| 40 | + - Click on "Override" button Optionally adding some comments |
| 41 | + - Click on "Confirm and Apply" button to allow the Run to complete. |
| 42 | + |
| 43 | +### Task 4: Destroy provisioned infrastructure |
| 44 | +**Steps:** |
| 45 | +- Use the same steps as Lab02 to Destroy provisioned infrastructure |
0 commit comments