Practical infrastructure challenge

Infrastructure Security and IAM Challenge

Review least privilege, IAM policy decisions, temporary credentials and Terraform sensitive data handling. Construct a narrowly scoped read-only policy.

1. Review the access requirements

Catalog report reader

A synthetic workload needs to read existing objects under reports/ in a fictional S3 bucket. It needs no listing, writing, deletion or other prefixes. The proposed policy is overly broad and must be narrowed. Assume same-account access with no other grants for the exercise; effective permissions in AWS depend on all applicable policies and encryption requirements.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": "*"
    }
  ]
}
Inspect the scenario data
{
  "workload": "Synthetic catalog reader",
  "required_action": "s3:GetObject",
  "allowed_resource": "arn:aws:s3:::example-training-catalog/reports/*",
  "requirements": [
    "Read existing objects only within reports/",
    "No bucket listing, writing, deletion or other prefixes",
    "Use temporary workload credentials",
    "Assume same-account access with no other grants for the exercise; actual AWS evaluation includes additional applicable policies and encryption requirements."
  ],
  "proposed_policy": {
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Action": "s3:*",
        "Resource": "*"
      }
    ]
  }
}

2. Review the security decisions

Loading the practice questions...

3. Construct the restricted policy

Write an output named reader_policy using jsonencode. Preserve policy version 2012-10-17 and grant only s3:GetObject on the object ARN arn:aws:s3:::example-training-catalog/reports/*. Do not attach a policy, create a role or connect to an AWS account.

main.tfTerraform ยท HCL
Need a conceptual hint?

Use a single Allow statement. Match the action to the requested read operation and the resource to the specific object prefix. Terraform can encode the policy object as JSON without a provider.

Compare a reference example after attempting
output "reader_policy" {
  value = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect   = "Allow"
      Action   = ["s3:GetObject"]
      Resource = ["arn:aws:s3:::example-training-catalog/reports/*"]
    }]
  })
}

Check that no additional action or resource scope is granted. The editor provides HCL self-comparison; it does not evaluate effective AWS permissions.

4. Explain your security decision

Explain why the original policy exceeds the requirement, how implicit and explicit denial differ, and why temporary credentials and protected Terraform state matter. Describe which additional checks would be necessary before deploying a real policy.

Continue your learning

Explore Infrastructure Scanner, Secrets Scanner, Module Design Challenge and learning methodology.

Technical references