-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (39 loc) · 1.29 KB
/
demoterraform.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: 'Terraform Deploy to AWS with Security Scanning'
on:
push:
branches:
- main # Set to the branch that triggers the deployment.
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
defaults:
run:
working-directory: terraform
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
- name: Set up AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1 # Replace with your AWS region
- name: Create Private Key File
run: |
echo "${{ secrets.CICD_PRIVATE_KEY_BASE64 }}" | base64 --decode > ${{ github.workspace }}/terraform/CICDKey.pem
- name: Terraform Initialize
run: terraform init
- name: Terraform Format and Write Changes
run: terraform fmt -recursive
- name: Commit any format changes
uses: EndBug/add-and-commit@v7
with:
message: 'Apply Terraform formatting changes'
add: '*.tf'
- name: Terraform Plan
run: terraform plan
- name: Terraform Apply
run: terraform apply -auto-approve