Skip to content

fix(rabbitmq): [122064401] add postpaid rabbitmq #3158

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

Merged
merged 2 commits into from
Feb 25, 2025
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/3158.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_tdmq_rabbitmq_vip_instance: Add `pay_mode`, `cluster_version`, `public_access_endpoint` and `vpcs`
```
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,52 @@ func ResourceTencentCloudTdmqRabbitmqVipInstance() *schema.Resource {
Type: schema.TypeInt,
Description: "Purchase duration, the default is 1 (month).",
},
"pay_mode": {
Optional: true,
Type: schema.TypeInt,
Computed: true,
Description: "Payment method: 0 indicates postpaid; 1 indicates prepaid. Default: prepaid.",
},
"cluster_version": {
Optional: true,
Type: schema.TypeString,
Computed: true,
Description: "Cluster version, the default is `3.8.30`, valid values: `3.8.30` and `3.11.8`.",
},
"public_access_endpoint": {
Type: schema.TypeString,
Computed: true,
Description: "Public Network Access Point.",
},
"vpcs": {
Type: schema.TypeList,
Computed: true,
Description: "List of VPC Access Points.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpc_id": {
Type: schema.TypeString,
Computed: true,
Description: "VPC ID.",
},
"subnet_id": {
Type: schema.TypeString,
Computed: true,
Description: "Subnet ID.",
},
"vpc_endpoint": {
Type: schema.TypeString,
Computed: true,
Description: "VPC Endpoint.",
},
"vpc_data_stream_endpoint_status": {
Type: schema.TypeString,
Computed: true,
Description: "Status Of Vpc Endpoint.",
},
},
},
},
},
}
}
Expand Down Expand Up @@ -137,6 +183,14 @@ func resourceTencentCloudTdmqRabbitmqVipInstanceCreate(d *schema.ResourceData, m
request.TimeSpan = helper.IntInt64(v.(int))
}

if v, ok := d.GetOkExists("pay_mode"); ok {
request.PayMode = helper.IntUint64(v.(int))
}

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

err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTdmqClient().CreateRabbitMQVipInstance(request)
if e != nil {
Expand Down Expand Up @@ -179,7 +233,7 @@ func resourceTencentCloudTdmqRabbitmqVipInstanceCreate(d *schema.ResourceData, m
}

if *result[0].Status == svctdmq.RabbitMQVipInstanceRunning {
return resource.RetryableError(fmt.Errorf("rabbitmq_vip_instance status is running"))
return resource.RetryableError(fmt.Errorf("rabbitmq_vip_instance status is creating"))
} else if *result[0].Status == svctdmq.RabbitMQVipInstanceSuccess {
return nil
} else {
Expand Down Expand Up @@ -236,6 +290,14 @@ func resourceTencentCloudTdmqRabbitmqVipInstanceRead(d *schema.ResourceData, met
_ = d.Set("storage_size", rabbitmqVipInstance.ClusterSpecInfo.MaxStorage)
}

if rabbitmqVipInstance.ClusterInfo.PayMode != nil {
_ = d.Set("pay_mode", rabbitmqVipInstance.ClusterInfo.PayMode)
}

if rabbitmqVipInstance.ClusterInfo.ClusterVersion != nil {
_ = d.Set("cluster_version", rabbitmqVipInstance.ClusterInfo.ClusterVersion)
}

paramMap := make(map[string]interface{})
tmpSet := make([]*tdmq.Filter, 0)
filter := tdmq.Filter{}
Expand Down Expand Up @@ -263,7 +325,31 @@ func resourceTencentCloudTdmqRabbitmqVipInstanceRead(d *schema.ResourceData, met
} else {
_ = d.Set("auto_renew_flag", false)
}
}

if result[0].PublicAccessEndpoint != nil {
_ = d.Set("public_access_endpoint", result[0].PublicAccessEndpoint)
}

if result[0].Vpcs != nil {
tmpList := make([]map[string]interface{}, 0, len(result[0].Vpcs))
for _, vpc := range result[0].Vpcs {
vpcMap := map[string]interface{}{}
if vpc.VpcId != nil {
vpcMap["vpc_id"] = vpc.VpcId
}
if vpc.SubnetId != nil {
vpcMap["subnet_id"] = vpc.SubnetId
}
if vpc.VpcEndpoint != nil {
vpcMap["vpc_endpoint"] = vpc.VpcEndpoint
}
if vpc.VpcDataStreamEndpointStatus != nil {
vpcMap["vpc_data_stream_endpoint_status"] = vpc.VpcDataStreamEndpointStatus
}
tmpList = append(tmpList, vpcMap)
}
_ = d.Set("vpcs", tmpList)
}

return nil
Expand All @@ -288,7 +374,11 @@ func resourceTencentCloudTdmqRabbitmqVipInstanceUpdate(d *schema.ResourceData, m
instanceId = d.Id()
)

immutableArgs := []string{"zone_ids", "vpc_id", "subnet_id", "node_spec", "node_num", "storage_size", "enable_create_default_ha_mirror_queue", "auto_renew_flag", "time_span"}
immutableArgs := []string{
"zone_ids", "vpc_id", "subnet_id", "node_spec", "node_num",
"storage_size", "enable_create_default_ha_mirror_queue",
"auto_renew_flag", "time_span", "pay_mode", "cluster_version",
}

for _, v := range immutableArgs {
if d.HasChange(v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ resource "tencentcloud_tdmq_rabbitmq_vip_instance" "example" {
auto_renew_flag = true
time_span = 1
}

# create postpaid rabbitmq instance
resource "tencentcloud_tdmq_rabbitmq_vip_instance" "example2" {
zone_ids = [data.tencentcloud_availability_zones.zones.zones.0.id]
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
cluster_name = "tf-example-rabbitmq-vip-instance"
node_spec = "rabbit-vip-basic-1"
node_num = 1
storage_size = 200
enable_create_default_ha_mirror_queue = false
auto_renew_flag = true
time_span = 1
pay_mode = 0
cluster_version = "3.11.8"
}
```

