Terraform Destroy Deploy to AWS #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Terraform Destroy Deploy to AWS | |
on: | |
workflow_dispatch: # Configuração para deploy manual | |
jobs: | |
build: | |
name: Terraform Deploy | |
runs-on: ubuntu-latest | |
environment: | |
name: staging | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_version: 1.9.8 | |
- name: Configure 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: ${{ vars.AWS_REGION }} | |
- name: Get Session Token | |
run: echo aws sts get-session-token | |
- name: Initialize Terraform | |
working-directory: ./src/infra | |
run: terraform init | |
- name: Terraform Plan | |
working-directory: ./src/infra | |
run: terraform plan -destroy -out=tfplan | |
- name: Terraform Apply | |
working-directory: ./src/infra | |
run: terraform apply -auto-approve tfplan |