forked from f5devcentral/f5-xc-terraform-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (95 loc) · 3.03 KB
/
aws-vpc-site-destroy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: "AWS VPC Site Destroy"
on:
push:
branches:
- aws-vpc-site
workflow_dispatch:
inputs:
TF_CLOUD_WORKSPACE_AWS_VPC_SITE:
description: "TF Cloud Workspace (optional)"
required: false
type: string
workflow_call:
inputs:
TF_CLOUD_WORKSPACE_AWS_VPC_SITE:
description: "TF Cloud Workspace"
required: false
type: string
secrets:
TF_API_TOKEN:
required: true
TF_CLOUD_ORGANIZATION:
required: true
XC_API_P12_FILE:
required: true
XC_P12_PASSWORD :
required: true
XC_API_URL:
required: true
AWS_ACCESS_KEY:
required: true
AWS_SECRET_KEY:
required: true
AWS_SESSION_TOKEN:
required: true
XC_AWS_CLOUD_CREDENTIALS_NAME:
required: false
jobs:
aws_vpc_site:
name: "AWS VPC Site Destroy"
runs-on: ubuntu-latest
defaults:
run:
working-directory: "./f5/xc/aws-vpc-site"
env:
VOLT_API_URL: ${{ secrets.XC_API_URL }}
VOLT_API_P12_FILE: "./api.p12"
VES_P12_PASSWORD: ${{ secrets.XC_P12_PASSWORD }}
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }}
TF_VAR_aws_cloud_credentials_name: ${{ secrets.XC_AWS_CLOUD_CREDENTIALS_NAME }}
TF_CLOUD_WORKSPACE_AWS_VPC_SITE: "aws-vpc-site"
TF_VAR_aws_region: "us-east-1"
TF_VAR_name: "aws-vpc-site"
TF_VAR_prefix: ""
TF_VAR_site_type: "ingress_gw"
TF_VAR_master_nodes_az_names: "[\"us-east-1a\"]"
TF_VAR_vpc_cidr: "10.10.0.0/16"
TF_VAR_local_subnets: "[\"10.10.1.0/24\"]"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: f5devcentral/f5-xc-terraform-examples
- id: apply_variables
uses: "f5devcentral/f5-xc-terraform-examples/.github/actions/apply-variables@main"
with:
vars_json: "${{ toJSON(vars) }}"
vars_prefix: "AWSVS_TF_VAR_"
inputs_json: "${{ toJSON(inputs) }}"
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Setup Terraform Backend
id: backend
run: |
echo "${{secrets.XC_API_P12_FILE}}" | base64 -d > api.p12
echo VOLT_API_P12_FILE="$PWD/api.p12" >> "$GITHUB_ENV"
cat > backend.tf << EOF
terraform {
cloud {
organization = "${{ secrets.TF_CLOUD_ORGANIZATION }}"
workspaces {
name = "$TF_CLOUD_WORKSPACE_AWS_VPC_SITE"
}
}
}
EOF
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Destroy
id: destroy
run: terraform destroy -auto-approve -input=false