File tree Expand file tree Collapse file tree
modules/aws-gha-oidc-providers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,5 +9,9 @@ module "aws_custom_policies" {
99 description = " Policy enforcing MFA for devops security users"
1010 filename = " enforce-mfa-for-users-policy.json"
1111 }
12+ " IncubatorTfPlanSecretsRead" = {
13+ description = " Allows incubator tf plan role to read specific Secrets Manager secrets needed for terraform plan"
14+ filename = " tf-plan-scoped.json"
15+ }
1216 }
1317}
Original file line number Diff line number Diff line change 1+ {
2+ "Version" : " 2012-10-17" ,
3+ "Statement" : [
4+ {
5+ "Sid" : " AllowReadSpecificSecretsForTerraformPlan" ,
6+ "Effect" : " Allow" ,
7+ "Action" : [
8+ " secretsmanager:GetSecretValue"
9+ ],
10+ "Resource" : [
11+ " arn:aws:secretsmanager:us-west-2:035866691871:secret:*"
12+ ]
13+ },
14+ {
15+ "Sid" : " AllowS3BackendAccessForTerraformPlan" ,
16+ "Effect" : " Allow" ,
17+ "Action" : [
18+ " s3:GetObject" ,
19+ " s3:PutObject" ,
20+ " s3:DeleteObject" ,
21+ " s3:ListBucket" ,
22+ " s3:GetBucketLocation"
23+ ],
24+ "Resource" : [
25+ " arn:aws:s3:::hfla-ops-terraform-state" ,
26+ " arn:aws:s3:::hfla-ops-terraform-state/*"
27+ ]
28+ },
29+ {
30+ "Sid" : " AllowDynamoDBLockTableAccessForTerraformPlan" ,
31+ "Effect" : " Allow" ,
32+ "Action" : [
33+ " dynamodb:PutItem" ,
34+ " dynamodb:DeleteItem" ,
35+ " dynamodb:GetItem" ,
36+ " dynamodb:UpdateItem" ,
37+ " dynamodb:DescribeTable"
38+ ],
39+ "Resource" : [
40+ " arn:aws:dynamodb:us-west-2:035866691871:table/hfla_ops_terraform_table"
41+ ]
42+ }
43+ ]
44+ }
45+
Original file line number Diff line number Diff line change @@ -40,13 +40,17 @@ resource "aws_iam_role" "incubator_tf_plan" {
4040}
4141
4242resource "aws_iam_role_policy_attachment" "incubator_tf_plan_readonly" {
43- role = aws_iam_role. incubator_tf_plan . name
43+ role = aws_iam_role. incubator_tf_plan . name
4444 policy_arn = " arn:aws:iam::aws:policy/ReadOnlyAccess"
4545}
4646
47+ resource "aws_iam_role_policy_attachment" "incubator_tf_plan_secrets_read" {
48+ role = aws_iam_role. incubator_tf_plan . name
49+ policy_arn = module. aws_custom_policies . policy_arns [" IncubatorTfPlanSecretsRead" ]
50+ }
51+
4752resource "aws_iam_role" "incubator_tf_apply" {
4853 name = " incubator-tf-apply"
49-
5054 assume_role_policy = jsonencode ({
5155 Version = " 2012-10-17"
5256 Statement = [
Original file line number Diff line number Diff line change @@ -50,8 +50,7 @@ resource "aws_iam_openid_connect_provider" "github_actions" {
5050
5151resource "aws_iam_role" "github_actions_oidc" {
5252
53- name = var. role_name
54- managed_policy_arns = var. policy_arns
53+ name = var. role_name
5554
5655 assume_role_policy = jsonencode ({
5756 " Version" : " 2012-10-17" ,
@@ -71,4 +70,11 @@ resource "aws_iam_role" "github_actions_oidc" {
7170 }
7271 }]
7372 })
74- }
73+ }
74+
75+ resource "aws_iam_role_policy_attachment" "github_actions_oidc" {
76+ for_each = toset (var. policy_arns )
77+
78+ role = aws_iam_role. github_actions_oidc . name
79+ policy_arn = each. value
80+ }
You can’t perform that action at this time.
0 commit comments