Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/alicloud_api_gateway_instance: Mark attribute instance_spec modifiable #8414

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion alicloud/resource_alicloud_api_gateway_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func resourceAliCloudApiGatewayInstance() *schema.Resource {
"instance_spec": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"instance_type": {
Type: schema.TypeString,
Expand Down Expand Up @@ -166,6 +165,10 @@ func resourceAliCloudApiGatewayInstance() *schema.Resource {
Optional: true,
ConflictsWith: []string{"to_connect_vpc_ip_block"},
},
"skip_wait_switch": {
Type: schema.TypeBool,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -374,6 +377,45 @@ func resourceAliCloudApiGatewayInstanceUpdate(d *schema.ResourceData, meta inter
}
}

update = false
action = "ModifyInstanceSpec"
request = make(map[string]interface{})
query = make(map[string]interface{})
request["Token"] = buildClientToken(action)
request["InstanceId"] = d.Id()
if !d.IsNewResource() && d.HasChanges("instance_spec") {
update = true
request["InstanceSpec"] = d.Get("instance_spec")
if v, ok := d.GetOk("skip_wait_switch"); ok {
request["SkipWaitSwitch"] = v
}
}
if update {
wait := incrementalWait(3*time.Second, 5*time.Second)
err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError {
response, err = client.RpcPost("CloudAPI", "2016-07-14", action, query, request, true)
request["Token"] = buildClientToken(action)

if err != nil {
if NeedRetry(err) {
wait()
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
addDebug(action, response, request)
return nil
})
if err != nil {
return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR)
}
apiGatewayServiceV2 := ApiGatewayServiceV2{client}
stateConf := BuildStateConf([]string{}, []string{"RUNNING"}, d.Timeout(schema.TimeoutUpdate), 30*time.Second, apiGatewayServiceV2.ApiGatewayInstanceStateRefreshFunc(d.Id(), "Status", []string{}))
if _, err := stateConf.WaitForState(); err != nil {
return WrapErrorf(err, IdMsg, d.Id())
}
}

return resourceAliCloudApiGatewayInstanceRead(d, meta)
}

Expand Down
29 changes: 20 additions & 9 deletions alicloud/resource_alicloud_api_gateway_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestAccAliCloudApiGatewayInstance_basic5800(t *testing.T) {
"instance_name": name + "_update",
"instance_spec": "api.s1.small",
"https_policy": "HTTPS2_TLS1_0",
"zone_id": "cn-hangzhou-MAZ6",
"zone_id": "cn-hangzhou-MAZ6(i,j,k)",
"payment_type": "PayAsYouGo",
"instance_type": "normal",
"egress_ipv6_enable": "true",
Expand All @@ -85,7 +85,7 @@ func TestAccAliCloudApiGatewayInstance_basic5800(t *testing.T) {
"instance_name": name + "_update",
"instance_spec": "api.s1.small",
"https_policy": "HTTPS2_TLS1_0",
"zone_id": "cn-hangzhou-MAZ6",
"zone_id": "cn-hangzhou-MAZ6(i,j,k)",
"payment_type": "PayAsYouGo",
"instance_type": "normal",
"egress_ipv6_enable": "true",
Expand All @@ -94,10 +94,21 @@ func TestAccAliCloudApiGatewayInstance_basic5800(t *testing.T) {
}),
),
},
{
Config: testAccConfig(map[string]interface{}{
"instance_spec": "api.s1.medium",
"skip_wait_switch": "true",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"instance_spec": "api.s1.medium",
}),
),
},
{
ResourceName: resourceId,
ImportState: true,
ImportStateVerify: true,
ImportStateVerify: true, ImportStateVerifyIgnore: []string{"skip_wait_switch"},
},
},
})
Expand Down Expand Up @@ -185,7 +196,7 @@ func TestAccAliCloudApiGatewayInstance_basic5806(t *testing.T) {
"instance_name": name + "_update",
"instance_spec": "api.s1.small",
"https_policy": "HTTPS2_TLS1_0",
"zone_id": "cn-hangzhou-MAZ6",
"zone_id": "cn-hangzhou-MAZ6(i,j,k)",
"payment_type": "Subscription",
"egress_ipv6_enable": "true",
"vpc_slb_intranet_enable": "true",
Expand All @@ -196,7 +207,7 @@ func TestAccAliCloudApiGatewayInstance_basic5806(t *testing.T) {
"instance_name": name + "_update",
"instance_spec": "api.s1.small",
"https_policy": "HTTPS2_TLS1_0",
"zone_id": "cn-hangzhou-MAZ6",
"zone_id": "cn-hangzhou-MAZ6(i,j,k)",
"payment_type": "Subscription",
"egress_ipv6_enable": "true",
"vpc_slb_intranet_enable": "true",
Expand Down Expand Up @@ -256,7 +267,7 @@ func TestAccAliCloudApiGatewayInstance_basic5800_twin(t *testing.T) {
"instance_name": name,
"instance_spec": "api.s1.small",
"https_policy": "HTTPS2_TLS1_2",
"zone_id": "cn-hangzhou-MAZ6",
"zone_id": "cn-hangzhou-MAZ6(i,j,k)",
"payment_type": "PayAsYouGo",
"instance_type": "normal",
"egress_ipv6_enable": "false",
Expand All @@ -267,7 +278,7 @@ func TestAccAliCloudApiGatewayInstance_basic5800_twin(t *testing.T) {
"instance_name": name,
"instance_spec": "api.s1.small",
"https_policy": "HTTPS2_TLS1_2",
"zone_id": "cn-hangzhou-MAZ6",
"zone_id": "cn-hangzhou-MAZ6(i,j,k)",
"payment_type": "PayAsYouGo",
"instance_type": "normal",
"egress_ipv6_enable": "false",
Expand Down Expand Up @@ -311,7 +322,7 @@ func TestAccAliCloudApiGatewayInstance_basic5806_twin(t *testing.T) {
"instance_name": name,
"instance_spec": "api.s1.small",
"https_policy": "HTTPS2_TLS1_2",
"zone_id": "cn-hangzhou-MAZ6",
"zone_id": "cn-hangzhou-MAZ6(i,j,k)",
"payment_type": "Subscription",
"pricing_cycle": "month",
"duration": "1",
Expand All @@ -323,7 +334,7 @@ func TestAccAliCloudApiGatewayInstance_basic5806_twin(t *testing.T) {
"instance_name": name,
"instance_spec": "api.s1.small",
"https_policy": "HTTPS2_TLS1_2",
"zone_id": "cn-hangzhou-MAZ6",
"zone_id": "cn-hangzhou-MAZ6(i,j,k)",
"payment_type": "Subscription",
"pricing_cycle": "month",
"duration": "1",
Expand Down
7 changes: 4 additions & 3 deletions website/docs/r/api_gateway_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ resource "alicloud_api_gateway_instance" "default" {

instance_spec = "api.s1.small"
https_policy = "HTTPS2_TLS1_0"
zone_id = "cn-hangzhou-MAZ6"
zone_id = "cn-hangzhou-MAZ6(i,j,k)"
payment_type = "PayAsYouGo"
instance_type = "normal"
}
Expand Down Expand Up @@ -80,8 +80,8 @@ resource "alicloud_vswitch" "vswitch_2" {
}

resource "alicloud_security_group" "security_group" {
vpc_id = alicloud_vpc.vpc.id
name = var.name
vpc_id = alicloud_vpc.vpc.id
security_group_name = var.name
}

resource "alicloud_api_gateway_instance" "vpc_integration_instance" {
Expand Down Expand Up @@ -136,6 +136,7 @@ When the value of> ChargeType is **PrePaid**, this parameter is available and mu
* `zone_vswitch_security_group` - (Optional, ForceNew, Available since v1.228.0) Network configuration details for Vpc integration instance which includes the availability zone, VSwitch, and security group information. See [`zone_vswitch_security_group`](#zone_vswitch_security_group) below.
* `to_connect_vpc_ip_block` - (Optional, Available since v1.228.0) The additional IP block that the VPC integration instance can access, conflict with `delete_vpc_ip_block`. See [`to_connect_vpc_ip_block`](#to_connect_vpc_ip_block) below.
* `delete_vpc_ip_block` - (Optional, Available since v1.228.0) Indicates whether to delete the IP block that the VPC can access, conflict with `to_connect_vpc_ip_block`.
* `skip_wait_switch` - (Optional, Available since v1.244.0) Specifies whether to skip the WAIT_SWITCH status of instance when modifying instance spec. Works only when instance spec change.

### `zone_vswitch_security_group`

Expand Down
Loading