Skip to content

Commit 46b760a

Browse files
authored
Merge pull request #1065 from byu-oit/opentofu
Use OpenTofu 1.9.0, refactor directory structure
2 parents 53ff143 + 2851dcd commit 46b760a

36 files changed

+464
-1024
lines changed

.github/dependabot.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,13 @@ updates:
1818
target-branch: dev
1919

2020
- package-ecosystem: terraform
21-
directory: '/terraform-iac/dev/app'
21+
directories:
22+
- '/iac/app'
23+
- '/iac/setup'
2224
schedule:
2325
interval: daily
2426
target-branch: dev
2527

26-
- package-ecosystem: terraform
27-
directory: '/terraform-iac/dev/setup'
28-
schedule:
29-
interval: daily
30-
target-branch: dev
31-
32-
# - package-ecosystem: terraform
33-
# directory: '/terraform-iac/modules/app'
34-
# schedule:
35-
# interval: daily
36-
# target-branch: dev
37-
#
38-
# - package-ecosystem: terraform
39-
# directory: '/terraform-iac/modules/setup'
40-
# schedule:
41-
# interval: daily
42-
# target-branch: dev
43-
4428
# For each of these, requesting reviews from your team makes Dependabot PRs easier to find (https://github.com/pulls/review-requested)
4529
# reviewers:
4630
# - byu-oit/your-github-team

.github/workflows/ci-app.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CI / App
2+
3+
on:
4+
pull_request:
5+
branches: [dev, stg, prd]
6+
types: [opened, reopened, synchronize, edited]
7+
paths:
8+
- 'src/**'
9+
- '.github/workflows/ci-app.yml'
10+
11+
env:
12+
node_version: "22.x"
13+
FORCE_COLOR: 3
14+
15+
jobs:
16+
test:
17+
name: Test
18+
timeout-minutes: 3
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ env.node_version }}
27+
cache: npm
28+
cache-dependency-path: '**/package-lock.json'
29+
30+
- name: npm ci
31+
working-directory: src
32+
run: npm ci --prefer-offline
33+
34+
- name: npm test
35+
working-directory: src
36+
run: npm test
37+
38+
- name: Report test coverage to Codecov
39+
uses: codecov/codecov-action@v3
40+
if: env.CODECOV_TOKEN
41+
env:
42+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
43+
44+
audit:
45+
name: Audit
46+
timeout-minutes: 3
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Set up Node.js
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: ${{ env.node_version }}
55+
56+
# We don't need to install deps to audit them
57+
58+
- name: npm audit
59+
working-directory: src
60+
run: npm audit --audit-level=critical
61+
62+
lint:
63+
name: Lint
64+
timeout-minutes: 3
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- name: Set up Node.js
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: ${{ env.node_version }}
73+
cache: npm
74+
cache-dependency-path: '**/package-lock.json'
75+
76+
- name: npm ci
77+
working-directory: src
78+
run: npm ci --prefer-offline
79+
80+
- name: npm lint
81+
working-directory: src
82+
run: npm run lint
Lines changed: 33 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
name: CI
1+
name: CI / IaC
22

33
on:
44
pull_request:
55
branches: [dev, stg, prd]
66
types: [opened, reopened, synchronize, edited]
7-
paths-ignore:
8-
- 'README.md'
9-
- 'LICENSE'
10-
- '.gitignore'
7+
paths:
8+
- 'iac/**'
9+
- '.github/workflows/ci-iac.yml'
10+
1111
env:
1212
node_version: "22.x"
13-
tf_version: "1.9.8" # must match value in terraform-iac/*/app/main.tf
14-
FORCE_COLOR: 3
13+
tf_version: "1.9.0" # must match value in iac/*/app/main.tf
1514

