Skip to content

Commit

Permalink
Update destroy-infra.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
VasaOfficial authored Jul 22, 2024
1 parent 1321be3 commit e5fbd0b
Showing 1 changed file with 26 additions and 107 deletions.
133 changes: 26 additions & 107 deletions .github/workflows/destroy-infra.yml
Original file line number Diff line number Diff line change
@@ -1,110 +1,29 @@
name: Destroy Infrastructure

name: Terraform Destroy
on:
workflow_dispatch:
workflow_dispatch:

jobs:
destroy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./user-service/terraform

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1

- name: Set up Terraform
uses: hashicorp/setup-terraform@v3

- name: Create varibales.tf file
run: |
cat <<EOF > variables.tf
variable "firebase_api_key" {
default = "${{ secrets.FIREBASE_API_KEY }}"
type = string
}
variable "firebase_auth_domain" {
default = "${{ secrets.FIREBASE_AUTH_DOMAIN }}"
type = string
}
variable "firebase_project_id" {
default = "${{ secrets.FIREBASE_PROJECT_ID }}"
type = string
}
variable "firebase_storage_bucket" {
default = "${{ secrets.FIREBASE_STORAGE_BUCKET }}"
type = string
}
variable "firebase_messaging_sender_id" {
default = "${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}"
type = string
}
variable "firebase_app_id" {
default = "${{ secrets.FIREBASE_APP_ID }}"
type = string
}
variable "firebase_type" {
default = "${{ secrets.FIREBASE_TYPE }}"
type = string
}
variable "firebase_private_key_id" {
default = "${{ secrets.FIREBASE_PRIVATE_KEY_ID }}"
type = string
}
variable "firebase_private_key" {
default = "${{ secrets.FIREBASE_PRIVATE_KEY }}"
type = string
}
variable "firebase_client_email" {
default = "${{ secrets.FIREBASE_CLIENT_EMAIL }}"
type = string
}
variable "firebase_client_id" {
default = "${{ secrets.FIREBASE_CLIENT_ID }}"
type = string
}
variable "firebase_auth_uri" {
default = "${{ secrets.FIREBASE_AUTH_URI }}"
type = string
}
variable "firebase_token_uri" {
default = "${{ secrets.FIREBASE_TOKEN_URI }}"
type = string
}
variable "firebase_auth_provider_x509_cert_url" {
default = "${{ secrets.FIREBASE_AUTH_PROVIDER_X509_CERT_URL }}"
type = string
}
variable "firebase_client_x509_cert_url" {
default = "${{ secrets.FIREBASE_CLIENT_X509_CERT_URL }}"
type = string
}
EOF
- name: Initialize Terraform
run: terraform init

- name: Terraform Destroy
run: terraform destroy -auto-approve
tf-destroy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-west-1'
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Terraform
uses: hashicorp/setup-terraform@v1

- name: Terraform Init
id: init
run: terraform init

- name: Show Destroy plan
run: terraform plan -destroy
continue-on-error: true

- name: Terraform destroy
id: destroy
run: terraform destroy -auto-approve

0 comments on commit e5fbd0b

Please sign in to comment.