Skip to content

Commit 16d2fa3

Browse files
Terraform Team Automationravinitp
authored andcommitted
Added - Support for UpdateInstanceConstraint in Terraform
1 parent 9134721 commit 16d2fa3

40 files changed

+121
-95
lines changed

internal/integrationtest/core_instance_test.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,16 @@ var (
5555
"ocpus": acctest.Representation{RepType: acctest.Required, Create: `1`},
5656
}
5757
CoreInstanceRepresentation = map[string]interface{}{
58-
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
59-
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
60-
"shape": acctest.Representation{RepType: acctest.Required, Create: `VM.Standard2.1`},
61-
"agent_config": acctest.RepresentationGroup{RepType: acctest.Optional, Group: CoreInstanceAgentConfigRepresentation},
62-
"availability_config": acctest.RepresentationGroup{RepType: acctest.Optional, Group: CoreInstanceAvailabilityConfigRepresentation},
63-
"create_vnic_details": acctest.RepresentationGroup{RepType: acctest.Optional, Group: CoreInstanceCreateVnicDetailsRepresentation},
64-
"dedicated_vm_host_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_core_dedicated_vm_host.test_dedicated_vm_host.id}`},
65-
"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")}`},
66-
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
58+
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
59+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
60+
"shape": acctest.Representation{RepType: acctest.Required, Create: `VM.Standard2.1`},
61+
"update_operation_constraint": acctest.Representation{RepType: acctest.Optional, Create: `ALLOW_DOWNTIME`, Update: `ALLOW_DOWNTIME`},
62+
"agent_config": acctest.RepresentationGroup{RepType: acctest.Optional, Group: CoreInstanceAgentConfigRepresentation},
63+
"availability_config": acctest.RepresentationGroup{RepType: acctest.Optional, Group: CoreInstanceAvailabilityConfigRepresentation},
64+
"create_vnic_details": acctest.RepresentationGroup{RepType: acctest.Optional, Group: CoreInstanceCreateVnicDetailsRepresentation},
65+
"dedicated_vm_host_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_core_dedicated_vm_host.test_dedicated_vm_host.id}`},
66+
"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")}`},
67+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
6768
"extended_metadata": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{
6869
"some_string": "stringA",
6970
"nested_object": "{\\\"some_string\\\": \\\"stringB\\\", \\\"object\\\": {\\\"some_string\\\": \\\"stringC\\\"}}",
@@ -673,6 +674,7 @@ func TestCoreInstanceResource_basic(t *testing.T) {
673674
resource.TestCheckResourceAttr(resourceName, "state", "STOPPED"),
674675
resource.TestCheckResourceAttrSet(resourceName, "subnet_id"),
675676
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
677+
resource.TestCheckResourceAttr(resourceName, "update_operation_constraint", "ALLOW_DOWNTIME"),
676678

677679
func(s *terraform.State) (err error) {
678680
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
@@ -687,7 +689,7 @@ func TestCoreInstanceResource_basic(t *testing.T) {
687689
// verify updates to updatable parameters
688690
{
689691
Config: config + compartmentIdVariableStr + managementEndpointStr + CoreInstanceResourceDependencies +
690-
acctest.GenerateResourceFromRepresentationMap("oci_core_instance", "test_instance", acctest.Optional, acctest.Update, CoreInstanceRepresentation),
692+
acctest.GenerateResourceFromRepresentationMap("oci_core_instance", "test_instance", acctest.Optional, acctest.Update, acctest.GetUpdatedRepresentationCopy("update_operation_constraint", acctest.Representation{RepType: acctest.Optional, Update: `ALLOW_DOWNTIME`}, CoreInstanceRepresentation)),
691693
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
692694
resource.TestCheckResourceAttr(resourceName, "agent_config.#", "1"),
693695
resource.TestCheckResourceAttr(resourceName, "agent_config.0.are_all_plugins_disabled", "false"),
@@ -742,6 +744,7 @@ func TestCoreInstanceResource_basic(t *testing.T) {
742744
resource.TestCheckResourceAttr(resourceName, "state", "RUNNING"),
743745
resource.TestCheckResourceAttrSet(resourceName, "subnet_id"),
744746
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
747+
resource.TestCheckResourceAttr(resourceName, "update_operation_constraint", "ALLOW_DOWNTIME"),
745748

746749
func(s *terraform.State) (err error) {
747750
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
@@ -914,6 +917,7 @@ func TestCoreInstanceResource_basic(t *testing.T) {
914917
resource.TestCheckResourceAttr(resourceName, "state", "STOPPED"),
915918
resource.TestCheckResourceAttrSet(resourceName, "subnet_id"),
916919
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
920+
resource.TestCheckResourceAttr(resourceName, "update_operation_constraint", "ALLOW_DOWNTIME"),
917921

918922
func(s *terraform.State) (err error) {
919923
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
@@ -935,6 +939,7 @@ func TestCoreInstanceResource_basic(t *testing.T) {
935939
// and so it may complain that values are different.
936940
"extended_metadata",
937941
"hostname_label",
942+
"update_operation_constraint",
938943
"is_pv_encryption_in_transit_enabled",
939944
"create_vnic_details.0.assign_private_dns_record",
940945
"subnet_id",

internal/service/core/core_instance_resource.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,10 @@ func CoreInstanceResource() *schema.Resource {
593593
Type: schema.TypeBool,
594594
Optional: true,
595595
},
596+
"update_operation_constraint": {
597+
Type: schema.TypeString,
598+
Optional: true,
599+
},
596600
"source_details": {
597601
Type: schema.TypeList,
598602
Optional: true,
@@ -1125,6 +1129,10 @@ func (s *CoreInstanceResourceCrud) Update() error {
11251129

11261130
request := oci_core.UpdateInstanceRequest{}
11271131

1132+
if updateOperationConstraint, ok := s.D.GetOkExists("update_operation_constraint"); ok {
1133+
request.UpdateOperationConstraint = oci_core.UpdateInstanceDetailsUpdateOperationConstraintEnum(updateOperationConstraint.(string))
1134+
}
1135+
11281136
if agentConfig, ok := s.D.GetOkExists("agent_config"); ok {
11291137
if tmpList := agentConfig.([]interface{}); len(tmpList) > 0 {
11301138
fieldKeyFormat := fmt.Sprintf("%s.%d.%%s", "agent_config", 0)
@@ -2914,6 +2922,10 @@ func (s *CoreInstanceResourceCrud) updateOptionsViaWorkRequest() error {
29142922
}
29152923
}
29162924

2925+
if updateOperationConstraint, ok := s.D.GetOkExists("update_operation_constraint"); ok {
2926+
request.UpdateOperationConstraint = oci_core.UpdateInstanceDetailsUpdateOperationConstraintEnum(updateOperationConstraint.(string))
2927+
}
2928+
29172929
if request.Shape == nil && request.ShapeConfig == nil && request.LaunchOptions == nil && request.FaultDomain == nil {
29182930
// no-op
29192931
return nil

internal/utils/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const (
6464
variable "FlexInstanceImageOCID" {
6565
type = "map"
6666
default = {
67-
us-phoenix-1 = "ocid1.image.oc1.phx.aaaaaaaa6hooptnlbfwr5lwemqjbu3uqidntrlhnt45yihfj222zahe7p3wq"
67+
us-phoenix-1 = "ocid1.image.oc1.phx.aaaaaaaalgvdp6hhnulo3tlxz3mtff625s7ix6ianpmv5l7chz5rcakrxbiq"
6868
us-ashburn-1 = "ocid1.image.oc1.iad.aaaaaaaa6tp7lhyrcokdtf7vrbmxyp2pctgg4uxvt4jz4vc47qoc2ec4anha"
6969
eu-frankfurt-1 = "ocid1.image.oc1.eu-frankfurt-1.aaaaaaaadvi77prh3vjijhwe5xbd6kjg3n5ndxjcpod6om6qaiqeu3csof7a"
7070
uk-london-1 = "ocid1.image.oc1.uk-london-1.aaaaaaaaw5gvriwzjhzt2tnylrfnpanz5ndztyrv3zpwhlzxdbkqsjfkwxaq"

website/docs/d/core_boot_volume.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The following attributes are exported:
4949
* `image_id` - The image OCID used to create the boot volume.
5050
* `is_auto_tune_enabled` - Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the `DetachedVolumeAutotunePolicy` instead to enable the volume for detached autotune.
5151
* `is_hydrated` - Specifies whether the boot volume's data has finished copying from the source boot volume or boot volume backup.
52-
* `kms_key_id` - The OCID of the Key Management master encryption key assigned to the boot volume.
52+
* `kms_key_id` - The OCID of the Vault service master encryption key assigned to the boot volume.
5353
* `size_in_gbs` - The size of the boot volume in GBs.
5454
* `size_in_mbs` - The size of the volume in MBs. The value must be a multiple of 1024. This field is deprecated. Please use `size_in_gbs`.
5555
* `source_details` -

website/docs/d/core_boot_volume_backup.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The following attributes are exported:
4040
* `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"}`
4141
* `id` - The OCID of the boot volume backup.
4242
* `image_id` - The image OCID used to create the boot volume the backup is taken from.
43-
* `kms_key_id` - The OCID of the Key Management master encryption assigned to the boot volume backup. For more information about the Key Management service and encryption keys, see [Overview of Key Management](https://docs.cloud.oracle.com/iaas/Content/KeyManagement/Concepts/keyoverview.htm) and [Using Keys](https://docs.cloud.oracle.com/iaas/Content/KeyManagement/Tasks/usingkeys.htm).
43+
* `kms_key_id` - The OCID of the Vault service master encryption assigned to the boot volume backup. For more information about the Vault service and encryption keys, see [Overview of Vault service](https://docs.cloud.oracle.com/iaas/Content/KeyManagement/Concepts/keyoverview.htm) and [Using Keys](https://docs.cloud.oracle.com/iaas/Content/KeyManagement/Tasks/usingkeys.htm).
4444
* `size_in_gbs` - The size of the boot volume, in GBs.
4545
* `source_boot_volume_backup_id` - The OCID of the source boot volume backup.
4646
* `source_type` - Specifies whether the backup was created manually, or via scheduled backup policy.

website/docs/d/core_boot_volume_backups.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The following attributes are exported:
5757
* `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"}`
5858
* `id` - The OCID of the boot volume backup.
5959
* `image_id` - The image OCID used to create the boot volume the backup is taken from.
60-
* `kms_key_id` - The OCID of the Key Management master encryption assigned to the boot volume backup. For more information about the Key Management service and encryption keys, see [Overview of Key Management](https://docs.cloud.oracle.com/iaas/Content/KeyManagement/Concepts/keyoverview.htm) and [Using Keys](https://docs.cloud.oracle.com/iaas/Content/KeyManagement/Tasks/usingkeys.htm).
60+
* `kms_key_id` - The OCID of the Vault service master encryption assigned to the boot volume backup. For more information about the Vault service and encryption keys, see [Overview of Vault service](https://docs.cloud.oracle.com/iaas/Content/KeyManagement/Concepts/keyoverview.htm) and [Using Keys](https://docs.cloud.oracle.com/iaas/Content/KeyManagement/Tasks/usingkeys.htm).
6161
* `size_in_gbs` - The size of the boot volume, in GBs.
6262
* `source_boot_volume_backup_id` - The OCID of the source boot volume backup.
6363
* `source_type` - Specifies whether the backup was created manually, or via scheduled backup policy.

website/docs/d/core_boot_volumes.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The following attributes are exported:
6161
* `image_id` - The image OCID used to create the boot volume.
6262
* `is_auto_tune_enabled` - Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the `DetachedVolumeAutotunePolicy` instead to enable the volume for detached autotune.
6363
* `is_hydrated` - Specifies whether the boot volume's data has finished copying from the source boot volume or boot volume backup.
64-
* `kms_key_id` - The OCID of the Key Management master encryption key assigned to the boot volume.
64+
* `kms_key_id` - The OCID of the Vault service master encryption key assigned to the boot volume.
6565
* `size_in_gbs` - The size of the boot volume in GBs.
6666
* `size_in_mbs` - The size of the volume in MBs. The value must be a multiple of 1024. This field is deprecated. Please use `size_in_gbs`.
6767
* `source_details` -

website/docs/d/core_drg_route_table_route_rules.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The following attributes are exported:
4848
Potential values:
4949
* An IP address range (IPv4 or IPv6) in CIDR notation. For example: `192.168.1.0/24` or `2001:0db8:0123:45::/56`.
5050
* When you're setting up a security rule for traffic destined for a particular `Service` through a service gateway, this is the `cidrBlock` value associated with that [Service](https://docs.cloud.oracle.com/iaas/api/#/en/iaas/20160918/Service/). For example: `oci-phx-objectstorage`.
51-
* `destination_type` - The type of destination for the rule. the type is required if `direction` = `EGRESS`.
51+
* `destination_type` - The type of destination for the rule.
5252

5353
Allowed values:
5454
* `CIDR_BLOCK`: If the rule's `destination` is an IP address range in CIDR notation.

website/docs/d/core_images.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Lists a subset of images available in the specified compartment, including
1414
[platform images](https://docs.cloud.oracle.com/iaas/Content/Compute/References/images.htm) and
1515
[custom images](https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/managingcustomimages.htm).
1616
The list of platform images includes the three most recently published versions
17-
of each major distribution.
17+
of each major distribution. The list does not support filtering based on image tags.
1818

1919
The list of images returned is ordered to first show the recent platform images,
2020
then all of the custom images.

website/docs/d/core_instance.html.markdown

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ This data source provides details about a specific Instance resource in Oracle C
1212

1313
Gets information about the specified instance.
1414

15+
**Note:** To retrieve public and private IP addresses for an instance, use the [ListVnicAttachments](https://docs.cloud.oracle.com/iaas/api/#/en/iaas/latest/VnicAttachment/ListVnicAttachments)
16+
operation to get the VNIC ID for the instance, and then call [GetVnic](https://docs.cloud.oracle.com/iaas/api/#/en/iaas/latest/Vnic/GetVnic) with the VNIC ID.
17+
18+
1519
## Example Usage
1620

1721
```hcl
@@ -204,9 +208,9 @@ The following attributes are exported:
204208
* `20`: Represents Higher Performance option.
205209
* `30`-`120`: Represents the Ultra High Performance option.
206210

207-
For volumes with the auto-tuned performance feature enabled, this is set to the default (minimum) VPUs/GB.
208-
* `kms_key_id` - The OCID of the Key Management key to assign as the master encryption key for the boot volume.
209-
* `source_id` - The OCID of an image or a boot volume to use, depending on the value of `source_type`.
211+
For volumes with the auto-tuned performance feature enabled, this is set to the default (minimum) VPUs/GB.
212+
* `kms_key_id` - The OCID of the Vault service key to assign as the master encryption key for the boot volume.
213+
* `source_id` - The OCID of the boot volume used to boot the instance.
210214
* `source_type` - The source type for the instance. Use `image` when specifying the image OCID. Use `bootVolume` when specifying the boot volume OCID.
211215
* `state` - The current state of the instance.
212216
* `system_tags` - System tags for this resource. Each key is predefined and scoped to a namespace. Example: `{"foo-namespace.bar-key": "value"}`

0 commit comments

Comments
 (0)