File tree Expand file tree Collapse file tree 2 files changed +37
-25
lines changed Expand file tree Collapse file tree 2 files changed +37
-25
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,25 @@ resource "aws_iam_role_policy" "deployment" {
2121 system_environment : local.system_environment
2222 })))
2323}
24+
25+ # Create a separate policy for state access to avoid size limits on the main
26+ # policy.
27+ resource "aws_iam_policy" "state" {
28+ name = " ${ var . project } -${ local . system_environment } -state-policy"
29+ description = " Allow access to S3 bucket and DynamoDB table for Terraform state."
30+
31+ policy = jsonencode (yamldecode (templatefile (" ${ path . module } /templates/state-policy.yaml.tftpl" , {
32+ account_id : data.aws_caller_identity.identity.account_id
33+ environment : var.environment
34+ region : data.aws_region.current.region
35+ partition : data.aws_partition.current.partition
36+ project : var.project
37+ })))
38+
39+ tags = var. tags
40+ }
41+
42+ resource "aws_iam_role_policy_attachments_exclusive" "attach" {
43+ role_name = aws_iam_role. deployment . name
44+ policy_arns = [aws_iam_policy . state . arn ]
45+ }
Original file line number Diff line number Diff line change 11Version: " 2012-10-17"
22Statement:
3- - Sid: InfraStateAccess
4- Effect: Allow
5- Action:
6- - s3: CreateBucket
7- - s3: ListBucket
8- - s3: GetBucketLocation
9- - s3: GetObject
10- - s3: PutObject
11- - s3: DeleteObject
12- Resource:
13- - arn: ${partition}: s3::: ${project}- ${environment}- tfstate
14- - arn: ${partition}: s3::: ${project}- ${environment}- tfstate/*
15- - Sid: InfraLockAccess
16- Effect: Allow
17- Action:
18- - dynamodb:CreateTable
19- - dynamodb:DescribeTable
20- - dynamodb:DeleteTable
21- - dynamodb:UpdateTable
22- - dynamodb:GetItem
23- - dynamodb:PutItem
24- - dynamodb:DeleteItem
25- Resource:
26- - arn:${partition}:dynamodb:${region}:${account_id}:table/${environment}.tfstate
27-
283 - Sid: GlobalActions
294 Effect: Allow
305 Action:
@@ -171,6 +146,21 @@ Statement:
171146 - arn:${partition}:ecs:${region}:${account_id}:task/${project}-${system_environment}-*
172147 - arn:${partition}:ecs:${region}:${account_id}:task-definition/${project}-${system_environment}-*
173148
149+ - Sid: EventBridgeAccess
150+ Effect: Allow
151+ Action:
152+ - events:DeleteRule
153+ - events:DescribeRule
154+ - events:ListTagsForResource
155+ - events:ListTargetsByRule
156+ - events:PutRule
157+ - events:PutTargets
158+ - events:RemoveTargets
159+ - events:TagResource
160+ - events:UntagResource
161+ Resource:
162+ - arn:${partition}:events:${region}:${account_id}:rule/${project}-${system_environment}-*
163+
174164 - Sid: IAMAccess
175165 Effect: Allow
176166 Action:
You can’t perform that action at this time.
0 commit comments