Import
Expand Down
25 changes: 24 additions & 1 deletion website/docs/r/tdmq_rabbitmq_vip_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ resource "tencentcloud_tdmq_rabbitmq_vip_instance" "example" {
auto_renew_flag = true
time_span = 1
}

# create postpaid rabbitmq instance
resource "tencentcloud_tdmq_rabbitmq_vip_instance" "example2" {
zone_ids = [data.tencentcloud_availability_zones.zones.zones.0.id]
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
cluster_name = "tf-example-rabbitmq-vip-instance"
node_spec = "rabbit-vip-basic-1"
node_num = 1
storage_size = 200
enable_create_default_ha_mirror_queue = false
auto_renew_flag = true
time_span = 1
pay_mode = 0
cluster_version = "3.11.8"
}
```

## Argument Reference
Expand All @@ -57,9 +73,11 @@ The following arguments are supported:
* `vpc_id` - (Required, String) Private network VpcId.
* `zone_ids` - (Required, Set: [`Int`]) availability zone.
* `auto_renew_flag` - (Optional, Bool) Automatic renewal, the default is true.
* `cluster_version` - (Optional, String) Cluster version, the default is `3.8.30`, valid values: `3.8.30` and `3.11.8`.
* `enable_create_default_ha_mirror_queue` - (Optional, Bool) Mirrored queue, the default is false.
* `node_num` - (Optional, Int) The number of nodes, a minimum of 3 nodes for a multi-availability zone. If not passed, the default single availability zone is 1, and the multi-availability zone is 3.
* `node_spec` - (Optional, String) Node specifications. Valid values: rabbit-vip-basic-5 (for 2C4G), rabbit-vip-profession-2c8g (for 2C8G), rabbit-vip-basic-1 (for 4C8G), rabbit-vip-profession-4c16g (for 4C16G), rabbit-vip-basic-2 (for 8C16G), rabbit-vip-profession-8c32g (for 8C32G), rabbit-vip-basic-4 (for 16C32G), rabbit-vip-profession-16c64g (for 16C64G). The default is rabbit-vip-basic-1. NOTE: The above specifications may be sold out or removed from the shelves.
* `pay_mode` - (Optional, Int) Payment method: 0 indicates postpaid; 1 indicates prepaid. Default: prepaid.
* `storage_size` - (Optional, Int) Single node storage specification, the default is 200G.
* `time_span` - (Optional, Int) Purchase duration, the default is 1 (month).

Expand All @@ -68,7 +86,12 @@ The following arguments are supported:
In addition to all arguments above, the following attributes are exported:

* `id` - ID of the resource.

* `public_access_endpoint` - Public Network Access Point.
* `vpcs` - List of VPC Access Points.
* `subnet_id` - Subnet ID.
* `vpc_data_stream_endpoint_status` - Status Of Vpc Endpoint.
* `vpc_endpoint` - VPC Endpoint.
* `vpc_id` - VPC ID.


## Import
Expand Down
Loading