1615
jobs:
1716
env:
@@ -25,7 +24,7 @@ jobs:
2524
matrix='{
2625
"env":[
2726
{
28-
"tf_working_dir":"./terraform-iac/dev/app",
27+
"environment_name":"dev",
2928
"aws_account":"977306314792",
3029
"aws_gha_role":"hw-lambda-api-dev-gha"
3130
}
@@ -39,7 +38,7 @@ jobs:
3938
matrix='{
4039
"env":[
4140
{
42-
"tf_working_dir":"./terraform-iac/stg/app",
41+
"environment_name":"stg",
4342
"aws_account":"977306314792",
4443
"aws_gha_role":"hw-lambda-api-stg-gha"
4544
}
@@ -53,14 +52,14 @@ jobs:
5352
matrix='{
5453
"env":[
5554
{
56-
"tf_working_dir":"./terraform-iac/prd/app",
55+
"environment_name":"prd",
5756
"aws_account":"539738229445",
58-
"aws_gha_role":"hw-lambda-api-prd-gha"
57+
"aws_gha_role":"hw-lambda-api-cpy-gha"
5958
},
6059
{
61-
"tf_working_dir":"./terraform-iac/cpy/app",
60+
"environment_name":"cpy",
6261
"aws_account":"539738229445",
63-
"aws_gha_role":"hw-lambda-api-cpy-gha"
62+
"aws_gha_role":"hw-lambda-api-prd-gha"
6463
}
6564
]
6665
}'
@@ -69,96 +68,24 @@ jobs:
6968
outputs:
7069
matrix: ${{ env.matrix }}
7170

72-
test:
73-
name: Test
74-
runs-on: ubuntu-latest
75-
timeout-minutes: 3
76-
steps:
77-
- uses: actions/checkout@v4
78-
79-
- name: Set up Node.js
80-
uses: actions/setup-node@v4
81-
with:
82-
node-version: ${{ env.node_version }}
83-
cache: npm
84-
cache-dependency-path: '**/package-lock.json'
85-
86-
- name: npm ci
87-
working-directory: src
88-
run: npm ci --prefer-offline
89-
90-
- name: npm test
91-
working-directory: src
92-
run: npm test
93-
94-
- name: Report test coverage to Codecov
95-
uses: codecov/codecov-action@v5
96-
if: env.CODECOV_TOKEN
97-
env:
98-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
99-
100-
audit:
101-
name: Audit
102-
runs-on: ubuntu-latest
103-
timeout-minutes: 3
104-
steps:
105-
- uses: actions/checkout@v4
106-
107-
- name: Set up Node.js
108-
uses: actions/setup-node@v4
109-
with:
110-
node-version: ${{ env.node_version }}
111-
112-
# We don't need to install deps to audit them
113-
114-
- name: npm audit
115-
working-directory: src
116-
run: npm audit --audit-level=critical
117-
118-
lint:
119-
name: Lint
120-
runs-on: ubuntu-latest
121-
timeout-minutes: 3
122-
steps:
123-
- uses: actions/checkout@v4
124-
125-
- name: Set up Node.js
126-
uses: actions/setup-node@v4
127-
with:
128-
node-version: ${{ env.node_version }}
129-
cache: npm
130-
cache-dependency-path: '**/package-lock.json'
131-
132-
- name: npm ci
133-
working-directory: src
134-
run: npm ci --prefer-offline
135-
136-
- name: npm lint
137-
working-directory: src
138-
run: npm run lint
139-
14071
format:
141-
name: Terraform Format
72+
name: Tofu Format
14273
timeout-minutes: 3
14374
runs-on: ubuntu-latest
144-
needs: env
145-
strategy:
146-
matrix: ${{ fromJson(needs.env.outputs.matrix) }}
147-
fail-fast: false
14875
steps:
14976
- uses: actions/checkout@v4
15077

151-
- name: Terraform Setup
152-
uses: hashicorp/setup-terraform@v3
78+
- name: Tofu Setup
79+
uses: opentofu/setup-opentofu@v1
15380
with:
154-
terraform_version: ${{ env.tf_version }}
81+
tofu_version: ${{ env.tf_version }}
15582

156-
- name: Terraform Format
157-
working-directory: "./"
158-
run: terraform fmt -check -recursive
83+
- name: Tofu Format
84+
working-directory: iac
85+
run: tofu fmt -check -recursive
15986

16087
plan:
161-
name: Terraform Plan
88+
name: Tofu Plan / ${{ matrix.env.environment_name }}
16289
timeout-minutes: 6
16390
runs-on: ubuntu-latest
16491
needs: env
@@ -193,31 +120,30 @@ jobs:
193120
npm ci --production --prefer-offline
194121
zip -r lambda.zip *
195122
196-
- name: Terraform Setup
197-
uses: hashicorp/setup-terraform@v3
123+
- name: Tofu Setup
124+
uses: opentofu/setup-opentofu@v1
198125
with:
199-
terraform_version: ${{ env.tf_version }}
126+
tofu_version: ${{ env.tf_version }}
200127

201-
- name: Terraform Init
202-
working-directory: ${{ matrix.env.tf_working_dir }}
203-
run: terraform init
128+
- name: Tofu Init
129+
working-directory: iac/app
130+
run: tofu init -var-file=${{ matrix.env.environment_name }}.tfvars
204131

205-
- name: Terraform Plan
206-
working-directory: ${{ matrix.env.tf_working_dir }}
207-
run: terraform plan -input=false -out plan -lock=false
132+
- name: Tofu Plan
133+
working-directory: iac/app
134+
run: tofu plan -var-file=${{ matrix.env.environment_name }}.tfvars -input=false -out plan -lock=false
208135

209-
- name: Comment Terraform Plan
136+
- name: Comment Tofu Plan
210137
uses: byu-oit/github-action-tf-plan-comment@v1
211138
with:
212139
github-token: ${{ secrets.GITHUB_TOKEN }}
213-
working-directory: ${{ matrix.env.tf_working_dir }}
140+
working-directory: iac/app
214141
terraform-plan-file: plan
215142

216-
- name: Analyze Terraform Plan
143+
- name: Analyze Tofu Plan
217144
uses: byu-oit/github-action-tf-plan-analyzer@v2
218145
with:
219-
working-directory: ${{ matrix.env.tf_working_dir }}
146+
working-directory: iac/app
220147
terraform-plan-file: plan
221148
divvycloud-username: ${{ secrets.DIVVYCLOUD_USERNAME }}
222149
divvycloud-password: ${{ secrets.DIVVYCLOUD_PASSWORD }}
223-

0 commit comments

Comments
 (0)