Skip to content

Commit 069bc31

Browse files
committed
Added terraform pipelines
1 parent 7638313 commit 069bc31

3 files changed

Lines changed: 116 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Terraform apply pipeline
2+
3+
on:
4+
workflow_dispatch
5+
6+
7+
jobs:
8+
apply_terraform:
9+
runs-on: ubuntu-latest
10+
11+
defaults:
12+
run:
13+
working-directory: terraform_infra
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Configure AWS Credentials
20+
uses: aws-actions/configure-aws-credentials@v4
21+
with:
22+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
23+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
24+
aws-region: ap-south-1
25+
26+
- name: Setup Terraform
27+
uses: hashicorp/setup-terraform@v3
28+
with:
29+
terraform_version: 1.15.6
30+
31+
- name: Initialize Terraform
32+
run: terraform init
33+
34+
- name: Apply Terraform
35+
run: terraform apply --auto-approve
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Terraform destroy pipeline
2+
3+
on:
4+
workflow_dispatch
5+
6+
7+
jobs:
8+
apply_terraform:
9+
runs-on: ubuntu-latest
10+
11+
defaults:
12+
run:
13+
working-directory: terraform_infra
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Configure AWS Credentials
20+
uses: aws-actions/configure-aws-credentials@v4
21+
with:
22+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
23+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
24+
aws-region: ap-south-1
25+
26+
- name: Setup Terraform
27+
uses: hashicorp/setup-terraform@v3
28+
with:
29+
terraform_version: 1.15.6
30+
31+
- name: Initialize Terraform
32+
run: terraform init
33+
34+
- name: Destroy Terraform
35+
run: terraform destroy --auto-approve
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Terraform pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
main
7+
8+
paths:
9+
- 'terraform_infra/**'
10+
11+
jobs:
12+
apply_terraform:
13+
runs-on: ubuntu-latest
14+
15+
defaults:
16+
run:
17+
working-directory: terraform_infra
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Configure AWS Credentials
24+
uses: aws-actions/configure-aws-credentials@v4
25+
with:
26+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
27+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28+
aws-region: ap-south-1
29+
30+
- name: Setup Terraform
31+
uses: hashicorp/setup-terraform@v3
32+
with:
33+
terraform_version: 1.15.6
34+
35+
- name: Initialize Terraform
36+
run: terraform init
37+
38+
- name: Format correction
39+
run: terraform fmt -check -recursive
40+
41+
- name: Validate the configuration
42+
run: terraform validate
43+
44+
- name: Plan the infra
45+
id: plan
46+
run: terraform plan -out=tfplan

0 commit comments

Comments
 (0)