1+ // Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+ // Licensed under the Mozilla Public License v2.0
3+
4+ variable "tenancy_ocid" {
5+ }
6+
7+ variable "user_ocid" {
8+ }
9+
10+ variable "compartment_ocid" {
11+ }
12+
13+ variable "region" {
14+ default = " us-ashburn-1"
15+ }
16+
17+ variable "kms_vault_id" {
18+ }
19+
20+ variable "compartment_id" {
21+ }
22+
23+ variable "cluster_cluster_pod_network_options_cni_type" {
24+ default = " OCI_VCN_IP_NATIVE"
25+ }
26+
27+ variable "cluster_defined_tags_value" {
28+ default = " value"
29+ }
30+
31+ variable "cluster_endpoint_config_is_public_ip_enabled" {
32+ default = false
33+ }
34+
35+ variable "cluster_endpoint_config_nsg_ids" {
36+ default = []
37+ }
38+
39+ variable "cluster_freeform_tags" {
40+ default = { " Department" = " Finance" }
41+ }
42+
43+ variable "cluster_image_policy_config_is_policy_enabled" {
44+ default = false
45+ }
46+
47+ variable "cluster_kubernetes_version" {
48+ default = " kubernetesVersion"
49+ }
50+
51+ variable "cluster_name" {
52+ default = " name"
53+ }
54+
55+ variable "cluster_options_add_ons_is_kubernetes_dashboard_enabled" {
56+ default = true
57+ }
58+
59+ variable "cluster_options_add_ons_is_tiller_enabled" {
60+ default = true
61+ }
62+
63+ variable "cluster_options_admission_controller_options_is_pod_security_policy_enabled" {
64+ default = false
65+ }
66+
67+ variable "cluster_options_kubernetes_network_config_pods_cidr" {
68+ default = " 10.1.0.0/16"
69+ }
70+
71+ variable "cluster_options_kubernetes_network_config_services_cidr" {
72+ default = " 10.2.0.0/16"
73+ }
74+
75+ variable "cluster_options_open_id_connect_token_authentication_config_client_id" {
76+ default = " client_id"
77+ }
78+
79+ variable "cluster_options_open_id_connect_token_authentication_config_is_open_id_connect_auth_enabled" {
80+ default = true
81+ }
82+
83+ variable "cluster_options_open_id_connect_token_authentication_config_ca_certificate" {
84+ }
85+
86+ variable "cluster_options_open_id_connect_token_authentication_config_groups_claim" {
87+ default = " groupsClaim"
88+ }
89+
90+ variable "cluster_options_open_id_connect_token_authentication_config_groups_prefix" {
91+ default = " groupsPrefix"
92+ }
93+
94+ variable "cluster_options_open_id_connect_token_authentication_config_issuer_url" {
95+ default = " https://url1.com"
96+ }
97+
98+ variable "cluster_options_open_id_connect_token_authentication_config_required_claims_key" {
99+ default = " key"
100+ }
101+
102+ variable "cluster_options_open_id_connect_token_authentication_config_required_claims_value" {
103+ default = " value"
104+ }
105+
106+ variable "cluster_options_open_id_connect_token_authentication_config_signing_algorithms" {
107+ default = [" RS256" ]
108+ }
109+
110+ variable "cluster_options_open_id_connect_token_authentication_config_username_claim" {
111+ default = " sub"
112+ }
113+
114+ variable "cluster_options_open_id_connect_token_authentication_config_username_prefix" {
115+ default = " oidc:"
116+ }
117+
118+ variable "cluster_options_persistent_volume_config_defined_tags_value" {
119+ default = " value"
120+ }
121+
122+ variable "cluster_options_persistent_volume_config_freeform_tags" {
123+ default = { " Department" = " Finance" }
124+ }
125+
126+ variable "cluster_options_service_lb_config_defined_tags_value" {
127+ default = " value"
128+ }
129+
130+ variable "cluster_options_service_lb_config_freeform_tags" {
131+ default = { " Department" = " Finance" }
132+ }
133+
134+ variable "cluster_options_service_lb_subnet_ids" {
135+ default = []
136+ }
137+
138+ variable "cluster_state" {
139+ default = []
140+ }
141+
142+ variable "cluster_type" {
143+ default = " ENHANCED_CLUSTER"
144+ }
145+
146+
147+
148+ provider "oci" {
149+ region = var. region
150+ auth = " SecurityToken"
151+ config_file_profile = " terraform-federation-test"
152+ }
153+
154+ variable defined_tag_namespace_name {
155+ default = " test"
156+ }
157+
158+ resource "oci_core_vcn" "test_vcn" {
159+ cidr_block = " 10.0.0.0/16"
160+ compartment_id = var. compartment_ocid
161+ display_name = " tfVcnForClusters"
162+ }
163+
164+ resource "oci_core_internet_gateway" "test_ig" {
165+ compartment_id = var. compartment_ocid
166+ display_name = " tfClusterInternetGateway"
167+ vcn_id = oci_core_vcn. test_vcn . id
168+ }
169+
170+ resource "oci_identity_tag_namespace" "tag-namespace1" {
171+ # Required
172+ compartment_id = var. tenancy_ocid
173+ description = " example tag namespace"
174+ name = var. defined_tag_namespace_name != " " ? var. defined_tag_namespace_name : " example-tag-namespace-all"
175+
176+ is_retired = false
177+ }
178+
179+ resource "oci_core_route_table" "test_route_table" {
180+ compartment_id = var. compartment_ocid
181+ vcn_id = oci_core_vcn. test_vcn . id
182+ display_name = " tfClustersRouteTable"
183+
184+ route_rules {
185+ destination = " 0.0.0.0/0"
186+ destination_type = " CIDR_BLOCK"
187+ network_entity_id = oci_core_internet_gateway. test_ig . id
188+ }
189+ }
190+
191+ data "oci_identity_availability_domains" "test_availability_domains" {
192+ compartment_id = var. tenancy_ocid
193+ }
194+
195+ data "oci_identity_availability_domain" "ad1" {
196+ compartment_id = var. tenancy_ocid
197+ ad_number = 1
198+ }
199+
200+ data "oci_identity_availability_domain" "ad2" {
201+ compartment_id = var. tenancy_ocid
202+ ad_number = 2
203+ }
204+
205+ resource "oci_core_subnet" "clusterSubnet_2" {
206+ # Required
207+ availability_domain = data. oci_identity_availability_domain . ad2 . name
208+ cidr_block = " 10.0.21.0/24"
209+ compartment_id = var. compartment_ocid
210+ vcn_id = oci_core_vcn. test_vcn . id
211+ display_name = " tfSubNet1ForClusters"
212+
213+ # Provider code tries to maintain compatibility with old versions.
214+ security_list_ids = [oci_core_vcn . test_vcn . default_security_list_id ]
215+ route_table_id = oci_core_route_table. test_route_table . id
216+ }
217+
218+ resource "oci_containerengine_cluster" "test_cluster" {
219+ # Required
220+ compartment_id = var. compartment_ocid
221+ kubernetes_version = " v1.28.2"
222+ name = " tfTestCluster"
223+ vcn_id = oci_core_vcn. test_vcn . id
224+
225+ # Optional
226+ # defined_tags = map(oci_identity_tag_namespace.tag-namespace1.name.oci_identity_tag.tag1.name, var.cluster_defined_tags_value)
227+
228+ freeform_tags = var. cluster_freeform_tags
229+ options {
230+
231+ # Optional
232+ add_ons {
233+
234+ # Optional
235+ is_kubernetes_dashboard_enabled = var. cluster_options_add_ons_is_kubernetes_dashboard_enabled
236+ is_tiller_enabled = var. cluster_options_add_ons_is_tiller_enabled
237+ }
238+ admission_controller_options {
239+
240+ # Optional
241+ is_pod_security_policy_enabled = var. cluster_options_admission_controller_options_is_pod_security_policy_enabled
242+ }
243+ kubernetes_network_config {
244+
245+ # Optional
246+ pods_cidr = var. cluster_options_kubernetes_network_config_pods_cidr
247+ services_cidr = var. cluster_options_kubernetes_network_config_services_cidr
248+ }
249+ open_id_connect_token_authentication_config {
250+ # Required
251+ is_open_id_connect_auth_enabled = var. cluster_options_open_id_connect_token_authentication_config_is_open_id_connect_auth_enabled
252+
253+ # Optional
254+ client_id = var. cluster_options_open_id_connect_token_authentication_config_client_id
255+ issuer_url = var. cluster_options_open_id_connect_token_authentication_config_issuer_url
256+ ca_certificate = var. cluster_options_open_id_connect_token_authentication_config_ca_certificate
257+ groups_claim = var. cluster_options_open_id_connect_token_authentication_config_groups_claim
258+ groups_prefix = var. cluster_options_open_id_connect_token_authentication_config_groups_prefix
259+ required_claims {
260+
261+ # Optional
262+ key = var. cluster_options_open_id_connect_token_authentication_config_required_claims_key
263+ value = var. cluster_options_open_id_connect_token_authentication_config_required_claims_value
264+ }
265+ signing_algorithms = var. cluster_options_open_id_connect_token_authentication_config_signing_algorithms
266+ username_claim = var. cluster_options_open_id_connect_token_authentication_config_username_claim
267+ username_prefix = var. cluster_options_open_id_connect_token_authentication_config_username_prefix
268+ }
269+ }
270+ type = var. cluster_type
271+ }
272+
273+ data "oci_containerengine_clusters" "test_clusters" {
274+ # Required
275+ compartment_id = var. compartment_id
276+
277+ # Optional
278+ name = var. cluster_name
279+ state = var. cluster_state
280+ }
0 commit comments