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

fix(as): [120908769] tencentcloud_as_scaling_config support cdc #2980

Merged
merged 2 commits into from
Nov 29, 2024
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
3 changes: 3 additions & 0 deletions .changelog/2980.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_as_scaling_config: support cdc
```
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/api v1.0.285
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apigateway v1.0.763
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm v1.0.825
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1033
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1050
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam v1.0.760
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cat v1.0.825
Expand All @@ -46,7 +46,7 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1034
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1046
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1046
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1050
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.1014
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm v1.0.825 h1:yiC2lsZ
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm v1.0.825/go.mod h1:6qtSa8OZKwJOWoOCYWVZd6+T62O96AxbPll0I43d4yw=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1033 h1:f39voqCh8s061EQojp1QHZSq+QbjrmOkz4LeVFA47r0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1033/go.mod h1:PzOW1D/Lzd4sUW3xlT+4oXp+6MLCN55J+V/W9q1acro=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1050 h1:uLV7suHZzLYQ7FzzPotAxHp8U2Cyu79Q9+DjHfGBS1o=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1050/go.mod h1:z8L5Brgaqaq9DK0p8wzOB+6alOD/qWABzkCFmitewAE=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824 h1:DVKvZ6h+qd7tadUrCjVAkCCmE3TsbK2ZmwGd3AJcpWc=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824/go.mod h1:DvBpDX/qdJG4KKLeULmRvhAjPYiw8za0HeTSu2y/lFw=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam v1.0.760 h1:Ky9dRsTL2HXKWUrTFpQFZWQ1TrM+o+P35kczR7thalo=
Expand Down Expand Up @@ -938,6 +940,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1045 h1:3vv
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1045/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1046 h1:0FvA5Rw9dGqK5CTbWlgyE1HbiND1hLsoIfne4jzWuRI=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1046/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1050 h1:SnzAe4ntwwrUf0jzgxE5Qm7wH8atRwvaDT+njfNExJ4=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1050/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993 h1:WlPgXldQCxt7qi5Xrc6j6zTrsXWzN5BcOGs7Irq7fwQ=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993/go.mod h1:Z9U8zNtyuyKhjS0698wqsrG/kLx1TQ5CEixXBwVe7xY=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=
Expand Down
22 changes: 21 additions & 1 deletion tencentcloud/services/as/resource_tc_as_scaling_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func ResourceTencentCloudAsScalingConfig() *schema.Resource {
"instance_charge_type": {
Type: schema.TypeString,
Optional: true,
Description: "Charge type of instance. Valid values are `PREPAID`, `POSTPAID_BY_HOUR`, `SPOTPAID`. The default is `POSTPAID_BY_HOUR`. NOTE: `SPOTPAID` instance must set `spot_instance_type` and `spot_max_price` at the same time.",
Description: "Charge type of instance. Valid values are `PREPAID`, `POSTPAID_BY_HOUR`, `SPOTPAID`, `CDCPAID`. The default is `POSTPAID_BY_HOUR`. NOTE: `SPOTPAID` instance must set `spot_instance_type` and `spot_max_price` at the same time.",
},
"instance_charge_type_prepaid_period": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -262,6 +262,11 @@ func ResourceTencentCloudAsScalingConfig() *schema.Resource {
},
},
},
"dedicated_cluster_id": {
Type: schema.TypeString,
Optional: true,
Description: "Dedicated Cluster ID.",
},
// Computed values
"status": {
Type: schema.TypeString,
Expand Down Expand Up @@ -485,6 +490,10 @@ func resourceTencentCloudAsScalingConfigCreate(d *schema.ResourceData, meta inte
request.InstanceNameSettings = settings[0]
}

if v, ok := d.GetOk("dedicated_cluster_id"); ok {
request.DedicatedClusterId = helper.String(v.(string))
}

response, err := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseAsClient().CreateLaunchConfiguration(request)
if err != nil {
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
Expand Down Expand Up @@ -598,6 +607,11 @@ func resourceTencentCloudAsScalingConfigRead(d *schema.ResourceData, meta interf
if config.InstanceChargePrepaid != nil {
_ = d.Set("instance_charge_type_prepaid_renew_flag", config.InstanceChargePrepaid.RenewFlag)
}

if config.DedicatedClusterId != nil {
_ = d.Set("dedicated_cluster_id", config.DedicatedClusterId)
}

return nil
})
if err != nil {
Expand Down Expand Up @@ -854,6 +868,12 @@ func resourceTencentCloudAsScalingConfigUpdate(d *schema.ResourceData, meta inte
}
}

if d.HasChange("dedicated_cluster_id") {
if v, ok := d.GetOk("dedicated_cluster_id"); ok {
request.DedicatedClusterId = helper.String(v.(string))
}
}

response, err := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseAsClient().ModifyLaunchConfigurationAttributes(request)
if err != nil {
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
Expand Down
59 changes: 52 additions & 7 deletions tencentcloud/services/as/resource_tc_as_scaling_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ Provides a resource to create a configuration for an AS (Auto scaling) instance.

Example Usage

Create a normal configuration

```hcl
data "tencentcloud_images" "example" {
image_type = ["PUBLIC_IMAGE"]
os_name = "TencentOS Server 3.2 (Final)"
os_name = "TencentOS Server 4 for x86_64"
}

