Build Deploy API Gateway With Lambdas #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: Build Deploy API Gateway With Lambdas | |
on: | |
workflow_dispatch: # Configuração para deploy manual | |
jobs: | |
build: | |
name: Build and Deploy | |
runs-on: ubuntu-latest | |
environment: | |
name: staging | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.22 | |
- name: Build validate_token | |
run: | | |
cd src/funcs/validate_token | |
go build -o main main.go | |
zip validate_token.zip main | |
- name: Build generate_token | |
run: | | |
cd src/funcs/generate_token | |
go build -o main main.go | |
zip generate_token.zip main | |
- 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 | |
env: | |
TF_VAR_backend_url: ${{ vars.BACKEND_URL }} | |
run: terraform plan -out=tfplan | |
- name: Terraform Apply | |
working-directory: ./src/infra | |
env: | |
TF_VAR_backend_url: ${{ vars.BACKEND_URL }} | |
run: terraform apply -auto-approve tfplan |