From 170fe8de58e1dec3cd5ffbae8c6f1d395f7a32ea Mon Sep 17 00:00:00 2001 From: David van der Spek Date: Tue, 7 Mar 2023 16:19:30 +0100 Subject: [PATCH] update azure tf provider template Signed-off-by: David van der Spek --- .../terraform/providers/0.1.3/azure.eex | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 apps/core/priv/scaffolds/terraform/providers/0.1.3/azure.eex diff --git a/apps/core/priv/scaffolds/terraform/providers/0.1.3/azure.eex b/apps/core/priv/scaffolds/terraform/providers/0.1.3/azure.eex new file mode 100644 index 000000000..f2fbff1c5 --- /dev/null +++ b/apps/core/priv/scaffolds/terraform/providers/0.1.3/azure.eex @@ -0,0 +1,44 @@ +terraform { + backend "azurerm" { + storage_account_name = {{ .Values.Context.StorageAccount | quote }} + resource_group_name = {{ .Values.ResourceGroup | quote }} + container_name = {{ .Values.Bucket | quote }} + key = "{{ .Values.__CLUSTER__ }}/{{ .Values.Prefix }}/terraform.tfstate" + } + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "~> 3.46.0" + } + kubernetes = { + source = "hashicorp/kubernetes" + version = "~> 2.18.1" + } + } +} + +provider "azurerm" { + features {} +} + +{{ if .Values.ClusterCreated }} +provider "kubernetes" { + host = {{ .Values.Cluster }}.host + client_certificate = base64decode({{ .Values.Cluster }}.client_certificate) + client_key = base64decode({{ .Values.Cluster }}.client_key) + cluster_ca_certificate = base64decode({{ .Values.Cluster }}.cluster_ca_certificate) +} +{{ else }} +data "azurerm_kubernetes_cluster" "cluster" { + name = {{ .Values.Cluster }} + resource_group_name = {{ .Values.ResourceGroup | quote }} +} + +provider "kubernetes" { + host = data.azurerm_kubernetes_cluster.cluster.kube_config[0].host + client_certificate = base64decode(data.azurerm_kubernetes_cluster.cluster.kube_config[0].client_certificate) + client_key = base64decode(data.azurerm_kubernetes_cluster.cluster.kube_config[0].client_key) + cluster_ca_certificate = base64decode(data.azurerm_kubernetes_cluster.cluster.kube_config[0].cluster_ca_certificate) +} +{{ end }}