Skip to content

Commit 4474d29

Browse files
jiangongjotruon
authored andcommitted
Add fault domains in instance pool
1 parent 00074a1 commit 4474d29

12 files changed

+62
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Added
44
- Support for creating `oci_database_autonomous_database` resource with the specified `whitelisted_ips`
55
- Support for `customer_asn` attribute in `core_virtual_circuit` resource
6+
- Support for Instance Pool with Fault Domain
67

78
### Deprecated
89
- Virtual Circuit resource: The `customer_bgp_asn` attribute is now deprecated. Please use the `customer_asn` instead.

examples/compute/instance_pool/instance_pool.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ resource "oci_core_instance_pool" "test_instance_pool" {
169169

170170
placement_configurations {
171171
availability_domain = "${data.oci_identity_availability_domain.ad.name}"
172+
fault_domains = ["FAULT-DOMAIN-1"]
172173
primary_subnet_id = "${oci_core_subnet.test_subnet.id}"
173174
}
174175

oci/core_cluster_network_resource.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ func CoreClusterNetworkResource() *schema.Resource {
134134
Type: schema.TypeString,
135135
Computed: true,
136136
},
137+
"fault_domains": {
138+
Type: schema.TypeList,
139+
Computed: true,
140+
Elem: &schema.Schema{
141+
Type: schema.TypeString,
142+
},
143+
},
137144
"primary_subnet_id": {
138145
Type: schema.TypeString,
139146
Computed: true,

oci/core_cluster_network_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ var (
8282

8383
instanceConfigurationInstanceDetailsLaunchDetailsClusterNetworkRepresentation = getUpdatedRepresentationCopy("shape", Representation{repType: Optional, create: `BM.HPC2.36`}, instanceConfigurationInstanceDetailsLaunchDetailsRepresentation)
8484

85-
ClusterNetworkResourceRequiredOnlyDependencies = AvailabilityDomainClusterNetworkConfig + DhcpOptionsRequiredOnlyResource + RouteTableRequiredOnlyResource + AnotherSecurityListRequiredOnlyResource +
85+
ClusterNetworkResourceRequiredOnlyDependencies = AvailabilityDomainClusterNetworkConfig + DefinedTagsDependencies + VcnResourceConfig + DhcpOptionsRequiredOnlyResource + AnotherSecurityListRequiredOnlyResource +
86+
generateResourceFromRepresentationMap("oci_core_route_table", "test_route_table", Required, Create, routeTableRepresentation) +
8687
generateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", Optional, Update, getUpdatedRepresentationCopy("cidr_block", Representation{repType: Required, create: `10.0.2.0/24`}, subnetRepresentation)) +
8788
OciImageIdsVariable +
88-
generateResourceFromRepresentationMap("oci_core_network_security_group", "test_network_security_group1", Required, Create, networkSecurityGroupRepresentation)
89+
generateResourceFromRepresentationMap("oci_core_network_security_group", "test_network_security_group", Required, Create, networkSecurityGroupRepresentation)
8990

9091
ClusterNetworkResourceDependencies = ClusterNetworkResourceRequiredOnlyDependencies +
9192
generateResourceFromRepresentationMap("oci_core_instance_configuration", "test_instance_configuration", Optional, Create, getUpdatedRepresentationCopy("instance_details", RepresentationGroup{Optional, instanceConfigurationInstanceDetailsClusterNetworkRepresentation}, instanceConfigurationRepresentation))

oci/core_instance_pool_resource.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ func CoreInstancePoolResource() *schema.Resource {
5656
},
5757

5858
// Optional
59+
"fault_domains": {
60+
Type: schema.TypeList,
61+
Optional: true,
62+
Computed: true,
63+
Elem: &schema.Schema{
64+
Type: schema.TypeString,
65+
DiffSuppressFunc: EqualIgnoreCaseSuppressDiff,
66+
},
67+
},
5968
"secondary_vnic_subnets": {
6069
Type: schema.TypeList,
6170
Optional: true,
@@ -616,6 +625,19 @@ func (s *CoreInstancePoolResourceCrud) mapToCreateInstancePoolPlacementConfigura
616625
result.AvailabilityDomain = &tmp
617626
}
618627

628+
if faultDomains, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "fault_domains")); ok {
629+
interfaces := faultDomains.([]interface{})
630+
tmp := make([]string, len(interfaces))
631+
for i := range interfaces {
632+
if interfaces[i] != nil {
633+
tmp[i] = interfaces[i].(string)
634+
}
635+
}
636+
if len(tmp) != 0 || s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "fault_domains")) {
637+
result.FaultDomains = tmp
638+
}
639+
}
640+
619641
if primarySubnetId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "primary_subnet_id")); ok {
620642
tmp := primarySubnetId.(string)
621643
result.PrimarySubnetId = &tmp
@@ -649,6 +671,19 @@ func (s *CoreInstancePoolResourceCrud) mapToUpdateInstancePoolPlacementConfigura
649671
result.AvailabilityDomain = &tmp
650672
}
651673

