-
Notifications
You must be signed in to change notification settings - Fork 1
/
providers.tf
91 lines (81 loc) · 3.38 KB
/
providers.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
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
# Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
locals {
cluster_endpoint = yamldecode(data.oci_containerengine_cluster_kube_config.oke.content)["clusters"][0]["cluster"]["server"]
cluster_ca_certificate = base64decode(yamldecode(data.oci_containerengine_cluster_kube_config.oke.content)["clusters"][0]["cluster"]["certificate-authority-data"])
cluster_id = yamldecode(data.oci_containerengine_cluster_kube_config.oke.content)["users"][0]["user"]["exec"]["args"][4]
cluster_region = yamldecode(data.oci_containerengine_cluster_kube_config.oke.content)["users"][0]["user"]["exec"]["args"][6]
}
terraform {
required_version = ">= 1.2"
required_providers {
oci = {
source = "oracle/oci"
version = ">= 4.85.0"
# https://registry.terraform.io/providers/hashicorp/oci/4.85.0
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.18.1"
# https://registry.terraform.io/providers/hashicorp/kubernetes/2.13.0
}
helm = {
source = "hashicorp/helm"
version = "2.9.0"
# https://registry.terraform.io/providers/hashicorp/helm/2.9.0
}
tls = {
source = "hashicorp/tls"
version = "3.1.0" # Latest version as January 2022 = 3.1.0.
# https://registry.terraform.io/providers/hashicorp/tls/3.1.0
}
local = {
source = "hashicorp/local"
version = "2.1.0" # Latest version as January 2022 = 2.1.0.
# https://registry.terraform.io/providers/hashicorp/local/2.1.0
}
random = {
source = "hashicorp/random"
version = "3.1.0" # Latest version as January 2022 = 3.1.0.
# https://registry.terraform.io/providers/hashicorp/random/3.1.0
}
}
}
provider "oci" {
tenancy_ocid = var.tenancy_ocid
region = var.region
}
provider "oci" {
alias = "home_region"
tenancy_ocid = var.tenancy_ocid
region = lookup(data.oci_identity_regions.home_region.regions[0], "name")
}
provider "oci" {
alias = "current_region"
tenancy_ocid = var.tenancy_ocid
region = var.region
}
# New configuration to avoid Terraform Kubernetes provider interpolation. https://registry.terraform.io/providers/hashicorp/kubernetes/2.2.0/docs#stacking-with-managed-kubernetes-cluster-resources
# Currently need to uncheck to refresh (--refresh=false) when destroying or else the terraform destroy will fail
# # https://docs.cloud.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengdownloadkubeconfigfile.htm#notes
provider "kubernetes" {
host = local.cluster_endpoint
cluster_ca_certificate = local.cluster_ca_certificate
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["ce", "cluster", "generate-token", "--cluster-id", local.cluster_id, "--region", local.cluster_region]
command = "oci"
}
}
# https://docs.cloud.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengdownloadkubeconfigfile.htm#notes
provider "helm" {
kubernetes {
host = local.cluster_endpoint
cluster_ca_certificate = local.cluster_ca_certificate
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["ce", "cluster", "generate-token", "--cluster-id", local.cluster_id, "--region", local.cluster_region]
command = "oci"
}
}
}