Skip to content

Commit 8cf30f2

Browse files
authored
Release v3.32.0
Release v3.32.0
2 parents fb2988a + 5cc9077 commit 8cf30f2

File tree

92 files changed

+1199
-290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1199
-290
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ script:
2121
branches:
2222
only:
2323
- master
24+
- release_gh
2425
matrix:
2526
fast_finish: true
2627
allow_failures:

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
## 3.32.0 (Unreleased)
2+
3+
### Added
4+
- Support for moving Images across compartments
5+
- Support for moving Instance Pools and Instance Configurations across compartments
6+
- Support for compartment move of auto-scaling configuration resource
7+
8+
### Fixed
9+
- We were throwing an error for some resources if the resource no longer existed during refresh. This is fixed now.
10+
211
## 3.31.0 (June 26, 2019)
312

413
### Added

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/terraform-providers/terraform-provider-oci
33
require (
44
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce // indirect
55
github.com/hashicorp/terraform v0.12.3-0.20190619193004-2ab2796c932c
6-
github.com/oracle/oci-go-sdk v5.12.0+incompatible
6+
github.com/oracle/oci-go-sdk v5.13.0+incompatible
77
github.com/stretchr/objx v0.1.1 // indirect
88
github.com/stretchr/testify v1.3.0
99
gopkg.in/yaml.v2 v2.2.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ github.com/oracle/oci-go-sdk v5.11.0+incompatible h1:p1gTVX65AZbH/x8w13fLRbAsGqd
264264
github.com/oracle/oci-go-sdk v5.11.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
265265
github.com/oracle/oci-go-sdk v5.12.0+incompatible h1:y1ISDE4Rq7dMTl+M2F10TuNQy4Q0to7/Jr4hGRQoS/o=
266266
github.com/oracle/oci-go-sdk v5.12.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
267+
github.com/oracle/oci-go-sdk v5.13.0+incompatible h1:CAs2Aq71RxYwDBT+L0z4cLmW20AM8PermmlO0Y8GfuA=
268+
github.com/oracle/oci-go-sdk v5.13.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
267269
github.com/packer-community/winrmcp v0.0.0-20180102160824-81144009af58/go.mod h1:f6Izs6JvFTdnRbziASagjZ2vmf55NSIkC/weStxCHqk=
268270
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
269271
github.com/pkg/errors v0.0.0-20170505043639-c605e284fe17/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

oci/auto_scaling_auto_scaling_configuration_resource.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ func AutoScalingAutoScalingConfigurationResource() *schema.Resource {
5757
"compartment_id": {
5858
Type: schema.TypeString,
5959
Required: true,
60-
ForceNew: true,
6160
},
6261
"policies": {
6362
Type: schema.TypeList,
@@ -398,6 +397,15 @@ func (s *AutoScalingAutoScalingConfigurationResourceCrud) Get() error {
398397
}
399398

400399
func (s *AutoScalingAutoScalingConfigurationResourceCrud) Update() error {
400+
if compartment, ok := s.D.GetOkExists("compartment_id"); ok && s.D.HasChange("compartment_id") {
401+
oldRaw, newRaw := s.D.GetChange("compartment_id")
402+
if newRaw != "" && oldRaw != "" {
403+
err := s.updateCompartment(compartment)
404+
if err != nil {
405+
return err
406+
}
407+
}
408+
}
401409
request := oci_auto_scaling.UpdateAutoScalingConfigurationRequest{}
402410

403411
tmp := s.D.Id()
@@ -851,3 +859,21 @@ func autoScalingConfigurationPolicyRulesHashCodeForSets(v interface{}) int {
851859
}
852860
return hashcode.String(buf.String())
853861
}
862+
func (s *AutoScalingAutoScalingConfigurationResourceCrud) updateCompartment(compartment interface{}) error {
863+
changeCompartmentRequest := oci_auto_scaling.ChangeAutoScalingConfigurationCompartmentRequest{}
864+
865+
idTmp := s.D.Id()
866+
changeCompartmentRequest.AutoScalingConfigurationId = &idTmp
867+
868+
compartmentTmp := compartment.(string)
869+
changeCompartmentRequest.ChangeCompartmentDetails = oci_auto_scaling.ChangeAutoScalingCompartmentDetails{}
870+
changeCompartmentRequest.ChangeCompartmentDetails.CompartmentId = &compartmentTmp
871+
872+
changeCompartmentRequest.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "auto_scaling")
873+
874+
_, err := s.Client.ChangeAutoScalingConfigurationCompartment(context.Background(), changeCompartmentRequest)
875+
if err != nil {
876+
return err
877+
}
878+
return nil
879+
}

oci/auto_scaling_auto_scaling_configuration_test.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ func TestAutoScalingAutoScalingConfigurationResource_basic(t *testing.T) {
110110
compartmentId := getEnvSettingWithBlankDefault("compartment_ocid")
111111
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
112112

113+
compartmentIdU := getEnvSettingWithDefault("compartment_id_for_update", compartmentId)
114+
compartmentIdUVariableStr := fmt.Sprintf("variable \"compartment_id_for_update\" { default = \"%s\" }\n", compartmentIdU)
115+
113116
resourceName := "oci_autoscaling_auto_scaling_configuration.test_auto_scaling_configuration"
114117
datasourceName := "data.oci_autoscaling_auto_scaling_configurations.test_auto_scaling_configurations"
115118
singularDatasourceName := "data.oci_autoscaling_auto_scaling_configuration.test_auto_scaling_configuration"
@@ -231,6 +234,67 @@ func TestAutoScalingAutoScalingConfigurationResource_basic(t *testing.T) {
231234
),
232235
},
233236

237+
// verify update to the compartment (the compartment will be switched back in the next step)
238+
{
239+
Config: config + compartmentIdVariableStr + compartmentIdUVariableStr + AutoScalingConfigurationResourceDependencies +
240+
generateResourceFromRepresentationMap("oci_autoscaling_auto_scaling_configuration", "test_auto_scaling_configuration", Optional, Create,
241+
representationCopyWithNewProperties(autoScalingConfigurationRepresentation, map[string]interface{}{
242+
"compartment_id": Representation{repType: Required, create: `${var.compartment_id_for_update}`},
243+
})),
244+
Check: resource.ComposeAggregateTestCheckFunc(
245+
resource.TestCheckResourceAttr(resourceName, "auto_scaling_resources.#", "1"),
246+
resource.TestCheckResourceAttrSet(resourceName, "auto_scaling_resources.0.id"),
247+
resource.TestCheckResourceAttr(resourceName, "auto_scaling_resources.0.type", "instancePool"),
248+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
249+
resource.TestCheckResourceAttr(resourceName, "cool_down_in_seconds", "300"),
250+
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
251+
resource.TestCheckResourceAttr(resourceName, "display_name", "example_autoscaling_configuration"),
252+
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
253+
resource.TestCheckResourceAttrSet(resourceName, "id"),
254+
resource.TestCheckResourceAttr(resourceName, "is_enabled", "false"),
255+
resource.TestCheckResourceAttr(resourceName, "policies.#", "1"),
256+
resource.TestCheckResourceAttrSet(resourceName, "policies.0.id"),
257+
resource.TestCheckResourceAttr(resourceName, "policies.0.capacity.#", "1"),
258+
resource.TestCheckResourceAttr(resourceName, "policies.0.capacity.0.initial", "2"),
259+
resource.TestCheckResourceAttr(resourceName, "policies.0.capacity.0.max", "3"),
260+
resource.TestCheckResourceAttr(resourceName, "policies.0.capacity.0.min", "2"),
261+
resource.TestCheckResourceAttr(resourceName, "policies.0.display_name", "example_autoscaling_configuration"),
262+
resource.TestCheckResourceAttr(resourceName, "policies.0.policy_type", "threshold"),
263+
resource.TestCheckResourceAttr(resourceName, "policies.0.rules.#", "2"),
264+
CheckResourceSetContainsElementWithProperties(resourceName, "policies.0.rules", map[string]string{
265+
"action.#": "1",
266+
"action.0.type": "CHANGE_COUNT_BY",
267+
"action.0.value": "1",
268+
"display_name": "scale out rule",
269+
"metric.#": "1",
270+
"metric.0.metric_type": "CPU_UTILIZATION",
271+
"metric.0.threshold.#": "1",
272+
"metric.0.threshold.0.operator": "GT",
273+
"metric.0.threshold.0.value": "1",
274+
},
275+
[]string{}),
276+
CheckResourceSetContainsElementWithProperties(resourceName, "policies.0.rules", map[string]string{
277+
"action.#": "1",
278+
"action.0.type": "CHANGE_COUNT_BY",
279+
"action.0.value": "-1",
280+
"display_name": "scale in rule",
281+
"metric.#": "1",
282+
"metric.0.metric_type": "CPU_UTILIZATION",
283+
"metric.0.threshold.#": "1",
284+
"metric.0.threshold.0.operator": "LT",
285+
"metric.0.threshold.0.value": "1",
286+
},
287+
[]string{}),
288+
resource.TestCheckResourceAttrSet(resourceName, "policies.0.time_created"),
289+
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
290+
291+
func(s *terraform.State) (err error) {
292+
resId, err = fromInstanceState(s, resourceName, "id")
293+
return err
294+
},
295+
),
296+
},
297+
234298
// verify updates to updatable parameters
235299
{
236300
Config: config + compartmentIdVariableStr + AutoScalingConfigurationResourceDependencies +

oci/core_dhcp_options_resource_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var additionalDhcpOption4 = `
5050
//To avoid multiple applies we perform an apply after the create in order have the options match what the user has in the config
5151
//This test makes sure we handle that case correctly and that there is a non empty plan after the apply
5252
func TestResourceCoreDHCPOptions_avoidServiceDefault(t *testing.T) {
53-
httpreplay.SetScenario("TestAccResourceCoreDHCPOptions_avoidServiceDefault")
53+
httpreplay.SetScenario("TestResourceCoreDHCPOptions_avoidServiceDefault")
5454
defer httpreplay.SaveScenario()
5555

5656
provider := testAccProvider
@@ -93,7 +93,7 @@ func TestResourceCoreDHCPOptions_avoidServiceDefault(t *testing.T) {
9393
}
9494

9595
func TestResourceCoreDHCPOptions_basic(t *testing.T) {
96-
httpreplay.SetScenario("TestAccResourceCoreDHCPOptions_basic")
96+
httpreplay.SetScenario("TestResourceCoreDHCPOptions_basic")
9797
defer httpreplay.SaveScenario()
9898

9999
var resDefaultId, resOpt4Id, resId2 string

oci/core_image_resource.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ func CoreImageResource() *schema.Resource {
3333
"compartment_id": {
3434
Type: schema.TypeString,
3535
Required: true,
36-
ForceNew: true,
3736
},
3837

3938
// Optional
@@ -352,6 +351,15 @@ func (s *CoreImageResourceCrud) Get() error {
352351
}
353352

354353
func (s *CoreImageResourceCrud) Update() error {
354+
if compartment, ok := s.D.GetOkExists("compartment_id"); ok && s.D.HasChange("compartment_id") {
355+
oldRaw, newRaw := s.D.GetChange("compartment_id")
356+
if newRaw != "" && oldRaw != "" {
357+
err := s.updateCompartment(compartment)
358+
if err != nil {
359+
return err
360+
}
361+
}
362+
}
355363
request := oci_core.UpdateImageRequest{}
356364

357365
if definedTags, ok := s.D.GetOkExists("defined_tags"); ok {
@@ -509,3 +517,21 @@ func InstanceAgentFeaturesToMap(obj *oci_core.InstanceAgentFeatures) map[string]
509517

510518
return result
511519
}
520+
521+
func (s *CoreImageResourceCrud) updateCompartment(compartment interface{}) error {
522+
changeCompartmentRequest := oci_core.ChangeImageCompartmentRequest{}
523+
524+
compartmentTmp := compartment.(string)
525+
changeCompartmentRequest.CompartmentId = &compartmentTmp
526+
527+
idTmp := s.D.Id()
528+
changeCompartmentRequest.ImageId = &idTmp
529+
530+
changeCompartmentRequest.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "core")
531+
532+
_, err := s.Client.ChangeImageCompartment(context.Background(), changeCompartmentRequest)
533+
if err != nil {
534+
return err
535+
}
536+
return nil
537+
}

oci/core_image_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ func TestCoreImageResource_basic(t *testing.T) {
5858
compartmentId := getEnvSettingWithBlankDefault("compartment_ocid")
5959
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
6060

61+
compartmentIdU := getEnvSettingWithDefault("compartment_id_for_update", compartmentId)
62+
compartmentIdUVariableStr := fmt.Sprintf("variable \"compartment_id_for_update\" { default = \"%s\" }\n", compartmentIdU)
63+
6164
resourceName := "oci_core_image.test_image"
6265
datasourceName := "data.oci_core_images.test_images"
6366

@@ -114,6 +117,37 @@ func TestCoreImageResource_basic(t *testing.T) {
114117
),
115118
},
116119

120+
// verify update to the compartment (the compartment will be switched back in the next step)
121+
{
122+
Config: config + compartmentIdVariableStr + compartmentIdUVariableStr + ImageResourceDependencies +
123+
generateResourceFromRepresentationMap("oci_core_image", "test_image", Optional, Create,
124+
representationCopyWithNewProperties(imageRepresentation, map[string]interface{}{
125+
"compartment_id": Representation{repType: Required, create: `${var.compartment_id_for_update}`},
126+
})),
127+
Check: resource.ComposeAggregateTestCheckFunc(
128+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
129+
resource.TestCheckResourceAttrSet(resourceName, "create_image_allowed"),
130+
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
131+
resource.TestCheckResourceAttr(resourceName, "display_name", "MyCustomImage"),
132+
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
133+
resource.TestCheckResourceAttrSet(resourceName, "id"),
134+
resource.TestCheckResourceAttrSet(resourceName, "instance_id"),
135+
resource.TestCheckResourceAttr(resourceName, "launch_mode", "NATIVE"),
136+
resource.TestCheckResourceAttrSet(resourceName, "operating_system"),
137+
resource.TestCheckResourceAttrSet(resourceName, "operating_system_version"),
138+
resource.TestCheckResourceAttrSet(resourceName, "state"),
139+
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
140+
141+
func(s *terraform.State) (err error) {
142+
resId2, err = fromInstanceState(s, resourceName, "id")
143+
if resId != resId2 {
144+
return fmt.Errorf("resource recreated when it was supposed to be updated")
145+
}
146+
return err
147+
},
148+
),
149+
},
150+
117151
// verify updates to updatable parameters
118152
{
119153
Config: config + compartmentIdVariableStr + ImageResourceDependencies +

oci/core_instance_configuration_resource.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func CoreInstanceConfigurationResource() *schema.Resource {
3030
"compartment_id": {
3131
Type: schema.TypeString,
3232
Required: true,
33-
ForceNew: true,
3433
},
3534
"instance_details": {
3635
Type: schema.TypeList,
@@ -630,6 +629,15 @@ func (s *CoreInstanceConfigurationResourceCrud) Get() error {
630629
}
631630

632631
func (s *CoreInstanceConfigurationResourceCrud) Update() error {
632+
if compartment, ok := s.D.GetOkExists("compartment_id"); ok && s.D.HasChange("compartment_id") {
633+
oldRaw, newRaw := s.D.GetChange("compartment_id")
634+
if newRaw != "" && oldRaw != "" {
635+
err := s.updateCompartment(compartment)
636+
if err != nil {
637+
return err
638+
}
639+
}
640+
}
633641
request := oci_core.UpdateInstanceConfigurationRequest{}
634642

635643
if definedTags, ok := s.D.GetOkExists("defined_tags"); ok {
@@ -1393,3 +1401,21 @@ func InstanceConfigurationVolumeSourceDetailsToMap(obj *oci_core.InstanceConfigu
13931401

13941402
return result
13951403
}
1404+
1405+
func (s *CoreInstanceConfigurationResourceCrud) updateCompartment(compartment interface{}) error {
1406+
changeCompartmentRequest := oci_core.ChangeInstanceConfigurationCompartmentRequest{}
1407+
1408+
compartmentTmp := compartment.(string)
1409+
changeCompartmentRequest.CompartmentId = &compartmentTmp
1410+
1411+
idTmp := s.D.Id()
1412+
changeCompartmentRequest.InstanceConfigurationId = &idTmp
1413+
1414+
changeCompartmentRequest.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "core")
1415+
1416+
_, err := s.Client.ChangeInstanceConfigurationCompartment(context.Background(), changeCompartmentRequest)
1417+
if err != nil {
1418+
return err
1419+
}
1420+
return nil
1421+
}

0 commit comments

Comments
 (0)