-
Notifications
You must be signed in to change notification settings - Fork 28
/
teardown.yml
39 lines (34 loc) · 1.24 KB
/
teardown.yml
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
version: '1.0'
steps:
check_env:
title: Check environment for required variables
image: bash:4.4.23
commands:
- echo 'Checking for CLUSTER_NAME, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY...'
- bash -c '[[ -z $CLUSTER_NAME || -z $AWS_ACCESS_KEY_ID || -z $AWS_SECRET_ACCESS_KEY ]] && exit 1 || true'
- cf_export K8S_NAME="eks-$CLUSTER_NAME"
load_tfstate:
title: Load Terraform statefile from Codefresh context
image: codefresh/cli:0.8.54
commands:
- apk add --update make bash
- make codefresh-load-tfstate
teardown_eks_cluster:
title: Teardown EKS cluster using Terraform
image: hashicorp/terraform:0.11.7
commands:
- apk add --update make bash
- set +e; make teardown; cf_export RC=$?
save_remove_tfstate:
title: Save/Remove Terraform statefile to/from Codefresh context
image: codefresh/cli:0.8.54
commands:
- apk add --update make bash
- bash -c '[[ "${{RC}}" != "0" ]] && make codefresh-save-tfstate || make codefresh-remove-tfstate'
- exit ${{RC}}
remove_cluster:
title: Remove EKS cluster from Codefresh account
image: byrnedo/alpine-curl:0.1.5
commands:
- apk add --update make bash jq
- make codefresh-remove-cluster