-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlocal_provisioner.tf
31 lines (26 loc) · 1009 Bytes
/
local_provisioner.tf
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
# Local Provisioner - Runs on your local Macbook Pro/Linux instance to
# 1. Configure the local ~/.kube/config file for accessing the AKS cluster
resource "local_file" "eks-kubeconfig" {
content = module.eks.kubeconfig
filename = "${path.module}/eks-kubeconfig"
depends_on = [module.eks.kubeconfig]
}
resource "null_resource" "local_mac_provisioner" {
provisioner "local-exec" {
command = <<EOT
echo ""
echo "################################################################################"
echo "# Running local provisioner to set KUBECONFIG"
echo "################################################################################"
echo ""
aws eks --region $(terraform output -raw region) update-kubeconfig --name $(terraform output -raw cluster_name)
EOT
}
provisioner "local-exec" {
when = destroy
command = <<EOT
rm ./eks-kubeconfig
EOT
}
depends_on = [module.eks.cluster, local_file.eks-kubeconfig]
}