Skip to content

Commit 1a68508

Browse files
committed
ci: add terraform plan and demo workflows (OIDC)
1 parent a4af7f7 commit 1a68508

2 files changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI - Terraform Plan (OIDC)
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
push:
7+
branches: ["main"]
8+
9+
permissions:
10+
id-token: write
11+
contents: read
12+
13+
jobs:
14+
plan:
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
shell: bash
19+
working-directory: terraform/environments/dev
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Configure AWS credentials (OIDC)
26+
uses: aws-actions/configure-aws-credentials@v4
27+
with:
28+
role-to-assume: arn:aws:iam::588738591601:role/github-actions-cloudops-dev
29+
aws-region: ca-central-1
30+
role-session-name: gha-tf-plan
31+
32+
- name: Setup Terraform
33+
uses: hashicorp/setup-terraform@v3
34+
with:
35+
terraform_version: 1.7.5
36+
37+
- name: Terraform fmt (check)
38+
run: terraform fmt -check -recursive
39+
40+
- name: Terraform init
41+
run: terraform init -input=false
42+
43+
- name: Terraform validate
44+
run: terraform validate
45+
46+
- name: Terraform plan
47+
run: terraform plan -no-color -input=false
48+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Demo - Rebuild, Validate, Teardown (OIDC)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
id-token: write
8+
contents: read
9+
10+
jobs:
11+
demo:
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Configure AWS credentials (OIDC)
22+
uses: aws-actions/configure-aws-credentials@v4
23+
with:
24+
role-to-assume: arn:aws:iam::588738591601:role/github-actions-cloudops-dev
25+
aws-region: ca-central-1
26+
role-session-name: gha-demo
27+
28+
- name: Make scripts executable
29+
run: chmod +x scripts/*.sh
30+
31+
- name: Rebuild demo environment
32+
run: ./scripts/rebuild-demo.sh
33+
34+
- name: Validate environment
35+
run: ./scripts/validate-env.sh
36+
37+
# CRITICAL: always teardown even if rebuild/validate fails
38+
- name: Teardown (always)
39+
if: always()
40+
run: ./scripts/teardown.sh
41+

0 commit comments

Comments
 (0)