Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions terraform/aws-custom-policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ module "aws_custom_policies" {
description = "Policy enforcing MFA for devops security users"
filename = "enforce-mfa-for-users-policy.json"
}
"IncubatorTfPlanSecretsRead" = {
description = "Allows incubator tf plan role to read specific Secrets Manager secrets needed for terraform plan"
filename = "incubator-tf-plan-secrets-read-policy.json"
}
Comment on lines +12 to +15
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description mentions a new policy file incubator-tf-plan-secrets-read-policy.tf, but the change here references incubator-tf-plan-secrets-read-policy.json. If the PR description is outdated/typo, consider updating it to match the actual file name/type to avoid confusion for reviewers and future maintainers.

Copilot uses AI. Check for mistakes.
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name of the file should not be specific to secrets, but all of the 'other' things that TF plan needs other than read only

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowReadSpecificSecretsForTerraformPlan",
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue"
],
"Resource": [
"arn:aws:secretsmanager:us-west-2:035866691871:secret:home-unite-us-cognito-client*",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be:
arn:aws:secretsmanager:us-west-2:035866691871:secret:*

"arn:aws:secretsmanager:us-west-2:035866691871:secret:home-unite-us-google-clientid*",
"arn:aws:secretsmanager:us-west-2:035866691871:secret:home-unite-us-google-secret*"
]
}
]
}
8 changes: 6 additions & 2 deletions terraform/aws-gha-oidc-providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ resource "aws_iam_role" "incubator_tf_plan" {
}

resource "aws_iam_role_policy_attachment" "incubator_tf_plan_readonly" {
role = aws_iam_role.incubator_tf_plan.name
role = aws_iam_role.incubator_tf_plan.name
policy_arn = "arn:aws:iam::aws:policy/ReadOnlyAccess"
}
Comment on lines +42 to +45
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attaching only the AWS managed ReadOnlyAccess policy to the Terraform plan role is likely insufficient for a remote S3 backend with DynamoDB state locking (this repo configures dynamodb_table in prod.backend.tfvars). Terraform plan/init typically needs write permissions to the lock table (e.g., dynamodb:PutItem, DeleteItem, UpdateItem) and appropriate S3 backend access; otherwise CI plans will fail when locking the state. Consider adding a minimal backend-access policy (S3 state bucket + DynamoDB lock table) to this role, instead of (or in addition to) ReadOnlyAccess.

Copilot uses AI. Check for mistakes.

resource "aws_iam_role_policy_attachment" "incubator_tf_plan_secrets_read" {
role = aws_iam_role.incubator_tf_plan.name
policy_arn = module.aws_custom_policies.policy_arns["IncubatorTfPlanSecretsRead"]
}

resource "aws_iam_role" "incubator_tf_apply" {
name = "incubator-tf-apply"

assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
Expand Down
Loading