674+
if faultDomains, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "fault_domains")); ok {
675+
interfaces := faultDomains.([]interface{})
676+
tmp := make([]string, len(interfaces))
677+
for i := range interfaces {
678+
if interfaces[i] != nil {
679+
tmp[i] = interfaces[i].(string)
680+
}
681+
}
682+
if len(tmp) != 0 || s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "fault_domains")) {
683+
result.FaultDomains = tmp
684+
}
685+
}
686+
652687
if primarySubnetId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "primary_subnet_id")); ok {
653688
tmp := primarySubnetId.(string)
654689
result.PrimarySubnetId = &tmp
@@ -679,6 +714,8 @@ func InstancePoolPlacementConfigurationToMap(obj oci_core.InstancePoolPlacementC
679714
result["availability_domain"] = string(*obj.AvailabilityDomain)
680715
}
681716

717+
result["fault_domains"] = obj.FaultDomains
718+
682719
if obj.PrimarySubnetId != nil {
683720
result["primary_subnet_id"] = string(*obj.PrimarySubnetId)
684721
}

oci/core_instance_pool_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ var (
5353
instancePoolPlacementConfigurationsRepresentation = map[string]interface{}{
5454
"availability_domain": Representation{repType: Required, create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
5555
"primary_subnet_id": Representation{repType: Required, create: `${oci_core_subnet.test_subnet.id}`},
56+
"fault_domains": Representation{repType: Optional, create: []string{`FAULT-DOMAIN-1`}, update: []string{`FAULT-DOMAIN-2`}},
5657
"secondary_vnic_subnets": RepresentationGroup{Optional, instancePoolPlacementConfigurationsSecondaryVnicSubnetsRepresentation},
5758
}
5859
instancePoolLoadBalancersRepresentation = map[string]interface{}{
@@ -193,6 +194,7 @@ func TestCoreInstancePoolResource_basic(t *testing.T) {
193194
resource.TestCheckResourceAttr(resourceName, "load_balancers.0.vnic_selection", "PrimaryVnic"),
194195
resource.TestCheckResourceAttr(resourceName, "placement_configurations.#", "1"),
195196
resource.TestCheckResourceAttrSet(resourceName, "placement_configurations.0.availability_domain"),
197+
resource.TestCheckResourceAttr(resourceName, "placement_configurations.0.fault_domains.#", "1"),
196198
resource.TestCheckResourceAttrSet(resourceName, "placement_configurations.0.primary_subnet_id"),
197199
resource.TestCheckResourceAttr(resourceName, "placement_configurations.0.secondary_vnic_subnets.#", "1"),
198200
resource.TestCheckResourceAttr(resourceName, "placement_configurations.0.secondary_vnic_subnets.0.display_name", "backend-servers-pool"),
@@ -237,6 +239,7 @@ func TestCoreInstancePoolResource_basic(t *testing.T) {
237239
resource.TestCheckResourceAttr(resourceName, "load_balancers.0.vnic_selection", "PrimaryVnic"),
238240
resource.TestCheckResourceAttr(resourceName, "placement_configurations.#", "1"),
239241
resource.TestCheckResourceAttrSet(resourceName, "placement_configurations.0.availability_domain"),
242+
resource.TestCheckResourceAttr(resourceName, "placement_configurations.0.fault_domains.#", "1"),
240243
resource.TestCheckResourceAttrSet(resourceName, "placement_configurations.0.primary_subnet_id"),
241244
resource.TestCheckResourceAttr(resourceName, "size", "2"),
242245
resource.TestCheckResourceAttrSet(resourceName, "state"),
@@ -273,6 +276,7 @@ func TestCoreInstancePoolResource_basic(t *testing.T) {
273276
resource.TestCheckResourceAttr(resourceName, "load_balancers.0.vnic_selection", "PrimaryVnic"),
274277
resource.TestCheckResourceAttr(resourceName, "placement_configurations.#", "1"),
275278
resource.TestCheckResourceAttrSet(resourceName, "placement_configurations.0.availability_domain"),
279+
resource.TestCheckResourceAttr(resourceName, "placement_configurations.0.fault_domains.#", "1"),
276280
resource.TestCheckResourceAttrSet(resourceName, "placement_configurations.0.primary_subnet_id"),
277281
resource.TestCheckResourceAttr(resourceName, "size", "3"),
278282
resource.TestCheckResourceAttr(resourceName, "state", "RUNNING"),
@@ -386,6 +390,7 @@ func TestCoreInstancePoolResource_basic(t *testing.T) {
386390
resource.TestCheckResourceAttr(singularDatasourceName, "load_balancers.0.vnic_selection", "PrimaryVnic"),
387391
resource.TestCheckResourceAttr(singularDatasourceName, "placement_configurations.#", "1"),
388392
resource.TestCheckResourceAttrSet(singularDatasourceName, "placement_configurations.0.availability_domain"),
393+
resource.TestCheckResourceAttr(singularDatasourceName, "placement_configurations.0.fault_domains.#", "1"),
389394
resource.TestCheckResourceAttr(singularDatasourceName, "size", "3"),
390395
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
391396
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"),

website/docs/d/core_cluster_network.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ The following attributes are exported:
5656
* `vnic_selection` - Indicates which VNIC on each instance in the instance pool should be used to associate with the load balancer. Possible values are "PrimaryVnic" or the displayName of one of the secondary VNICs on the instance configuration that is associated with the instance pool.
5757
* `placement_configurations` - The placement configurations for the instance pool.
5858
* `availability_domain` - The availability domain to place instances. Example: `Uocm:PHX-AD-1`
59+
* `fault_domains` - The fault domains to place instances.
5960
* `primary_subnet_id` - The OCID of the primary subnet to place instances.
6061
* `secondary_vnic_subnets` - The set of secondary VNIC data for instances in the pool.
6162
* `display_name` - The displayName of the vnic. This is also use to match against the Instance Configuration defined secondary vnic.

website/docs/d/core_cluster_networks.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The following attributes are exported:
6868
* `vnic_selection` - Indicates which VNIC on each instance in the instance pool should be used to associate with the load balancer. Possible values are "PrimaryVnic" or the displayName of one of the secondary VNICs on the instance configuration that is associated with the instance pool.
6969
* `placement_configurations` - The placement configurations for the instance pool.
7070
* `availability_domain` - The availability domain to place instances. Example: `Uocm:PHX-AD-1`
71+
* `fault_domains` - The fault domains to place instances.
7172
* `primary_subnet_id` - The OCID of the primary subnet to place instances.
7273
* `secondary_vnic_subnets` - The set of secondary VNIC data for instances in the pool.
7374
* `display_name` - The displayName of the vnic. This is also use to match against the Instance Configuration defined secondary vnic.

website/docs/d/core_instance_pool.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The following attributes are exported:
4848
* `vnic_selection` - Indicates which VNIC on each instance in the instance pool should be used to associate with the load balancer. Possible values are "PrimaryVnic" or the displayName of one of the secondary VNICs on the instance configuration that is associated with the instance pool.
4949
* `placement_configurations` - The placement configurations for the instance pool.
5050
* `availability_domain` - The availability domain to place instances. Example: `Uocm:PHX-AD-1`
51+
* `fault_domains` - The fault domains to place instances.
5152
* `primary_subnet_id` - The OCID of the primary subnet to place instances.
5253
* `secondary_vnic_subnets` - The set of secondary VNIC data for instances in the pool.
5354
* `display_name` - The displayName of the vnic. This is also use to match against the Instance Configuration defined secondary vnic.

website/docs/d/core_instance_pools.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ The following attributes are exported:
6060
* `vnic_selection` - Indicates which VNIC on each instance in the instance pool should be used to associate with the load balancer. Possible values are "PrimaryVnic" or the displayName of one of the secondary VNICs on the instance configuration that is associated with the instance pool.
6161
* `placement_configurations` - The placement configurations for the instance pool.
6262
* `availability_domain` - The availability domain to place instances. Example: `Uocm:PHX-AD-1`
63+
* `fault_domains` - The fault domains to place instances.
6364
* `primary_subnet_id` - The OCID of the primary subnet to place instances.
6465
* `secondary_vnic_subnets` - The set of secondary VNIC data for instances in the pool.
6566
* `display_name` - The displayName of the vnic. This is also use to match against the Instance Configuration defined secondary vnic.

0 commit comments

Comments
 (0)