Skip to content

terraform deploy

terraform deploy #11

Workflow file for this run

name: terraform deploy
on:
workflow_dispatch:
inputs:
environment:
description: 'Target environment (dev, prod)'
required: true
default: 'dev'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
uses: actions/checkout@v2
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.10.3
- name: Create Terraform Credentials File
run: |
mkdir -p ~/.terraform.d
cat <<EOF > ~/.terraform.d/credentials.tfrc.json
{
"credentials": {
"app.terraform.io": {
"token": "${{ secrets.TF_API_TOKEN }}"
}
}
}
EOF
- name: Terraform Init and Apply
env:
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
working-directory: terraform/environments/${{ github.event.inputs.environment }}
run: |
terraform init
terraform plan -out=tfplan
terraform apply tfplan