Merge pull request #4 from fiap-8soat-tc-one/feature/tf-sample #4
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 Deploy to AWS | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
terraform: | |
name: Terraform Deploy | |
runs-on: ubuntu-latest | |
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-session-token: ${{ secrets.AWS_SESSION_TOKEN }} | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Initialize Terraform | |
working-directory: ./src/infra | |
run: terraform init | |
- name: Terraform Plan | |
working-directory: ./src/infra | |
env: | |
TF_VAR_db_password: ${{ secrets.AWS_RDS_DB_PASSWORD }} | |
run: terraform plan -out=tfplan | |
- name: Terraform Apply | |
working-directory: ./src/infra | |
env: | |
TF_VAR_db_password: ${{ secrets.AWS_RDS_DB_PASSWORD }} | |
run: terraform apply -auto-approve tfplan |