-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yaml
79 lines (69 loc) · 2.75 KB
/
Taskfile.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
version: '3'
env:
TAG: "Azure Private Link for Developers Demo"
DEFAULT_REGION: canadacentral
vars:
VARFILE: "azure.tfvars"
tasks:
default:
cmds:
- task --list
up:
desc: Creates a complete {{.TAG}} environment
cmds:
- task: init
- task: apply
- task: creds
init:
desc: Initializes Terraform
cmds:
- terraform -chdir=./infrastructure workspace new {{.REGION}} || true
- terraform -chdir=./infrastructure workspace select {{.REGION}}
- terraform -chdir=./infrastructure init
vars:
REGION: '{{default .DEFAULT_REGION .CLI_ARGS}}'
apply:
desc: Applies the Terraform templates
cmds:
- terraform -chdir=./infrastructure apply -auto-approve -var "region={{.REGION}}" -var "tags={{.TAG}}" -var-file="{{.VARFILE}}"
vars:
REGION: '{{default .DEFAULT_REGION .CLI_ARGS}}'
creds:
desc: Grab AKS credentials
cmds:
- az aks get-credentials --subscription {{.APP_SUBSCRIPTION_ID}} -g {{.RG}} -n {{.AKS}} --overwrite-existing
- kubelogin convert-kubeconfig -l azurecli
vars:
APP_SUBSCRIPTION_ID:
sh: terraform -chdir=./infrastructure output -raw APP_SUBSCRIPTION_ID
RG:
sh: terraform -chdir=./infrastructure output -raw AKS_RESOURCE_GROUP
AKS:
sh: terraform -chdir=./infrastructure output -raw AKS_NAME
refresh:
desc: Refresh the Terraform values
cmds:
- terraform -chdir=./infrastructure refresh -var "region={{.REGION}}" -var "tags={{.TAG}}" -var-file="{{.VARFILE}}"
vars:
REGION: '{{default .DEFAULT_REGION .CLI_ARGS}}'
run:
desc: Run commands on AKS cluster
cmds:
- az aks command invoke --subscription {{.APP_SUBSCRIPTION_ID}} -g {{.RG}} -n {{.AKS}} --command {{.CMD}}
vars:
APP_SUBSCRIPTION_ID:
sh: terraform -chdir=./infrastructure output -raw APP_SUBSCRIPTION_ID
RG:
sh: terraform -chdir=./infrastructure output -raw AKS_RESOURCE_GROUP
AKS:
sh: terraform -chdir=./infrastructure output -raw AKS_NAME
CMD: '{{default .CLI_ARGS}}'
down:
desc: Destroys all Azure resources and cleans up Terraform
cmds:
- az group list --subscription {{.APP_SUBSCRIPTION_ID}} --tag Application="{{.TAG}}" --query "[].name" -o tsv | xargs -ot -n 1 az group delete --subscription {{.APP_SUBSCRIPTION_ID}} -y --verbose --no-wait -n || true
- az group list --tag Application="{{.TAG}}" --query "[].name" -o tsv | xargs -ot -n 1 az group delete -y --verbose --no-wait -n || true
- cd ./infrastructure; rm -rf terraform.tfstate.d .terraform.lock.hcl .terraform terraform.tfstate terraform.tfstate.backup .terraform.tfstate.lock.info || true
vars:
APP_SUBSCRIPTION_ID:
sh: terraform -chdir=./infrastructure output -raw APP_SUBSCRIPTION_ID