Skip to content

Commit 95091b0

Browse files
Terraform Team AutomationMeharwadeDivya
authored andcommitted
Added - Support for Instance Configuration feature parity improvement March 2021 Compute: Instance Configuration feature parity with downstream APIs
1 parent 9e2c83a commit 95091b0

10 files changed

+243
-43
lines changed

examples/compute/instance_pool/instance_pool.tf

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,16 @@ resource "oci_core_instance_configuration" "test_instance_configuration" {
175175
*/
176176
block_volumes {
177177
create_details {
178-
compartment_id = var.compartment_ocid
179-
display_name = "TestCreateVolumeDetails-1"
180-
availability_domain = data.oci_identity_availability_domain.ad.name
181-
size_in_gbs = 50
182-
vpus_per_gb = 20 // min vpus
178+
compartment_id = var.compartment_ocid
179+
display_name = "TestCreateVolumeDetails-1"
180+
availability_domain = data.oci_identity_availability_domain.ad.name
181+
size_in_gbs = 50
182+
vpus_per_gb = 20 // min vpus
183+
is_auto_tune_enabled = false
184+
block_volume_replicas {
185+
display_name = "TestCreateVolumeDetails-1"
186+
availability_domain = data.oci_identity_availability_domain.ad.name
187+
}
183188
}
184189

185190
attach_details {
@@ -221,6 +226,11 @@ resource "oci_core_instance_configuration" "test_instance_configuration" {
221226
is_monitoring_disabled = false
222227
}
223228

229+
availability_config {
230+
recovery_action = "RESTORE_INSTANCE"
231+
is_live_migration_preferred = false
232+
}
233+
224234
launch_options {
225235
network_type = "PARAVIRTUALIZED"
226236
}

internal/integrationtest/core_instance_configuration_test.go

Lines changed: 63 additions & 32 deletions
Large diffs are not rendered by default.

internal/service/core/core_instance_configuration_resource.go

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,35 @@ func CoreInstanceConfigurationResource() *schema.Resource {
207207
Computed: true,
208208
ForceNew: true,
209209
},
210+
"block_volume_replicas": {
211+
Type: schema.TypeList,
212+
Optional: true,
213+
Computed: true,
214+
ForceNew: true,
215+
MinItems: 1,
216+
MaxItems: 1,
217+
Elem: &schema.Resource{
218+
Schema: map[string]*schema.Schema{
219+
// Required
220+
"availability_domain": {
221+
Type: schema.TypeString,
222+
Required: true,
223+
ForceNew: true,
224+
DiffSuppressFunc: tfresource.EqualIgnoreCaseSuppressDiff,
225+
},
226+
227+
// Optional
228+
"display_name": {
229+
Type: schema.TypeString,
230+
Optional: true,
231+
Computed: true,
232+
ForceNew: true,
233+
},
234+
235+
// Computed
236+
},
237+
},
238+
},
210239
"compartment_id": {
211240
Type: schema.TypeString,
212241
Optional: true,
@@ -234,6 +263,12 @@ func CoreInstanceConfigurationResource() *schema.Resource {
234263
ForceNew: true,
235264
Elem: schema.TypeString,
236265
},
266+
"is_auto_tune_enabled": {
267+
Type: schema.TypeBool,
268+
Optional: true,
269+
Computed: true,
270+
ForceNew: true,
271+
},
237272
"kms_key_id": {
238273
Type: schema.TypeString,
239274
Optional: true,
@@ -389,6 +424,11 @@ func CoreInstanceConfigurationResource() *schema.Resource {
389424
// Required
390425

391426
// Optional
427+
"is_live_migration_preferred": {
428+
Type: schema.TypeBool,
429+
Optional: true,
430+
Computed: true,
431+
},
392432
"recovery_action": {
393433
Type: schema.TypeString,
394434
Optional: true,
@@ -888,6 +928,12 @@ func CoreInstanceConfigurationResource() *schema.Resource {
888928
Computed: true,
889929
ForceNew: true,
890930
},
931+
"kms_key_id": {
932+
Type: schema.TypeString,
933+
Optional: true,
934+
Computed: true,
935+
ForceNew: true,
936+
},
891937

892938
// Computed
893939
},
@@ -1458,6 +1504,11 @@ func InstanceConfigurationAutotunePolicyToMap(obj oci_core.InstanceConfiguration
14581504
func (s *CoreInstanceConfigurationResourceCrud) mapToInstanceConfigurationAvailabilityConfig(fieldKeyFormat string) (oci_core.InstanceConfigurationAvailabilityConfig, error) {
14591505
result := oci_core.InstanceConfigurationAvailabilityConfig{}
14601506

1507+
if isLiveMigrationPreferred, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_live_migration_preferred")); ok {
1508+
tmp := isLiveMigrationPreferred.(bool)
1509+
result.IsLiveMigrationPreferred = &tmp
1510+
}
1511+
14611512
if recoveryAction, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "recovery_action")); ok {
14621513
result.RecoveryAction = oci_core.InstanceConfigurationAvailabilityConfigRecoveryActionEnum(recoveryAction.(string))
14631514
}
@@ -1468,6 +1519,10 @@ func (s *CoreInstanceConfigurationResourceCrud) mapToInstanceConfigurationAvaila
14681519
func InstanceConfigurationAvailabilityConfigToMap(obj *oci_core.InstanceConfigurationAvailabilityConfig) map[string]interface{} {
14691520
result := map[string]interface{}{}
14701521

1522+
if obj.IsLiveMigrationPreferred != nil {
1523+
result["is_live_migration_preferred"] = bool(*obj.IsLiveMigrationPreferred)
1524+
}
1525+
14711526
result["recovery_action"] = string(obj.RecoveryAction)
14721527

14731528
return result
@@ -1528,6 +1583,36 @@ func InstanceConfigurationBlockVolumeDetailsToMap(obj oci_core.InstanceConfigura
15281583
return result
15291584
}
15301585

1586+
func (s *CoreInstanceConfigurationResourceCrud) mapToInstanceConfigurationBlockVolumeReplicaDetails(fieldKeyFormat string) (oci_core.InstanceConfigurationBlockVolumeReplicaDetails, error) {
1587+
result := oci_core.InstanceConfigurationBlockVolumeReplicaDetails{}
1588+
1589+
if availabilityDomain, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "availability_domain")); ok {
1590+
tmp := availabilityDomain.(string)
1591+
result.AvailabilityDomain = &tmp
1592+
}
1593+
1594+
if displayName, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "display_name")); ok {
1595+
tmp := displayName.(string)
1596+
result.DisplayName = &tmp
1597+
}
1598+
1599+
return result, nil
1600+
}
1601+
1602+
func InstanceConfigurationBlockVolumeReplicaDetailsToMap(obj oci_core.InstanceConfigurationBlockVolumeReplicaDetails) map[string]interface{} {
1603+
result := map[string]interface{}{}
1604+
1605+
if obj.AvailabilityDomain != nil {
1606+
result["availability_domain"] = string(*obj.AvailabilityDomain)
1607+
}
1608+
1609+
if obj.DisplayName != nil {
1610+
result["display_name"] = string(*obj.DisplayName)
1611+
}
1612+
1613+
return result
1614+
}
1615+
15311616
func (s *CoreInstanceConfigurationResourceCrud) mapToInstanceConfigurationCreateVnicDetails(fieldKeyFormat string) (oci_core.InstanceConfigurationCreateVnicDetails, error) {
15321617
result := oci_core.InstanceConfigurationCreateVnicDetails{}
15331618

@@ -1677,6 +1762,23 @@ func (s *CoreInstanceConfigurationResourceCrud) mapToInstanceConfigurationCreate
16771762
result.BackupPolicyId = &tmp
16781763
}
16791764

1765+
if blockVolumeReplicas, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "block_volume_replicas")); ok {
1766+
interfaces := blockVolumeReplicas.([]interface{})
1767+
tmp := make([]oci_core.InstanceConfigurationBlockVolumeReplicaDetails, len(interfaces))
1768+
for i := range interfaces {
1769+
stateDataIndex := i
1770+
fieldKeyFormatNextLevel := fmt.Sprintf("%s.%d.%%s", fmt.Sprintf(fieldKeyFormat, "block_volume_replicas"), stateDataIndex)
1771+
converted, err := s.mapToInstanceConfigurationBlockVolumeReplicaDetails(fieldKeyFormatNextLevel)
1772+
if err != nil {
1773+
return result, err
1774+
}
1775+
tmp[i] = converted
1776+
}
1777+
if len(tmp) != 0 || s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "block_volume_replicas")) {
1778+
result.BlockVolumeReplicas = tmp
1779+
}
1780+
}
1781+
16801782
if compartmentId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "compartment_id")); ok {
16811783
tmp := compartmentId.(string)
16821784
result.CompartmentId = &tmp
@@ -1699,6 +1801,11 @@ func (s *CoreInstanceConfigurationResourceCrud) mapToInstanceConfigurationCreate
16991801
result.FreeformTags = tfresource.ObjectMapToStringMap(freeformTags.(map[string]interface{}))
17001802
}
17011803

