이제 .gitlab.yml
파일 수정을 마무리할 시점이 왔다.
destroy에도 두 단계가 있다.
하나는 staging을 위한 destroy
다른 하나는 production을 위한 destroy다.
Staging Destroy:
stage: Destroy
script:
- echo "Run Terraform Destroy for Staging"
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|production)$/'
when: manual
Production Destroy:
stage: Destroy
script:
- echo "Run Terraform Destroy for Production"
rules:
- if: '$CI_COMMIT_BRANCH == "production"'
when: manual
Staging Destroy:
stage: Destroy
script:
- cd deploy/
- terraform init
- terraform workspace select staging
- terraform destroy -auto-approve
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|production)$/'
when: manual
Production Destroy:
stage: Destroy
script:
- cd deploy/
- terraform init
- terraform workspace select production
- terraform destroy -auto-approve
rules:
- if: '$CI_COMMIT_BRANCH == "production"'
when: manual