Repository navigation
Expand file tree
/
Copy pathmain.tf
More file actions
717 lines (655 loc) · 21 KB
/
Copy pathmain.tf
File metadata and controls
717 lines (655 loc) · 21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
data "aws_caller_identity" "current" {}
data "aws_partition" "current" {}
data "aws_region" "current" {}
locals {
oidc_url = "https://token.actions.githubusercontent.com"
oidc_provider_host = "token.actions.githubusercontent.com"
oidc_thumbprint = "dd55b4520291e276588f0dd02fafd83a7368e0fa"
project_prefix = replace(var.role_name, "/-terraform-.*/", "")
branch_subjects = [for branch in var.allowed_branches : "repo:${var.github_org}/${var.github_repo}:ref:refs/heads/${branch}"]
environment_subjects = [for environment in var.allowed_environments : "repo:${var.github_org}/${var.github_repo}:environment:${environment}"]
allowed_subjects = concat(local.branch_subjects, local.environment_subjects)
lake_bucket_arn = "arn:${data.aws_partition.current.partition}:s3:::${local.project_prefix}-lake-*"
state_bucket_name = "agentflow-terraform-state"
state_bucket_arn = "arn:${data.aws_partition.current.partition}:s3:::${local.state_bucket_name}"
state_object_arns = [
for environment in var.state_environments :
"${local.state_bucket_arn}/env/${environment}/terraform.tfstate"
]
state_prefix_arns = [
for environment in var.state_environments :
"${local.state_bucket_arn}/env/${environment}/*"
]
state_table_arn = "arn:${data.aws_partition.current.partition}:dynamodb:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:table/agentflow-terraform-locks"
# S3 backend LockID is <bucket>/<key>; Terraform also writes a <key>-md5 digest item.
state_lock_ids = flatten([
for environment in var.state_environments : [
"${local.state_bucket_name}/env/${environment}/terraform.tfstate",
"${local.state_bucket_name}/env/${environment}/terraform.tfstate-md5",
]
])
oidc_provider_arn = "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${local.oidc_provider_host}"
terraform_role_arn = "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:role/${local.project_prefix}-terraform-*"
service_role_arns = [
"arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:role/${local.project_prefix}-flink-*",
"arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:role/${local.project_prefix}-grafana-*",
]
boundary_policy_name = "${var.role_name}-boundary"
boundary_policy_arn = "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:policy/${local.boundary_policy_name}"
region_account = "${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}"
msk_cluster_arns = ["arn:${data.aws_partition.current.partition}:kafka:${local.region_account}:cluster/${local.project_prefix}-*/*"]
msk_config_arns = ["arn:${data.aws_partition.current.partition}:kafka:${local.region_account}:configuration/${local.project_prefix}-*/*"]
flink_app_arns = ["arn:${data.aws_partition.current.partition}:kinesisanalytics:${local.region_account}:application/${local.project_prefix}-*"]
alarm_arns = ["arn:${data.aws_partition.current.partition}:cloudwatch:${local.region_account}:alarm:${local.project_prefix}-*"]
kms_key_arns = ["arn:${data.aws_partition.current.partition}:kms:${local.region_account}:key/*"]
kms_alias_arns = ["arn:${data.aws_partition.current.partition}:kms:${local.region_account}:alias/${local.project_prefix}-*"]
project_bucket_arns = [
"arn:${data.aws_partition.current.partition}:s3:::${local.project_prefix}-*",
"arn:${data.aws_partition.current.partition}:s3:::${local.project_prefix}-*/*",
]
}
data "aws_iam_policy_document" "assume_role" {
statement {
sid = "GitHubActionsAssumeRole"
effect = "Allow"
actions = ["sts:AssumeRoleWithWebIdentity"]
principals {
type = "Federated"
identifiers = [aws_iam_openid_connect_provider.github_actions.arn]
}
condition {
test = "StringEquals"
variable = "${local.oidc_provider_host}:aud"
values = ["sts.amazonaws.com"]
}
condition {
test = "StringLike"
variable = "${local.oidc_provider_host}:sub"
values = local.allowed_subjects
}
}
}
data "aws_iam_policy_document" "terraform" {
statement {
sid = "TerraformStateBucket"
effect = "Allow"
actions = [
"s3:GetBucketLocation",
"s3:GetBucketVersioning",
"s3:ListBucket",
]
resources = [local.state_bucket_arn]
}
statement {
sid = "TerraformStateObject"
effect = "Allow"
actions = [
"s3:DeleteObject",
"s3:GetObject",
"s3:PutObject",
]
resources = concat(local.state_object_arns, local.state_prefix_arns)
}
statement {
sid = "TerraformStateLockTableDescribe"
effect = "Allow"
actions = ["dynamodb:DescribeTable"]
resources = [local.state_table_arn]
}
statement {
sid = "TerraformStateLockItems"
effect = "Allow"
actions = [
"dynamodb:DeleteItem",
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
]
resources = [local.state_table_arn]
condition {
test = "ForAllValues:StringEquals"
variable = "dynamodb:LeadingKeys"
values = local.state_lock_ids
}
}
# List cannot be resource-scoped; every mutating OIDC-provider verb below is
# pinned to the one provider this module manages (IaC-3: no wildcard verbs on
# every provider in the account).
statement {
sid = "OidcProviderDiscovery"
effect = "Allow"
actions = ["iam:ListOpenIDConnectProviders"]
resources = ["*"]
}
statement {
sid = "OidcProviderLifecycle"
effect = "Allow"
actions = [
"iam:AddClientIDToOpenIDConnectProvider",
"iam:CreateOpenIDConnectProvider",
"iam:DeleteOpenIDConnectProvider",
"iam:GetOpenIDConnectProvider",
"iam:ListOpenIDConnectProviderTags",
"iam:RemoveClientIDFromOpenIDConnectProvider",
"iam:TagOpenIDConnectProvider",
"iam:UntagOpenIDConnectProvider",
"iam:UpdateOpenIDConnectProviderThumbprint",
]
resources = [local.oidc_provider_arn]
}
# IaC-2: the deploy role can refresh its own state (read-only) but can no
# longer mutate roles matching its own name — writes are limited to the
# service roles, and creating/re-policying them requires the permissions
# boundary to be attached. Changes to this role or its inline policy are
# applied out-of-band by an account admin, not by CI.
statement {
sid = "RoleStateRead"
effect = "Allow"
actions = [
"iam:GetRole",
"iam:GetRolePolicy",
"iam:ListAttachedRolePolicies",
"iam:ListRolePolicies",
"iam:ListRoleTags",
]
resources = concat([local.terraform_role_arn], local.service_role_arns)
}
statement {
sid = "ServiceRoleCreate"
effect = "Allow"
actions = ["iam:CreateRole"]
resources = local.service_role_arns
condition {
test = "StringEquals"
variable = "iam:PermissionsBoundary"
values = [local.boundary_policy_arn]
}
}
statement {
sid = "ServiceRolePolicyMutation"
effect = "Allow"
actions = [
"iam:AttachRolePolicy",
"iam:DeleteRolePolicy",
"iam:DetachRolePolicy",
"iam:PutRolePolicy",
]
resources = local.service_role_arns
condition {
test = "StringEquals"
variable = "iam:PermissionsBoundary"
values = [local.boundary_policy_arn]
}
}
statement {
sid = "ServiceRoleLifecycle"
effect = "Allow"
actions = [
"iam:DeleteRole",
"iam:TagRole",
"iam:UntagRole",
"iam:UpdateAssumeRolePolicy",
]
resources = local.service_role_arns
}
# Terraform needs to create and refresh the boundary policy, but not to
# rewrite it: no CreatePolicyVersion/SetDefaultPolicyVersion/DeletePolicy —
# loosening the ceiling is an out-of-band admin operation.
statement {
sid = "BoundaryPolicyRead"
effect = "Allow"
actions = [
"iam:GetPolicy",
"iam:GetPolicyVersion",
"iam:ListPolicyTags",
"iam:ListPolicyVersions",
]
resources = [local.boundary_policy_arn]
}
statement {
sid = "BoundaryPolicyCreate"
effect = "Allow"
actions = [
"iam:CreatePolicy",
"iam:TagPolicy",
"iam:UntagPolicy",
]
resources = [local.boundary_policy_arn]
}
statement {
sid = "PassServiceRoles"
effect = "Allow"
actions = ["iam:PassRole"]
resources = local.service_role_arns
}
statement {
sid = "ServiceLinkedRoles"
effect = "Allow"
actions = ["iam:CreateServiceLinkedRole"]
resources = ["*"]
condition {
test = "StringLike"
variable = "iam:AWSServiceName"
values = [
"grafana.amazonaws.com",
"kafka.amazonaws.com",
"kinesisanalytics.amazonaws.com",
]
}
}
# Security-group ids are generated at create time and Describe* is not
# resource-scopeable, so these stay on "*"; deleting a group is gated on the
# project tag below.
#trivy:ignore:AVD-AWS-0057
statement {
sid = "SecurityGroups"
effect = "Allow"
actions = [
"ec2:AuthorizeSecurityGroupEgress",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:CreateSecurityGroup",
"ec2:CreateTags",
"ec2:DeleteTags",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSubnets",
"ec2:DescribeTags",
"ec2:DescribeVpcs",
"ec2:GetManagedPrefixListEntries",
"ec2:RevokeSecurityGroupEgress",
"ec2:RevokeSecurityGroupIngress",
]
resources = ["*"]
}
#trivy:ignore:AVD-AWS-0057
statement {
sid = "SecurityGroupsDestroy"
effect = "Allow"
actions = ["ec2:DeleteSecurityGroup"]
resources = ["*"]
condition {
test = "StringEquals"
variable = "aws:ResourceTag/Project"
values = [local.project_prefix]
}
}
# IaC-4: explicit verbs instead of kafka:*Cluster*/kafka:*Configuration*,
# scoped to this project's cluster/configuration name patterns; cluster
# deletion additionally requires the project tag.
#trivy:ignore:AVD-AWS-0057
statement {
sid = "MSKDiscovery"
effect = "Allow"
actions = [
"kafka:DescribeClusterOperation",
"kafka:DescribeClusterOperationV2",
"kafka:ListClusters",
"kafka:ListClustersV2",
"kafka:ListConfigurations",
]
resources = ["*"]
}
statement {
sid = "MSKClusterLifecycle"
effect = "Allow"
actions = [
"kafka:CreateCluster",
"kafka:CreateClusterV2",
"kafka:DescribeCluster",
"kafka:DescribeClusterV2",
"kafka:GetBootstrapBrokers",
"kafka:ListTagsForResource",
"kafka:TagResource",
"kafka:UntagResource",
"kafka:UpdateBrokerCount",
"kafka:UpdateBrokerStorage",
"kafka:UpdateBrokerType",
"kafka:UpdateClusterConfiguration",
"kafka:UpdateClusterKafkaVersion",
"kafka:UpdateConnectivity",
"kafka:UpdateMonitoring",
"kafka:UpdateSecurity",
"kafka:UpdateStorage",
]
resources = local.msk_cluster_arns
}
statement {
sid = "MSKConfigurationLifecycle"
effect = "Allow"
actions = [
"kafka:CreateConfiguration",
"kafka:DeleteConfiguration",
"kafka:DescribeConfiguration",
"kafka:DescribeConfigurationRevision",
"kafka:ListConfigurationRevisions",
"kafka:UpdateConfiguration",
]
resources = local.msk_config_arns
}
statement {
sid = "MSKDestroy"
effect = "Allow"
actions = ["kafka:DeleteCluster"]
resources = local.msk_cluster_arns
condition {
test = "StringEquals"
variable = "aws:ResourceTag/Project"
values = [local.project_prefix]
}
}
# IaC-4: explicit verbs instead of kinesisanalytics:*Application*, scoped to
# this project's application name pattern; deletion requires the project tag.
#trivy:ignore:AVD-AWS-0057
statement {
sid = "FlinkDiscovery"
effect = "Allow"
actions = ["kinesisanalytics:ListApplications"]
resources = ["*"]
}
statement {
sid = "FlinkApplicationLifecycle"
effect = "Allow"
actions = [
"kinesisanalytics:CreateApplication",
"kinesisanalytics:DescribeApplication",
"kinesisanalytics:DescribeApplicationVersion",
"kinesisanalytics:ListApplicationVersions",
"kinesisanalytics:ListTagsForResource",
"kinesisanalytics:StartApplication",
"kinesisanalytics:StopApplication",
"kinesisanalytics:TagResource",
"kinesisanalytics:UntagResource",
"kinesisanalytics:UpdateApplication",
]
resources = local.flink_app_arns
}
statement {
sid = "FlinkDestroy"
effect = "Allow"
actions = ["kinesisanalytics:DeleteApplication"]
resources = local.flink_app_arns
condition {
test = "StringEquals"
variable = "aws:ResourceTag/Project"
values = [local.project_prefix]
}
}
statement {
sid = "LakeBucket"
effect = "Allow"
actions = [
"s3:CreateBucket",
"s3:DeleteBucket",
"s3:DeleteBucketEncryption",
"s3:DeleteBucketLifecycle",
"s3:DeleteBucketPublicAccessBlock",
"s3:GetBucketLocation",
"s3:GetBucketPublicAccessBlock",
"s3:GetBucketTagging",
"s3:GetBucketVersioning",
"s3:GetEncryptionConfiguration",
"s3:GetLifecycleConfiguration",
"s3:ListBucket",
"s3:PutBucketPublicAccessBlock",
"s3:PutBucketTagging",
"s3:PutBucketVersioning",
"s3:PutEncryptionConfiguration",
"s3:PutLifecycleConfiguration",
]
resources = [local.lake_bucket_arn]
}
statement {
sid = "CloudWatchAlarms"
effect = "Allow"
actions = [
"cloudwatch:DeleteAlarms",
"cloudwatch:DescribeAlarms",
"cloudwatch:ListTagsForResource",
"cloudwatch:PutMetricAlarm",
"cloudwatch:TagResource",
"cloudwatch:UntagResource",
]
resources = local.alarm_arns
}
# Workspace ids are generated at create time, so grafana verbs stay on "*";
# workspace deletion is gated on the project tag below.
#trivy:ignore:AVD-AWS-0057
statement {
sid = "GrafanaWorkspaces"
effect = "Allow"
actions = [
"grafana:CreateWorkspace",
"grafana:DescribeWorkspace",
"grafana:DescribeWorkspaceAuthentication",
"grafana:DescribeWorkspaceConfiguration",
"grafana:ListTagsForResource",
"grafana:ListVersions",
"grafana:ListWorkspaces",
"grafana:TagResource",
"grafana:UntagResource",
"grafana:UpdateWorkspace",
"grafana:UpdateWorkspaceAuthentication",
"grafana:UpdateWorkspaceConfiguration",
]
resources = ["*"]
}
#trivy:ignore:AVD-AWS-0057
statement {
sid = "GrafanaDestroy"
effect = "Allow"
actions = ["grafana:DeleteWorkspace"]
resources = ["*"]
condition {
test = "StringEquals"
variable = "aws:ResourceTag/Project"
values = [local.project_prefix]
}
}
statement {
sid = "GrafanaDependencies"
effect = "Allow"
actions = [
"organizations:DescribeOrganization",
"sso:CreateManagedApplicationInstance",
"sso:DeleteManagedApplicationInstance",
"sso:DescribeRegisteredRegions",
"sso:GetSharedSsoConfiguration",
]
resources = ["*"]
}
# Key ids are generated at create time, so key-scoped verbs use key/* within
# this account and region; alias verbs are pinned to the project prefix and
# key deletion is gated on the project tag.
#trivy:ignore:AVD-AWS-0057
statement {
sid = "KMSKeyCreate"
effect = "Allow"
actions = ["kms:CreateKey"]
resources = ["*"]
}
#trivy:ignore:AVD-AWS-0057
statement {
sid = "KMSKeyLifecycle"
effect = "Allow"
actions = [
"kms:DescribeKey",
"kms:EnableKeyRotation",
"kms:GetKeyPolicy",
"kms:GetKeyRotationStatus",
"kms:ListResourceTags",
"kms:TagResource",
"kms:UntagResource",
]
resources = local.kms_key_arns
}
#trivy:ignore:AVD-AWS-0057
statement {
sid = "KMSAliasLifecycle"
effect = "Allow"
actions = [
"kms:CreateAlias",
"kms:DeleteAlias",
"kms:UpdateAlias",
]
resources = concat(local.kms_alias_arns, local.kms_key_arns)
}
#trivy:ignore:AVD-AWS-0057
statement {
sid = "KMSDestroy"
effect = "Allow"
actions = [
"kms:DisableKey",
"kms:ScheduleKeyDeletion",
]
resources = local.kms_key_arns
condition {
test = "StringEquals"
variable = "aws:ResourceTag/Project"
values = [local.project_prefix]
}
}
}
# Permissions boundary shared by the deploy role and the service roles it
# manages (IaC-2). It is a ceiling, not a grant — effective permissions are the
# intersection with each role's identity policy — so per-service wildcards here
# are intentional. The load-bearing part is what iam: allows exclude (no role
# mutation on the deploy role's own name pattern) plus the explicit denies:
# even a compromised deploy role cannot detach the boundary, rewrite it, or
# escalate itself. The two suppressed checks flag the ceiling's s3:* action
# (resource-pinned to project buckets) and PassRole on the service-role name
# patterns — both deliberate here.
#trivy:ignore:AVD-AWS-0342
#trivy:ignore:AVD-AWS-0345
data "aws_iam_policy_document" "permissions_boundary" {
#trivy:ignore:AVD-AWS-0057
statement {
sid = "ProjectServicesCeiling"
effect = "Allow"
actions = [
"cloudwatch:*",
"dynamodb:*",
"ec2:*",
"grafana:*",
"kafka-cluster:*",
"kafka:*",
"kinesisanalytics:*",
"kms:*",
"organizations:DescribeOrganization",
"sso:*",
]
resources = ["*"]
}
# Action wildcard is the point of a ceiling; the resource list is pinned to
# project-prefixed buckets, so this cannot reach the account's other buckets.
#trivy:ignore:AVD-AWS-0345
statement {
sid = "ProjectBucketsCeiling"
effect = "Allow"
actions = ["s3:*"]
resources = local.project_bucket_arns
}
#trivy:ignore:AVD-AWS-0057
statement {
sid = "IamReadCeiling"
effect = "Allow"
actions = [
"iam:Get*",
"iam:List*",
]
resources = ["*"]
}
# PassRole is limited to the project's service-role name patterns; the "*"
# in them is the environment suffix, not an open wildcard.
#trivy:ignore:AVD-AWS-0342
statement {
sid = "IamPassRoleCeiling"
effect = "Allow"
actions = ["iam:PassRole"]
resources = local.service_role_arns
}
#trivy:ignore:AVD-AWS-0057
statement {
sid = "IamServiceLinkedRoleCeiling"
effect = "Allow"
actions = ["iam:CreateServiceLinkedRole"]
resources = ["*"]
}
statement {
sid = "IamServiceRoleMutationCeiling"
effect = "Allow"
actions = [
"iam:AttachRolePolicy",
"iam:CreateRole",
"iam:DeleteRole",
"iam:DeleteRolePolicy",
"iam:DetachRolePolicy",
"iam:PutRolePolicy",
"iam:TagRole",
"iam:UntagRole",
"iam:UpdateAssumeRolePolicy",
]
resources = local.service_role_arns
}
statement {
sid = "IamOidcProviderCeiling"
effect = "Allow"
actions = [
"iam:AddClientIDToOpenIDConnectProvider",
"iam:CreateOpenIDConnectProvider",
"iam:DeleteOpenIDConnectProvider",
"iam:RemoveClientIDFromOpenIDConnectProvider",
"iam:TagOpenIDConnectProvider",
"iam:UntagOpenIDConnectProvider",
"iam:UpdateOpenIDConnectProviderThumbprint",
]
resources = [local.oidc_provider_arn]
}
statement {
sid = "IamBoundaryPolicyCreateCeiling"
effect = "Allow"
actions = [
"iam:CreatePolicy",
"iam:TagPolicy",
"iam:UntagPolicy",
]
resources = [local.boundary_policy_arn]
}
statement {
sid = "DenyBoundaryDetach"
effect = "Deny"
actions = [
"iam:DeleteRolePermissionsBoundary",
"iam:PutRolePermissionsBoundary",
]
resources = ["*"]
}
statement {
sid = "DenyBoundaryPolicyMutation"
effect = "Deny"
actions = [
"iam:CreatePolicyVersion",
"iam:DeletePolicy",
"iam:DeletePolicyVersion",
"iam:SetDefaultPolicyVersion",
]
resources = [local.boundary_policy_arn]
}
}
resource "aws_iam_policy" "permissions_boundary" {
name = local.boundary_policy_name
policy = data.aws_iam_policy_document.permissions_boundary.json
}
resource "aws_iam_openid_connect_provider" "github_actions" {
url = local.oidc_url
client_id_list = ["sts.amazonaws.com"]
thumbprint_list = [local.oidc_thumbprint]
}
resource "aws_iam_role" "github_actions" {
name = var.role_name
assume_role_policy = data.aws_iam_policy_document.assume_role.json
permissions_boundary = aws_iam_policy.permissions_boundary.arn
}
resource "aws_iam_role_policy" "terraform" {
name = "${var.role_name}-terraform"
role = aws_iam_role.github_actions.id
policy = data.aws_iam_policy_document.terraform.json
}