Skip to content

add aws configure

add aws configure #12

name: 'Terraform destroy'
on:
push:
branches: [ "main" ]
schedule:
- cron: "0 15 * * 1-5" # UTC standard -> KRT = UTC + 9, KRT 13:00 = 04:00 + 9
permissions:
contents: read
jobs:
terraform-destroy:
name: 'Terraform destroy'
runs-on: ubuntu-latest
environment: production
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4
# Install the latest version of Terraform CLI
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
# Configure AWS credentials
- name: Configure AWS credentials
run: aws configure --profile falconlee236
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ap-northeast-2
# Create terraform.prod.tfvars file
- name: Create terraform.prod.tfvars file
run: |-
cat > terraform.prod.tfvars <<EOF
dockerhub_id="${{ secrets.DOCKERHUB_id }}"
dockerhub_pwd ="${{ secrets.DOCKERHUB_pwd }}"
EOF
# Create google cloud service account credential.json file
- name: Configure GCP service account credentials
run: echo "${{ secrets.GCP_SERVICE_ACCOUNT_JSON_VALUE }}" > credentials.json
- name: Terraform init
run: cd src && terraform init
env:
GOOGLE_CREDENTIALS: ${{ secrets.GCP_SERVICE_ACCOUNT_JSON_VALUE }}
# destroy GCP instance
- name: destory GCP Compute Engine
run: make clean
env:
GOOGLE_CREDENTIALS: ${{ secrets.GCP_SERVICE_ACCOUNT_JSON_VALUE }}