Skip to content

added modules for tfc cloud #100

added modules for tfc cloud

added modules for tfc cloud #100

name: Terraform AWS Workflow
on:
workflow_call:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
tfpath:
description: 'TF File Path'
required: false
default: 'aws_samples/create_ec2'
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
tf_code_check:
name: Terraform Validation and Build
runs-on: ubuntu-latest
if: ${{ inputs.tfpath }}
steps:
- name: Checkout tf code in runner environment
uses: actions/[email protected]
- name: Configure AWS Credentials Action For GitHub Actions
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Setup Terraform CLI
uses: hashicorp/[email protected]
- name: Terraform init and validate
run: |
echo `pwd`
echo "tfpath ${{ github.event.inputs.tfpath }}"
echo "** Running Terraform Init**"
terraform init
echo "** Running Terraform Validate**"
terraform validate
working-directory: ${{ github.event.inputs.tfpath }}
- name: Terraform plan and apply
run: |
echo `pwd`
echo "tfpath ${{ github.event.inputs.tfpath }}"
echo "** Running Terraform Plan**"
terraform plan
echo "** Running Terraform Apply**"
terraform apply -auto-approve
working-directory: ${{ github.event.inputs.tfpath }}
- name: Terraform Destroy
run: |
echo "** Running Terraform Destroy**"
terraform destroy -auto-approve
working-directory: ${{ github.event.inputs.tfpath }}