File tree Expand file tree Collapse file tree 4 files changed +75
-29
lines changed Expand file tree Collapse file tree 4 files changed +75
-29
lines changed Original file line number Diff line number Diff line change @@ -24,20 +24,28 @@ jobs:
2424        with :
2525          path : ~/.tflint.d/plugins 
2626          key : tflint-${{ hashFiles('.tflint.hcl') }} 
27-       - uses : terraform-linters/setup-tflint@v5  
27+       - uses : terraform-linters/setup-tflint@v6  
2828        name : Setup TFLint 
2929      - name : Show version 
3030        run : tflint --version 
3131      - name : Init TFLint 
3232        run : tflint --init 
3333      - name : Run TFLint 
34-         run : tflint --format sarif --recursive --config "$GITHUB_WORKSPACE/.tflint.hcl" > tflint-results.sarif 
34+         #  Run TFLint, outputting the results to a SARIF file. We use `tee` so
35+         #  that we can still see the output in the logs, and capture the exit
36+         #  code properly with `pipefail`.
37+         run : | 
38+           set -o pipefail 
39+           tflint --format sarif --recursive \ 
40+             --config "$GITHUB_WORKSPACE/.tflint.hcl" \ 
41+             | tee tflint-results.sarif 
42+           exit "${PIPESTATUS[0]}" 
3543       - name : Parse SARIF file for annotations 
3644        if : always() 
37-         uses : Miragon /sarif-report-parse@v1 .0.4 
45+         uses : jontyms /sarif-annotations@v0 .0.3 
3846        with :
39-           severity-level : low 
4047          sarif-file : tflint-results.sarif 
48+           annotation-level : notice 
4149      #  When run on main, if SARIF uploads are available, we want to upload the
4250      #  SARIF file to GitHub.
4351      - name : Upload SARIF result 
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: 
Original file line number Diff line number Diff line change 1+ Version:  " 2012-10-17" 
2+ Statement: 
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 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments