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 = "tf-plan-scoped.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.
}
}
15 changes: 15 additions & 0 deletions terraform/aws-custom-policies/tf-plan-scoped.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowReadSpecificSecretsForTerraformPlan",
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue"
],
"Resource": [
"arn:aws:secretsmanager:us-west-2:035866691871: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
10 changes: 8 additions & 2 deletions terraform/modules/aws-gha-oidc-providers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ resource "aws_iam_openid_connect_provider" "github_actions" {

resource "aws_iam_role" "github_actions_oidc" {

name = var.role_name
managed_policy_arns = var.policy_arns
name = var.role_name

assume_role_policy = jsonencode({
"Version" : "2012-10-17",
Expand All @@ -71,4 +70,11 @@ resource "aws_iam_role" "github_actions_oidc" {
}
}]
})
}

resource "aws_iam_role_policy_attachment" "github_actions_oidc" {
for_each = toset(var.policy_arns)

role = aws_iam_role.github_actions_oidc.name
policy_arn = each.value
}
Loading