Skip to content

Update demoterraform.yml #31

Update demoterraform.yml

Update demoterraform.yml #31

Workflow file for this run

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