Skip to content

GCP / Destroy

GCP / Destroy #512

# Copyright (C) Nicolas Lamirault <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
---
name: GCP / Destroy
on: # yamllint disable-line rule:truthy
workflow_dispatch:
inputs:
env:
description: 'Environment'
required: true
default: 'dev'
tf_version:
description: "Terraform version"
required: true
#datasource=github-tags depName=hashicorp/terraform
default: '1.2.2'
schedule:
- cron: "0 23 * * *"
permissions:
contents: read
jobs:
gcp_observability:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- run: |
echo "Delete Observability on GCP / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/observability/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/observability/${{ github.event.inputs.env }}
gcp_cert_manager:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- run: |
echo "Delete CertManager on GCP / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/cert-manager/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/cert-manager/${{ github.event.inputs.env }}
gcp_external_dns:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- run: |
echo "Delete External DNS on GCP / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/external-dns/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/external-dns/${{ github.event.inputs.env }}
gcp_gke:
needs:
- gcp_observability
- gcp_cert_manager
- gcp_external_dns
runs-on: ubuntu-latest
steps:
- run: |
echo "Undeploy Portefaix on GCP / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/gke/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/gke/${{ github.event.inputs.env }}
env:
TF_VAR_master_authorized_networks: "[{\"cidr_block\": \"${{ secrets.HOME_IP_ADDRESS }}\", \"display_name\": \"Home\"}]"
gcp_cloud_nat:
needs: gcp_gke
runs-on: ubuntu-latest
steps:
- run: |
echo "Cloud NAT on GCP / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/cloud-nat/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/cloud-nat/${{ github.event.inputs.env }}
gcp_cloud_dns:
# needs: gcp_gke
runs-on: ubuntu-latest
steps:
- run: |
echo "Cloud DNS on GCP / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/cloud-dns/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/cloud-dns/${{ github.event.inputs.env }}
gcp_cloud_armor:
# needs: gcp_gke
runs-on: ubuntu-latest
steps:
- run: |
echo "Cloud Armor on GCP / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/cloud-armor/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/cloud-armor/${{ github.event.inputs.env }}
gcp_secrets:
# needs: gcp_gke
runs-on: ubuntu-latest
steps:
- run: |
echo "PubSub on GCP / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/secrets/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/secrets/${{ github.event.inputs.env }}
gcp_pubsub:
# needs: gcp_gke
runs-on: ubuntu-latest
steps:
- run: |
echo "PubSub on GCP / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/pubsub/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/pubsub/${{ github.event.inputs.env }}
gcp_artifact_registry:
# needs: gcp_gke
runs-on: ubuntu-latest
steps:
- run: |
echo "Artifact Registry on GCP / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/artifact-registry/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/artifact-registry/${{ github.event.inputs.env }}
gcp_external_ip_cloud_nat:
needs: gcp_cloud_nat
runs-on: ubuntu-latest
steps:
- run: |
echo "External IP for Cloud NAT on GCP / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/external-ips/cloud-nat/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/external-ips/cloud-nat/${{ github.event.inputs.env }}
gcp_external_ip_external_lb:
needs: gcp_gke
runs-on: ubuntu-latest
steps:
- run: |
echo "External IP for External Load Balancer / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/external-ips/external-lb/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/external-ips/external-lb/${{ github.event.inputs.env }}
gcp_internal_ip_internal_lb:
needs: gcp_gke
runs-on: ubuntu-latest
steps:
- run: |
echo "Internal IP for Internal Load Balancer / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/internal-ips/internal-lb/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/internal-ips/internal-lb/${{ github.event.inputs.env }}
gcp_vpc:
needs:
- gcp_cloud_nat
- gcp_cloud_dns
- gcp_cloud_armor
- gcp_pubsub
- gcp_secrets
- gcp_artifact_registry
- gcp_external_ip_cloud_nat
- gcp_external_ip_external_lb
- gcp_internal_ip_internal_lb
runs-on: ubuntu-latest
steps:
- run: |
echo "Delete VPC / ${{ github.event.inputs.env }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Configure GCP credentials
# uses: google-github-actions/[email protected]
# with:
# version: 324.0.0
# service_account_key: ${{ secrets.GCP_SA_KEY_PROD }}
# export_default_credentials: true
# - name: Use gcloud CLI
# run: gcloud info
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ github.event.inputs.tf_version }}
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform Init
run: terraform init -upgrade
working-directory: terraform/gcp/vpc/${{ github.event.inputs.env }}
- name: Terraform Destroy
run: terraform destroy -auto-approve
working-directory: terraform/gcp/vpc/${{ github.event.inputs.env }}