diff --git a/terraform/README.md b/terraform/README.md index a7a5207..01f81e7 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -78,6 +78,7 @@ Terraform directory structure | [aws_iam_role_policy.user_bot](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource | | [aws_iam_role_policy.user_bot_deploy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource | | [aws_iam_role_policy_attachment.incubator_tf_apply_admin](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | +| [aws_iam_role_policy_attachment.incubator_tf_plan_location_read](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | | [aws_iam_role_policy_attachment.incubator_tf_plan_readonly](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | | [aws_iam_role_policy_attachment.incubator_tf_plan_secrets_read](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | | [aws_iam_user.fangyiliu](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource | diff --git a/terraform/aws-custom-policies.tf b/terraform/aws-custom-policies.tf index ac2c698..a9b9c9b 100644 --- a/terraform/aws-custom-policies.tf +++ b/terraform/aws-custom-policies.tf @@ -13,5 +13,10 @@ module "aws_custom_policies" { description = "Allows incubator tf plan role to read specific Secrets Manager secrets needed for terraform plan" filename = "tf-plan-scoped.json" } + # The AWS-managed ReadOnlyAccess policy grants no geo: actions at all. + "IncubatorTfPlanLocationRead" = { + description = "Allows incubator tf plan role to read Amazon Location resources during terraform plan" + filename = "tf-plan-location-read.json" + } } } diff --git a/terraform/aws-custom-policies/tf-plan-location-read.json b/terraform/aws-custom-policies/tf-plan-location-read.json new file mode 100644 index 0000000..4004172 --- /dev/null +++ b/terraform/aws-custom-policies/tf-plan-location-read.json @@ -0,0 +1,14 @@ +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "AllowLocationReadForTerraformPlan", + "Effect": "Allow", + "Action": [ + "geo:Describe*", + "geo:List*" + ], + "Resource": "*" + } + ] +} diff --git a/terraform/aws-gha-oidc-providers.tf b/terraform/aws-gha-oidc-providers.tf index a27bd08..0a9a95e 100644 --- a/terraform/aws-gha-oidc-providers.tf +++ b/terraform/aws-gha-oidc-providers.tf @@ -72,6 +72,11 @@ resource "aws_iam_role_policy_attachment" "incubator_tf_plan_secrets_read" { policy_arn = module.aws_custom_policies.policy_arns["IncubatorTfPlanSecretsRead"] } +resource "aws_iam_role_policy_attachment" "incubator_tf_plan_location_read" { + role = aws_iam_role.incubator_tf_plan.name + policy_arn = module.aws_custom_policies.policy_arns["IncubatorTfPlanLocationRead"] +} + resource "aws_iam_role" "incubator_tf_apply" { name = "incubator-tf-apply" assume_role_policy = jsonencode({