|
1 | | -# name: Terraform Pipeline |
| 1 | +name: Terraform Pipeline |
2 | 2 |
|
3 | | -# on: |
4 | | -# push: |
5 | | -# branches: |
6 | | -# - main # Only trigger on push to main branch |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main # Only trigger on push to main branch |
7 | 7 |
|
8 | | -# workflow_call: |
| 8 | + workflow_call: |
9 | 9 |
|
10 | | -# env: |
11 | | -# AWS_REGION: eu-west-3 |
| 10 | +env: |
| 11 | + AWS_REGION: eu-west-3 |
12 | 12 |
|
13 | 13 |
|
14 | | -# permissions: |
15 | | -# id-token: write |
16 | | -# contents: read |
| 14 | +permissions: |
| 15 | + id-token: write |
| 16 | + contents: read |
17 | 17 |
|
18 | | -# jobs: |
19 | | -# terraform: |
20 | | -# runs-on: ubuntu-latest |
| 18 | +jobs: |
| 19 | + terraform: |
| 20 | + runs-on: ubuntu-latest |
21 | 21 |
|
22 | | -# steps: |
23 | | -# # Checkout the code |
24 | | -# - name: Checkout code |
25 | | -# uses: actions/checkout@v2 |
| 22 | + steps: |
| 23 | + # Checkout the code |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v2 |
26 | 26 |
|
27 | | -# # Configure AWS credentials |
28 | | -# - name: configure aws credentials |
29 | | -# uses: aws-actions/configure-aws-credentials@v3 |
30 | | -# with: |
31 | | -# role-to-assume: arn:aws:iam::730335299686:role/GithubActionsRole |
32 | | -# aws-region: ${{ env.AWS_REGION }} |
33 | | - |
34 | | -# # Set up Terraform |
35 | | -# - name: Set up Terraform |
36 | | -# uses: hashicorp/setup-terraform@v2 |
37 | | -# with: |
38 | | -# terraform_version: 1.3.6 |
39 | | - |
40 | | -# # Terraform initialization |
41 | | -# - name: Terraform Init |
42 | | -# run: terraform init |
43 | | -# working-directory: terraform |
44 | | - |
45 | | -# # Terraform validate |
46 | | -# - name: Terraform Validate |
47 | | -# run: terraform validate |
48 | | -# working-directory: terraform |
49 | | - |
50 | | -# # Terraform plan |
51 | | -# - name: Terraform Plan |
52 | | -# run: terraform plan -out=tfplan |
53 | | -# working-directory: terraform |
54 | | - |
55 | | -# # Terraform apply |
56 | | -# # Commented for testing purposes |
57 | | -# # - name: Terraform Apply |
58 | | -# # run: terraform apply -auto-approve tfplan |
59 | | -# # working-directory: terraform |
| 27 | + # Configure AWS credentials |
| 28 | + - name: configure aws credentials |
| 29 | + uses: aws-actions/configure-aws-credentials@v3 |
| 30 | + with: |
| 31 | + role-to-assume: arn:aws:iam::730335299686:role/GithubActionsRole |
| 32 | + aws-region: ${{ env.AWS_REGION }} |
| 33 | + |
| 34 | + # Set up Terraform |
| 35 | + - name: Set up Terraform |
| 36 | + uses: hashicorp/setup-terraform@v2 |
| 37 | + with: |
| 38 | + terraform_version: 1.3.6 |
| 39 | + |
| 40 | + # Terraform initialization |
| 41 | + - name: Terraform Init |
| 42 | + run: terraform init |
| 43 | + working-directory: terraform |
| 44 | + |
| 45 | + # Terraform validate |
| 46 | + - name: Terraform Validate |
| 47 | + run: terraform validate |
| 48 | + working-directory: terraform |
| 49 | + |
| 50 | + # Terraform plan |
| 51 | + - name: Terraform Plan |
| 52 | + run: terraform plan -out=tfplan |
| 53 | + working-directory: terraform |
| 54 | + |
| 55 | + # Terraform apply |
| 56 | + - name: Terraform Apply |
| 57 | + run: terraform apply -auto-approve tfplan |
| 58 | + working-directory: terraform |
0 commit comments