3636 addonConfigValue = "1"
3737 addonConfigValueUpdate = "2"
3838
39+ essentialAddonName = "CoreDNS"
40+ essentialAddonConfigKey = "minReplica"
41+ essentialAddonConfigValue = "4"
42+
3943 ContainerengineAddonSingularDataSourceRepresentation = map [string ]interface {}{
4044 "addon_name" : acctest.Representation {RepType : acctest .Required , Create : `${oci_containerengine_addon.test_addon.addon_name}` },
4145 "cluster_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_containerengine_cluster.test_cluster.id}` },
@@ -57,71 +61,31 @@ var (
5761 "version" : acctest.Representation {RepType : acctest .Optional , Create : nil , Update : `${data.oci_containerengine_addon_options.adddon_options_dashboard.addon_options[0].versions[0].version_number}` },
5862 }
5963
64+ ContainerengineEssentialAddonRepresentation = map [string ]interface {}{
65+ "cluster_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_containerengine_cluster.test_cluster.id}` },
66+ "addon_name" : acctest.Representation {RepType : acctest .Required , Create : essentialAddonName },
67+ "remove_addon_resources_on_delete" : acctest.Representation {RepType : acctest .Required , Create : `false` },
68+ "override_existing" : acctest.Representation {RepType : acctest .Optional , Create : `true` },
69+ "configurations" : acctest.RepresentationGroup {RepType : acctest .Optional , Group : ContainerengineEssentialAddonConfigurationsRepresentation },
70+ }
71+
6072 ContainerengineAddonConfigurationsRepresentation = map [string ]interface {}{
6173 "key" : acctest.Representation {RepType : acctest .Optional , Create : addonConfigKey , Update : addonConfigKey },
6274 "value" : acctest.Representation {RepType : acctest .Optional , Create : addonConfigValue , Update : addonConfigValueUpdate },
6375 }
6476
77+ ContainerengineEssentialAddonConfigurationsRepresentation = map [string ]interface {}{
78+ "key" : acctest.Representation {RepType : acctest .Optional , Create : essentialAddonConfigKey },
79+ "value" : acctest.Representation {RepType : acctest .Optional , Create : essentialAddonConfigValue },
80+ }
81+
6582 ContainerengineAddonRequiredOnlyResourceCreate = acctest .GenerateResourceFromRepresentationMap ("oci_containerengine_addon" , "test_addon" , acctest .Required , acctest .Create , ContainerengineAddonRepresentation )
6683
6784 ContainerengineAddonOptionalResourceCreate = acctest .GenerateResourceFromRepresentationMap ("oci_containerengine_addon" , "test_addon" , acctest .Optional , acctest .Create , ContainerengineAddonRepresentation )
6885
6986 ContainerengineAddonOptionalResourceConfigUpdate = acctest .GenerateResourceFromRepresentationMap ("oci_containerengine_addon" , "test_addon" , acctest .Optional , acctest .Update , ContainerengineAddonRepresentation )
7087
71- clusterOptionAddonDataSourceRepresentation = map [string ]interface {}{
72- "cluster_option_id" : acctest.Representation {RepType : acctest .Required , Create : `all` },
73- "compartment_id" : acctest.Representation {RepType : acctest .Optional , Create : `${var.compartment_id}` },
74- }
75-
76- clusterAddonVcnRepresentation = map [string ]interface {}{
77- "cidr_block" : acctest.Representation {RepType : acctest .Required , Create : `10.0.0.0/16` },
78- "compartment_id" : acctest.Representation {RepType : acctest .Required , Create : `${var.compartment_id}` },
79- "defined_tags" : acctest.Representation {RepType : acctest .Optional , Create : `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}` , Update : `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}` },
80- "display_name" : acctest.Representation {RepType : acctest .Optional , Create : `displayName` , Update : `displayName2` },
81- "dns_label" : acctest.Representation {RepType : acctest .Optional , Create : `dnslabel` },
82- "freeform_tags" : acctest.Representation {RepType : acctest .Optional , Create : map [string ]string {"Department" : "Finance" }, Update : map [string ]string {"Department" : "Accounting" }},
83- "lifecycle" : acctest.RepresentationGroup {RepType : acctest .Required , Group : ignoreDefinedTagsChangesRep },
84- }
85-
86- clusterAddonSubnetRepresentation = map [string ]interface {}{
87- "cidr_block" : acctest.Representation {RepType : acctest .Required , Create : `10.0.0.0/24` , Update : "10.0.0.0/16" },
88- "compartment_id" : acctest.Representation {RepType : acctest .Required , Create : `${var.compartment_id}` },
89- "vcn_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_core_vcn.test_vcn.id}` },
90- "availability_domain" : acctest.Representation {RepType : acctest .Optional , Create : `${lower("${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}")}` },
91- "defined_tags" : acctest.Representation {RepType : acctest .Optional , Create : `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}` , Update : `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}` },
92- "dhcp_options_id" : acctest.Representation {RepType : acctest .Optional , Create : `${oci_core_vcn.test_vcn.default_dhcp_options_id}` , Update : `${oci_core_dhcp_options.test_dhcp_options.id}` },
93- "display_name" : acctest.Representation {RepType : acctest .Optional , Create : `MySubnet` , Update : `displayName2` },
94- "dns_label" : acctest.Representation {RepType : acctest .Optional , Create : `dnslabel` },
95- "freeform_tags" : acctest.Representation {RepType : acctest .Optional , Create : map [string ]string {"Department" : "Finance" }, Update : map [string ]string {"Department" : "Accounting" }},
96- "prohibit_public_ip_on_vnic" : acctest.Representation {RepType : acctest .Optional , Create : `false` },
97- "prohibit_internet_ingress" : acctest.Representation {RepType : acctest .Optional , Create : `false` },
98- "route_table_id" : acctest.Representation {RepType : acctest .Optional , Create : `${oci_core_vcn.test_vcn.default_route_table_id}` , Update : `${oci_core_route_table.test_route_table.id}` },
99- "security_list_ids" : acctest.Representation {RepType : acctest .Optional , Create : []string {`${oci_core_vcn.test_vcn.default_security_list_id}` }, Update : []string {`${oci_core_security_list.test_security_list.id}` }},
100- "lifecycle" : acctest.RepresentationGroup {RepType : acctest .Required , Group : ignoreDefinedTagsChangesRep },
101- }
102-
103- containerengineClusterRepresentation = map [string ]interface {}{
104- "compartment_id" : acctest.Representation {RepType : acctest .Required , Create : `${var.compartment_id}` },
105- "kubernetes_version" : acctest.Representation {RepType : acctest .Required , Create : `${data.oci_containerengine_cluster_option.test_cluster_option.kubernetes_versions[length(data.oci_containerengine_cluster_option.test_cluster_option.kubernetes_versions)-2]}` , Update : `${data.oci_containerengine_cluster_option.test_cluster_option.kubernetes_versions[length(data.oci_containerengine_cluster_option.test_cluster_option.kubernetes_versions)-1]}` },
106- "name" : acctest.Representation {RepType : acctest .Required , Create : `name` , Update : `name2` },
107- "vcn_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_core_vcn.test_vcn.id}` },
108- "defined_tags" : acctest.Representation {RepType : acctest .Optional , Create : `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}` , Update : `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}` },
109- "endpoint_config" : acctest.RepresentationGroup {RepType : acctest .Optional , Group : clusterAddonEndpointConfigRepresentation },
110- "freeform_tags" : acctest.Representation {RepType : acctest .Optional , Create : map [string ]string {"Department" : "Finance" }, Update : map [string ]string {"Department" : "Accounting" }},
111- "image_policy_config" : acctest.RepresentationGroup {RepType : acctest .Optional , Group : clusterAddonImagePolicyConfigRepresentation },
112- "kms_key_id" : acctest.Representation {RepType : acctest .Optional , Create : `${lookup(data.oci_kms_keys.test_keys_dependency.keys[0], "id")}` },
113- "options" : acctest.RepresentationGroup {RepType : acctest .Optional , Group : ContainerengineClusterOptionsRepresentation },
114- }
115-
116- clusterAddonEndpointConfigRepresentation = map [string ]interface {}{
117- "nsg_ids" : acctest.Representation {RepType : acctest .Optional , Create : []string {`${oci_core_network_security_group.test_network_security_group.id}` }, Update : []string {}},
118- "subnet_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_core_subnet.test_subnet.id}` },
119- }
120-
121- clusterAddonImagePolicyConfigRepresentation = map [string ]interface {}{
122- "is_policy_enabled" : acctest.Representation {RepType : acctest .Optional , Create : `false` , Update : `true` },
123- "key_details" : acctest.RepresentationGroup {RepType : acctest .Optional , Group : ContainerengineClusterImagePolicyConfigKeyDetailsRepresentation },
124- }
88+ ContainerengineEssentialAddonResourceCreate = acctest .GenerateResourceFromRepresentationMap ("oci_containerengine_addon" , "test_essential_addon" , acctest .Optional , acctest .Create , ContainerengineEssentialAddonRepresentation )
12589
12690 AddonOptionDashboardDataSourceRepresentation = map [string ]interface {}{
12791 "kubernetes_version" : acctest.Representation {RepType : acctest .Required , Create : `${data.oci_containerengine_cluster_option.test_cluster_option.kubernetes_versions[length(data.oci_containerengine_cluster_option.test_cluster_option.kubernetes_versions)-2]}` },
@@ -130,9 +94,13 @@ var (
13094
13195 ContainerengineAddonResourceDependencies = acctest .GenerateResourceFromRepresentationMap ("oci_containerengine_cluster" , "test_cluster" , acctest .Required , acctest .Create ,
13296 acctest .RepresentationCopyWithNewProperties (ContainerengineClusterRepresentation , map [string ]interface {}{
133- "type" : acctest.Representation {RepType : acctest .Required , Create : `ENHANCED_CLUSTER` , Update : `ENHANCED_CLUSTER` },
97+ "type" : acctest.Representation {RepType : acctest .Required , Create : `ENHANCED_CLUSTER` , Update : `ENHANCED_CLUSTER` },
98+ "cluster_pod_network_options" : acctest.RepresentationGroup {RepType : acctest .Required , Group : clusterClusterPodNetworkOptionsRepresentation },
99+ "endpoint_config" : acctest.RepresentationGroup {RepType : acctest .Required , Group : ContainerengineClusterEndpointConfigRepresentation },
134100 })) +
135101 acctest .GenerateDataSourceFromRepresentationMap ("oci_containerengine_cluster_option" , "test_cluster_option" , acctest .Required , acctest .Create , ContainerengineContainerengineClusterOptionSingularDataSourceRepresentation ) +
102+ acctest .GenerateResourceFromRepresentationMap ("oci_core_network_security_group" , "test_network_security_group" , acctest .Required , acctest .Create , CoreNetworkSecurityGroupRepresentation ) +
103+ acctest .GenerateResourceFromRepresentationMap ("oci_core_subnet" , "test_subnet" , acctest .Required , acctest .Create , CoreSubnetRepresentation ) +
136104 acctest .GenerateResourceFromRepresentationMap ("oci_core_vcn" , "test_vcn" , acctest .Required , acctest .Create , acctest .RepresentationCopyWithNewProperties (CoreVcnRepresentation , map [string ]interface {}{
137105 "dns_label" : acctest.Representation {RepType : acctest .Required , Create : `dnslabel` },
138106 })) +
@@ -145,12 +113,15 @@ func TestContainerengineAddonResource_basic(t *testing.T) {
145113 httpreplay .SetScenario ("TestContainerengineAddonResource_basic" )
146114 defer httpreplay .SaveScenario ()
147115
116+ fmt .Printf ("ContainerengineEssentialAddonResourceCreate: %v" , ContainerengineEssentialAddonResourceCreate )
117+
148118 config := acctest .ProviderTestConfig ()
149119
150120 compartmentId := utils .GetEnvSettingWithBlankDefault ("compartment_ocid" )
151121 compartmentIdVariableStr := fmt .Sprintf ("variable \" compartment_id\" { default = \" %s\" }\n " , compartmentId )
152122
153123 resourceName := "oci_containerengine_addon.test_addon"
124+ essentialAddonResourceName := "oci_containerengine_addon.test_essential_addon"
154125 datasourceName := "data.oci_containerengine_addons.test_addons"
155126 singularDatasourceName := "data.oci_containerengine_addon.test_addon"
156127
@@ -230,6 +201,20 @@ func TestContainerengineAddonResource_basic(t *testing.T) {
230201 },
231202 ),
232203 },
204+ // verify update-on-install of an essential addon
205+ {
206+ Config : baseConfig + ContainerengineAddonOptionalResourceConfigUpdate + ContainerengineEssentialAddonResourceCreate ,
207+
208+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
209+ resource .TestCheckResourceAttrSet (essentialAddonResourceName , "cluster_id" ),
210+ resource .TestCheckResourceAttr (essentialAddonResourceName , "configurations.#" , "1" ),
211+ resource .TestCheckResourceAttr (essentialAddonResourceName , "configurations.0.key" , essentialAddonConfigKey ),
212+ resource .TestCheckResourceAttr (essentialAddonResourceName , "configurations.0.value" , essentialAddonConfigValue ),
213+ resource .TestCheckResourceAttrSet (essentialAddonResourceName , "current_installed_version" ),
214+ resource .TestCheckResourceAttr (essentialAddonResourceName , "addon_name" , essentialAddonName ),
215+ resource .TestCheckResourceAttrSet (essentialAddonResourceName , "state" ),
216+ ),
217+ },
233218 // verify datasource
234219 {
235220 Config : baseConfig + ContainerengineAddonDataSource + ContainerengineAddonOptionalResourceConfigUpdate ,
@@ -246,7 +231,6 @@ func TestContainerengineAddonResource_basic(t *testing.T) {
246231 Config : baseConfig + ContainerengineAddonSingularDataSource + ContainerengineAddonOptionalResourceConfigUpdate ,
247232
248233 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
249- resource .TestCheckNoResourceAttr (singularDatasourceName , "addon_error" ),
250234 resource .TestCheckResourceAttrSet (singularDatasourceName , "time_created" ),
251235 resource .TestCheckResourceAttr (singularDatasourceName , "configurations.#" , "1" ),
252236 resource .TestCheckResourceAttr (singularDatasourceName , "configurations.0.key" , addonConfigKey ),
@@ -262,7 +246,7 @@ func TestContainerengineAddonResource_basic(t *testing.T) {
262246 Config : baseConfig + ContainerengineAddonRequiredOnlyResourceCreate ,
263247 ImportState : true ,
264248 ImportStateVerify : true ,
265- ImportStateVerifyIgnore : []string {"remove_addon_resources_on_delete" },
249+ ImportStateVerifyIgnore : []string {"remove_addon_resources_on_delete" , "override_existing" },
266250 ResourceName : resourceName ,
267251 },
268252 })
@@ -272,7 +256,7 @@ func testAccCheckContainerengineAddonDestroy(s *terraform.State) error {
272256 noResourceFound := true
273257 client := acctest .TestAccProvider .Meta ().(* tf_client.OracleClients ).ContainerEngineClient ()
274258 for _ , rs := range s .RootModule ().Resources {
275- if rs .Type == "oci_containerengine_addon" {
259+ if rs .Type == "oci_containerengine_addon" && rs . Primary . Attributes [ "addon_name" ] != essentialAddonName {
276260 noResourceFound = false
277261 request := oci_containerengine.GetAddonRequest {}
278262
0 commit comments