1804+
if isAutoTuneEnabled, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_auto_tune_enabled")); ok {
1805+
tmp := isAutoTuneEnabled.(bool)
1806+
result.IsAutoTuneEnabled = &tmp
1807+
}
1808+
17021809
if kmsKeyId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "kms_key_id")); ok {
17031810
tmp := kmsKeyId.(string)
17041811
result.KmsKeyId = &tmp
@@ -1753,6 +1860,12 @@ func InstanceConfigurationCreateVolumeDetailsToMap(obj *oci_core.InstanceConfigu
17531860
result["backup_policy_id"] = string(*obj.BackupPolicyId)
17541861
}
17551862

1863+
blockVolumeReplicas := []interface{}{}
1864+
for _, item := range obj.BlockVolumeReplicas {
1865+
blockVolumeReplicas = append(blockVolumeReplicas, InstanceConfigurationBlockVolumeReplicaDetailsToMap(item))
1866+
}
1867+
result["block_volume_replicas"] = blockVolumeReplicas
1868+
17561869
if obj.CompartmentId != nil {
17571870
result["compartment_id"] = string(*obj.CompartmentId)
17581871
}
@@ -1767,6 +1880,10 @@ func InstanceConfigurationCreateVolumeDetailsToMap(obj *oci_core.InstanceConfigu
17671880

17681881
result["freeform_tags"] = obj.FreeformTags
17691882

1883+
if obj.IsAutoTuneEnabled != nil {
1884+
result["is_auto_tune_enabled"] = bool(*obj.IsAutoTuneEnabled)
1885+
}
1886+
17701887
if obj.KmsKeyId != nil {
17711888
result["kms_key_id"] = string(*obj.KmsKeyId)
17721889
}
@@ -1951,6 +2068,10 @@ func (s *CoreInstanceConfigurationResourceCrud) mapToInstanceConfigurationInstan
19512068
tmp := imageId.(string)
19522069
details.ImageId = &tmp
19532070
}
2071+
if kmsKeyId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "kms_key_id")); ok {
2072+
tmp := kmsKeyId.(string)
2073+
details.KmsKeyId = &tmp
2074+
}
19542075
baseObject = details
19552076
default:
19562077
return nil, fmt.Errorf("unknown source_type '%v' was specified", sourceType)
@@ -1981,6 +2102,10 @@ func InstanceConfigurationInstanceSourceDetailsToMap(obj *oci_core.InstanceConfi
19812102
if v.ImageId != nil {
19822103
result["image_id"] = string(*v.ImageId)
19832104
}
2105+
2106+
if v.KmsKeyId != nil {
2107+
result["kms_key_id"] = string(*v.KmsKeyId)
2108+
}
19842109
default:
19852110
log.Printf("[WARN] Received 'source_type' of unknown type %v", *obj)
19862111
return nil

website/docs/d/core_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The following attributes are exported:
6060
To enable the monitoring and management plugins, the `isMonitoringDisabled` and `isManagementDisabled` attributes must also be set to false.
6161
* `name` - The plugin name. To get a list of available plugins, use the [ListInstanceagentAvailablePlugins](https://docs.cloud.oracle.com/iaas/api/#/en/instanceagent/20180530/Plugin/ListInstanceagentAvailablePlugins) operation in the Oracle Cloud Agent API. For more information about the available plugins, see [Managing Plugins with Oracle Cloud Agent](https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/manage-plugins.htm).
6262
* `availability_config` - Options for defining the availabiity of a VM instance after a maintenance event that impacts the underlying hardware.
63-
* `is_live_migration_preferred` - Whether live migration is preferred for infrastructure maintenance. If null preference is specified, live migration will be preferred for infrastructure maintenance for applicable instances.
63+
* `is_live_migration_preferred` - Whether to live migrate supported VM instances to a healthy physical VM host without disrupting running instances during infrastructure maintenance events. If null, Oracle chooses the best option for migrating the VM during infrastructure maintenance events.
6464
* `recovery_action` - The lifecycle state for an instance when it is recovered after infrastructure maintenance.
6565
* `RESTORE_INSTANCE` - The instance is restored to the lifecycle state it was in before the maintenance event. If the instance was running, it is automatically rebooted. This is the default action when a value is not set.
6666
* `STOP_INSTANCE` - The instance is recovered in the stopped state.

website/docs/d/core_instance_configuration.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,14 @@ The following attributes are exported:
5454
* `max_vpus_per_gb` - This will be the maximum VPUs/GB performance level that the volume will be auto-tuned temporarily based on performance monitoring.
5555
* `availability_domain` - The availability domain of the volume. Example: `Uocm:PHX-AD-1`
5656
* `backup_policy_id` - If provided, specifies the ID of the volume backup policy to assign to the newly created volume. If omitted, no policy will be assigned.
57+
* `block_volume_replicas` - The list of block volume replicas to be enabled for this volume in the specified destination availability domains.
58+
* `availability_domain` - The availability domain of the block volume replica. Example: `Uocm:PHX-AD-1`
59+
* `display_name` - The display name of the block volume replica. You may optionally specify a *display name* for the block volume replica, otherwise a default is provided.
5760
* `compartment_id` - The OCID of the compartment that contains the volume.
5861
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
5962
* `display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
6063
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
64+
* `is_auto_tune_enabled` - Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the `InstanceConfigurationDetachedVolumeAutotunePolicy` instead to enable the volume for detached autotune.
6165
* `kms_key_id` - The OCID of the Vault service key to assign as the master encryption key for the volume.
6266
* `size_in_gbs` - The size of the volume in GBs.
6367
* `source_details` -
@@ -101,6 +105,7 @@ The following attributes are exported:
101105
To enable the monitoring and management plugins, the `isMonitoringDisabled` and `isManagementDisabled` attributes must also be set to false.
102106
* `name` - The plugin name. To get a list of available plugins, use the [ListInstanceagentAvailablePlugins](https://docs.cloud.oracle.com/iaas/api/#/en/instanceagent/20180530/Plugin/ListInstanceagentAvailablePlugins) operation in the Oracle Cloud Agent API. For more information about the available plugins, see [Managing Plugins with Oracle Cloud Agent](https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/manage-plugins.htm).
103107
* `availability_config` - Options for defining the availabiity of a VM instance after a maintenance event that impacts the underlying hardware.
108+
* `is_live_migration_preferred` - Whether to live migrate supported VM instances to a healthy physical VM host without disrupting running instances during infrastructure maintenance events. If null, Oracle chooses the best option for migrating the VM during infrastructure maintenance events.
104109
* `recovery_action` - The lifecycle state for an instance when it is recovered after infrastructure maintenance.
105110
* `RESTORE_INSTANCE` - The instance is restored to the lifecycle state it was in before the maintenance event. If the instance was running, it is automatically rebooted. This is the default action when a value is not set.
106111
* `STOP_INSTANCE` - The instance is recovered in the stopped state.
@@ -252,6 +257,7 @@ The following attributes are exported:
252257
* `20`: Represents Higher Performance option.
253258
* `30`-`120`: Represents the Ultra High Performance option.
254259
* `image_id` - The OCID of the image used to boot the instance.
260+
* `kms_key_id` - The OCID of the Vault service key to assign as the master encryption key for the boot volume.
255261
* `source_type` - The source type for the instance. Use `image` when specifying the image OCID. Use `bootVolume` when specifying the boot volume OCID.
256262
* `secondary_vnics` - Secondary VNIC parameters.
257263
* `create_vnic_details` - Contains the properties of the VNIC for an instance configuration. See [CreateVnicDetails](https://docs.cloud.oracle.com/iaas/api/#/en/iaas/latest/CreateVnicDetails/) and [Instance Configurations](https://docs.cloud.oracle.com/iaas/Content/Compute/Concepts/instancemanagement.htm#config) for more information.

website/docs/d/core_instance_configurations.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,14 @@ The following attributes are exported:
6161
* `max_vpus_per_gb` - This will be the maximum VPUs/GB performance level that the volume will be auto-tuned temporarily based on performance monitoring.
6262
* `availability_domain` - The availability domain of the volume. Example: `Uocm:PHX-AD-1`
6363
* `backup_policy_id` - If provided, specifies the ID of the volume backup policy to assign to the newly created volume. If omitted, no policy will be assigned.
64+
* `block_volume_replicas` - The list of block volume replicas to be enabled for this volume in the specified destination availability domains.
65+
* `availability_domain` - The availability domain of the block volume replica. Example: `Uocm:PHX-AD-1`
66+
* `display_name` - The display name of the block volume replica. You may optionally specify a *display name* for the block volume replica, otherwise a default is provided.
6467
* `compartment_id` - The OCID of the compartment that contains the volume.
6568
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
6669
* `display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
6770
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
71+
* `is_auto_tune_enabled` - Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the `InstanceConfigurationDetachedVolumeAutotunePolicy` instead to enable the volume for detached autotune.
6872
* `kms_key_id` - The OCID of the Vault service key to assign as the master encryption key for the volume.
6973
* `size_in_gbs` - The size of the volume in GBs.
7074
* `source_details` -
@@ -108,6 +112,7 @@ The following attributes are exported:
108112
To enable the monitoring and management plugins, the `isMonitoringDisabled` and `isManagementDisabled` attributes must also be set to false.
109113
* `name` - The plugin name. To get a list of available plugins, use the [ListInstanceagentAvailablePlugins](https://docs.cloud.oracle.com/iaas/api/#/en/instanceagent/20180530/Plugin/ListInstanceagentAvailablePlugins) operation in the Oracle Cloud Agent API. For more information about the available plugins, see [Managing Plugins with Oracle Cloud Agent](https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/manage-plugins.htm).
110114
* `availability_config` - Options for defining the availabiity of a VM instance after a maintenance event that impacts the underlying hardware.
115+
* `is_live_migration_preferred` - Whether to live migrate supported VM instances to a healthy physical VM host without disrupting running instances during infrastructure maintenance events. If null, Oracle chooses the best option for migrating the VM during infrastructure maintenance events.
111116
* `recovery_action` - The lifecycle state for an instance when it is recovered after infrastructure maintenance.
112117
* `RESTORE_INSTANCE` - The instance is restored to the lifecycle state it was in before the maintenance event. If the instance was running, it is automatically rebooted. This is the default action when a value is not set.
113118
* `STOP_INSTANCE` - The instance is recovered in the stopped state.
@@ -259,6 +264,7 @@ The following attributes are exported:
259264
* `20`: Represents Higher Performance option.
260265
* `30`-`120`: Represents the Ultra High Performance option.
261266
* `image_id` - The OCID of the image used to boot the instance.
267+
* `kms_key_id` - The OCID of the Vault service key to assign as the master encryption key for the boot volume.
262268
* `source_type` - The source type for the instance. Use `image` when specifying the image OCID. Use `bootVolume` when specifying the boot volume OCID.
263269
* `secondary_vnics` - Secondary VNIC parameters.
264270
* `create_vnic_details` - Contains the properties of the VNIC for an instance configuration. See [CreateVnicDetails](https://docs.cloud.oracle.com/iaas/api/#/en/iaas/latest/CreateVnicDetails/) and [Instance Configurations](https://docs.cloud.oracle.com/iaas/Content/Compute/Concepts/instancemanagement.htm#config) for more information.

0 commit comments

Comments
 (0)