Skip to content

Commit bb9bb2e

Browse files
jasoniharrisJason Harrisscottgerring
authored
chore: SAM and Terraform IaC extracted from pr_build and simplified approach. (#1533)
* SAM and Terraform IaC extracted from pr_build and simplified approach. * Update .github/workflows/pr_iac_lint.yml Co-authored-by: Scott Gerring <[email protected]> --------- Co-authored-by: Jason Harris <[email protected]> Co-authored-by: Scott Gerring <[email protected]>
1 parent 04d692a commit bb9bb2e

File tree

2 files changed

+49
-21
lines changed

2 files changed

+49
-21
lines changed

.github/workflows/pr_build.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,33 +79,12 @@ jobs:
7979
if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8
8080
working-directory: examples/powertools-examples-core/kotlin
8181
run: ./gradlew build
82-
- name: Setup Terraform
83-
if: ${{ matrix.java == '11' }}
84-
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 #v2.0.3
8582
- name: Setup AWS credentials
8683
if: ${{ matrix.java == '11' }}
8784
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
8885
with:
8986
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
9087
aws-region: ${{ env.AWS_REGION }}
91-
- name: Terraform validate
92-
working-directory: examples/powertools-examples-core/terraform
93-
if: ${{ matrix.java == '11' }}
94-
run: |
95-
terraform -version
96-
terraform init -backend=false
97-
terraform validate
98-
terraform plan
99-
- name: Setup Terraform lint
100-
if: ${{ matrix.java == '11' }}
101-
uses: terraform-linters/setup-tflint@a5a1af8c6551fb10c53f1cd4ba62359f1973746f # v3.1.1
102-
- name: Terraform lint
103-
working-directory: examples/powertools-examples-core/terraform
104-
if: ${{ matrix.java == '11' }}
105-
run: |
106-
tflint --version
107-
tflint --init
108-
tflint -f compact
10988
- name: Upload coverage to Codecov
11089
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
11190
if: ${{ matrix.java == '11' }} # publish results once

.github/workflows/pr_iac_lint.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Validate IaC
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- v2
8+
pull_request:
9+
branches:
10+
- main
11+
- v2
12+
paths:
13+
- 'examples/**'
14+
jobs:
15+
linter:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
project: ["sam", "gradle", "kotlin"]
20+
steps:
21+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
22+
- name: Setup java JDK
23+
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
24+
with:
25+
distribution: 'corretto'
26+
java-version: 11
27+
- name: Run SAM validator to check syntax of IaC templates - Java
28+
working-directory: examples/powertools-examples-core/${{ matrix.project }}
29+
run: |
30+
sam build
31+
sam validate --lint
32+
- name: Setup Terraform
33+
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 #v2.0.3
34+
- name: Run Terraform validator to check syntax of IaC templates and produce a plan of changes
35+
working-directory: examples/powertools-examples-core/terraform
36+
run: |
37+
mvn install
38+
terraform -version
39+
terraform init -backend=false
40+
terraform validate
41+
terraform plan
42+
- name: Setup Terraform lint
43+
uses: terraform-linters/setup-tflint@a5a1af8c6551fb10c53f1cd4ba62359f1973746f # v3.1.1
44+
- name: Run Terraform lint to check for best practices, errors, deprecated syntax etc.
45+
working-directory: examples/powertools-examples-core/terraform
46+
run: |
47+
tflint --version
48+
tflint --init
49+
tflint -f compact

0 commit comments

Comments
 (0)