refactor: Migrate Python code to TypeScript Serverless (#35) #19
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: Deploying in dev environment via Terraform | |
on: | |
push: | |
branches: | |
- main | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
S3_REGION: ${{ secrets.S3_REGION }} | |
S3_BUCKET: ${{ secrets.S3_BUCKET }} | |
DYNAMODB: ${{ secrets.DYNAMODB }} | |
TF_VAR_database_username: ${{ secrets.TF_VAR_DATABASE_USERNAME }} | |
TF_VAR_database_password: ${{ secrets.TF_VAR_DATABASE_PASSWORD }} | |
jobs: | |
tf_init: | |
name: Terraform Init | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_version: 1.3.7 | |
- name: Terraform Init | |
run: terraform init -backend-config="bucket=$S3_BUCKET" -backend-config="region=$S3_REGION" -backend-config="dynamodb_table=$DYNAMODB" | |
- name: Terraform Workspace | |
run: terraform workspace new dev 2> /dev/null || terraform workspace select dev | |
- name: Terraform Validate | |
run: terraform validate | |
tf_plan: | |
name: Terraform Plan | |
needs: [tf_init] | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_version: 1.3.7 | |
- name: Terraform Init | |
run: terraform init -backend-config="bucket=$S3_BUCKET" -backend-config="region=$S3_REGION" -backend-config="dynamodb_table=$DYNAMODB" | |
- name: Terraform Workspace | |
run: terraform workspace new dev 2> /dev/null || terraform workspace select dev | |
- name: Terraform Plan | |
run: terraform plan -input=false -out=terraform-plan-dev | |
- name: Upload Terraform Plan | |
uses: actions/upload-artifact@v2 | |
with: | |
name: terraform-plan-dev | |
path: terraform-plan-dev | |
tf_apply: | |
name: Terraform Apply | |
needs: [tf_plan] | |
runs-on: ubuntu-latest | |
environment: dev-manual | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_version: 1.3.7 | |
- name: Terraform Init | |
run: terraform init -backend-config="bucket=$S3_BUCKET" -backend-config="region=$S3_REGION" -backend-config="dynamodb_table=$DYNAMODB" | |
- name: Terraform Workspace | |
run: terraform workspace new dev 2> /dev/null || terraform workspace select dev | |
- name: Download Terraform Plan | |
uses: actions/download-artifact@v2 | |
with: | |
name: terraform-plan-dev | |
- name: Terraform Apply | |
run: terraform apply -auto-approve terraform-plan-dev |