Skip to content

AWS_Setup_Deployment #4

AWS_Setup_Deployment

AWS_Setup_Deployment #4

Workflow file for this run

name: "AWS_Setup_Deployment"
on:
workflow_dispatch:
env:
AWS_REGION: us-east-1
jobs:
security:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./aws_setup
steps:
- uses: actions/checkout@master
- uses: snyk/actions/setup@master
- uses: actions/setup-go@v1
with:
go-version: '1.13'
- name: Snyk monitor
run: snyk iac test --report
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
continue-on-error: true
terraform:
name: "Apply Terraform Code changes"
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./aws_setup
steps:
- name: "Checkout source code"
uses: actions/checkout@v4
- name: "Set up Terraform"
uses: hashicorp/setup-terraform@v3
- name: "Configure Terraform credentials"
run: |
mkdir -p ~/.terraform.d
cat > ~/.terraform.d/credentials.tfrc.json <<EOF
{
"credentials": {
"app.terraform.io": {
"token": "${{ secrets.TF_CLOUD_TOKEN }}"
}
}
}
EOF
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: "Terraform init"
id: init
run: echo "yes" | terraform init
- name: "Terraform fmt"
id: fmt
run: terraform fmt -check
continue-on-error: true
- name: "Terraform validate"
id: validate
run: terraform validate
- name: "Terraform plan"
id: plan
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: terraform plan -no-color -input=false
- name: "Terraform plan status"
if: steps.plan.outcome == 'failure'
run: echo "Terraform plan failed"
- name: "Terraform Apply"
id: apply
run: terraform apply --auto-approve -input=false