resource "tencentcloud_as_scaling_config" "example" {
configuration_name = "example-launch-configuration"
configuration_name = "tf-example"
image_id = data.tencentcloud_images.example.images.0.image_id
instance_types = ["SA1.SMALL1"]
instance_types = ["SA5.MEDIUM4"]
project_id = 0
system_disk_type = "CLOUD_PREMIUM"
system_disk_size = "50"
Expand All @@ -33,7 +35,7 @@ resource "tencentcloud_as_scaling_config" "example" {
user_data = "dGVzdA=="

host_name_settings {
host_name = "host-name-test"
host_name = "host-name"
host_name_style = "UNIQUE"
}

Expand All @@ -48,13 +50,13 @@ Using `SPOTPAID` charge type
```hcl
data "tencentcloud_images" "example" {
image_type = ["PUBLIC_IMAGE"]
os_name = "TencentOS Server 3.2 (Final)"
os_name = "TencentOS Server 4 for x86_64"
}

resource "tencentcloud_as_scaling_config" "example" {
configuration_name = "launch-configuration"
configuration_name = "tf-example"
image_id = data.tencentcloud_images.example.images.0.image_id
instance_types = ["SA1.SMALL1"]
instance_types = ["SA5.MEDIUM4"]
instance_charge_type = "SPOTPAID"
spot_instance_type = "one-time"
spot_max_price = "1000"
Expand Down Expand Up @@ -88,6 +90,49 @@ resource "tencentcloud_as_scaling_config" "example" {
}
```

Create a CDC configuration

```hcl
data "tencentcloud_images" "example" {
image_type = ["PUBLIC_IMAGE"]
os_name = "TencentOS Server 4 for x86_64"
}

resource "tencentcloud_as_scaling_config" "example" {
configuration_name = "tf-example"
image_id = data.tencentcloud_images.example.images.0.image_id
instance_types = ["SA5.MEDIUM4"]
project_id = 0
system_disk_type = "CLOUD_PREMIUM"
system_disk_size = "50"
instance_charge_type = "CDCPAID"
dedicated_cluster_id = "cluster-262n63e8"

data_disk {
disk_type = "CLOUD_PREMIUM"
disk_size = 50
}

internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
internet_max_bandwidth_out = 10
public_ip_assigned = true
password = "Test@123#"
enhanced_security_service = false
enhanced_monitor_service = false
enhanced_automation_tools_service = false
user_data = "dGVzdA=="

host_name_settings {
host_name = "host-name"
host_name_style = "UNIQUE"
}

instance_tags = {
tag = "example"
}
}
```

Import

AutoScaling Configuration can be imported using the id, e.g.
Expand Down
Loading
Loading