Skip to content

Commit 80f780d

Browse files
authored
fix(rabbitmq): [122064401] add postpaid rabbitmq (#3158)
* add postpaid rabbitmq * add postpaid rabbitmq
1 parent 0f80143 commit 80f780d

File tree

4 files changed

+135
-3
lines changed

4 files changed

+135
-3
lines changed

.changelog/3158.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_tdmq_rabbitmq_vip_instance: Add `pay_mode`, `cluster_version`, `public_access_endpoint` and `vpcs`
3+
```

tencentcloud/services/trabbit/resource_tc_tdmq_rabbitmq_vip_instance.go

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,52 @@ func ResourceTencentCloudTdmqRabbitmqVipInstance() *schema.Resource {
7676
Type: schema.TypeInt,
7777
Description: "Purchase duration, the default is 1 (month).",
7878
},
79+
"pay_mode": {
80+
Optional: true,
81+
Type: schema.TypeInt,
82+
Computed: true,
83+
Description: "Payment method: 0 indicates postpaid; 1 indicates prepaid. Default: prepaid.",
84+
},
85+
"cluster_version": {
86+
Optional: true,
87+
Type: schema.TypeString,
88+
Computed: true,
89+
Description: "Cluster version, the default is `3.8.30`, valid values: `3.8.30` and `3.11.8`.",
90+
},
91+
"public_access_endpoint": {
92+
Type: schema.TypeString,
93+
Computed: true,
94+
Description: "Public Network Access Point.",
95+
},
96+
"vpcs": {
97+
Type: schema.TypeList,
98+
Computed: true,
99+
Description: "List of VPC Access Points.",
100+
Elem: &schema.Resource{
101+
Schema: map[string]*schema.Schema{
102+
"vpc_id": {
103+
Type: schema.TypeString,
104+
Computed: true,
105+
Description: "VPC ID.",
106+
},
107+
"subnet_id": {
108+
Type: schema.TypeString,
109+
Computed: true,
110+
Description: "Subnet ID.",
111+
},
112+
"vpc_endpoint": {
113+
Type: schema.TypeString,
114+
Computed: true,
115+
Description: "VPC Endpoint.",
116+
},
117+
"vpc_data_stream_endpoint_status": {
118+
Type: schema.TypeString,
119+
Computed: true,
120+
Description: "Status Of Vpc Endpoint.",
121+
},
122+
},
123+
},
124+
},
79125
},
80126
}
81127
}
@@ -137,6 +183,14 @@ func resourceTencentCloudTdmqRabbitmqVipInstanceCreate(d *schema.ResourceData, m
137183
request.TimeSpan = helper.IntInt64(v.(int))
138184
}
139185

186+
if v, ok := d.GetOkExists("pay_mode"); ok {
187+
request.PayMode = helper.IntUint64(v.(int))
188+
}
189+
190+
if v, ok := d.GetOk("cluster_version"); ok {
191+
request.ClusterVersion = helper.String(v.(string))
192+
}
193+
140194
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
141195
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTdmqClient().CreateRabbitMQVipInstance(request)
142196
if e != nil {
@@ -179,7 +233,7 @@ func resourceTencentCloudTdmqRabbitmqVipInstanceCreate(d *schema.ResourceData, m
179233
}
180234

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

293+
if rabbitmqVipInstance.ClusterInfo.PayMode != nil {
294+
_ = d.Set("pay_mode", rabbitmqVipInstance.ClusterInfo.PayMode)
295+
}
296+
297+
if rabbitmqVipInstance.ClusterInfo.ClusterVersion != nil {
298+
_ = d.Set("cluster_version", rabbitmqVipInstance.ClusterInfo.ClusterVersion)
299+
}
300+
239301
paramMap := make(map[string]interface{})
240302
tmpSet := make([]*tdmq.Filter, 0)
241303
filter := tdmq.Filter{}
@@ -263,7 +325,31 @@ func resourceTencentCloudTdmqRabbitmqVipInstanceRead(d *schema.ResourceData, met
263325
} else {
264326
_ = d.Set("auto_renew_flag", false)
265327
}
328+
}
266329

330+
if result[0].PublicAccessEndpoint != nil {
331+
_ = d.Set("public_access_endpoint", result[0].PublicAccessEndpoint)
332+
}
333+
334+
if result[0].Vpcs != nil {
335+
tmpList := make([]map[string]interface{}, 0, len(result[0].Vpcs))
336+
for _, vpc := range result[0].Vpcs {
337+
vpcMap := map[string]interface{}{}
338+
if vpc.VpcId != nil {
339+
vpcMap["vpc_id"] = vpc.VpcId
340+
}
341+
if vpc.SubnetId != nil {
342+
vpcMap["subnet_id"] = vpc.SubnetId
343+
}
344+
if vpc.VpcEndpoint != nil {
345+
vpcMap["vpc_endpoint"] = vpc.VpcEndpoint
346+
}
347+
if vpc.VpcDataStreamEndpointStatus != nil {
348+
vpcMap["vpc_data_stream_endpoint_status"] = vpc.VpcDataStreamEndpointStatus
349+
}
350+
tmpList = append(tmpList, vpcMap)
351+
}
352+
_ = d.Set("vpcs", tmpList)
267353
}
268354

269355
return nil
@@ -288,7 +374,11 @@ func resourceTencentCloudTdmqRabbitmqVipInstanceUpdate(d *schema.ResourceData, m
288374
instanceId = d.Id()
289375
)
290376

291-
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"}
377+
immutableArgs := []string{
378+
"zone_ids", "vpc_id", "subnet_id", "node_spec", "node_num",
379+
"storage_size", "enable_create_default_ha_mirror_queue",
380+
"auto_renew_flag", "time_span", "pay_mode", "cluster_version",
381+
}
292382

293383
for _, v := range immutableArgs {
294384
if d.HasChange(v) {

tencentcloud/services/trabbit/resource_tc_tdmq_rabbitmq_vip_instance.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ resource "tencentcloud_tdmq_rabbitmq_vip_instance" "example" {
3535
auto_renew_flag = true
3636
time_span = 1
3737
}
38+
39+
# create postpaid rabbitmq instance
40+
resource "tencentcloud_tdmq_rabbitmq_vip_instance" "example2" {
41+
zone_ids = [data.tencentcloud_availability_zones.zones.zones.0.id]
42+
vpc_id = tencentcloud_vpc.vpc.id
43+
subnet_id = tencentcloud_subnet.subnet.id
44+
cluster_name = "tf-example-rabbitmq-vip-instance"
45+
node_spec = "rabbit-vip-basic-1"
46+
node_num = 1
47+
storage_size = 200
48+
enable_create_default_ha_mirror_queue = false
49+
auto_renew_flag = true
50+
time_span = 1
51+
pay_mode = 0
52+
cluster_version = "3.11.8"
53+
}
3854
```
3955

4056
Import

website/docs/r/tdmq_rabbitmq_vip_instance.html.markdown

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ resource "tencentcloud_tdmq_rabbitmq_vip_instance" "example" {
4646
auto_renew_flag = true
4747
time_span = 1
4848
}
49+
50+
# create postpaid rabbitmq instance
51+
resource "tencentcloud_tdmq_rabbitmq_vip_instance" "example2" {
52+
zone_ids = [data.tencentcloud_availability_zones.zones.zones.0.id]
53+
vpc_id = tencentcloud_vpc.vpc.id
54+
subnet_id = tencentcloud_subnet.subnet.id
55+
cluster_name = "tf-example-rabbitmq-vip-instance"
56+
node_spec = "rabbit-vip-basic-1"
57+
node_num = 1
58+
storage_size = 200
59+
enable_create_default_ha_mirror_queue = false
60+
auto_renew_flag = true
61+
time_span = 1
62+
pay_mode = 0
63+
cluster_version = "3.11.8"
64+
}
4965
```
5066

5167
## Argument Reference
@@ -57,9 +73,11 @@ The following arguments are supported:
5773
* `vpc_id` - (Required, String) Private network VpcId.
5874
* `zone_ids` - (Required, Set: [`Int`]) availability zone.
5975
* `auto_renew_flag` - (Optional, Bool) Automatic renewal, the default is true.
76+
* `cluster_version` - (Optional, String) Cluster version, the default is `3.8.30`, valid values: `3.8.30` and `3.11.8`.
6077
* `enable_create_default_ha_mirror_queue` - (Optional, Bool) Mirrored queue, the default is false.
6178
* `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.
6279
* `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.
80+
* `pay_mode` - (Optional, Int) Payment method: 0 indicates postpaid; 1 indicates prepaid. Default: prepaid.
6381
* `storage_size` - (Optional, Int) Single node storage specification, the default is 200G.
6482
* `time_span` - (Optional, Int) Purchase duration, the default is 1 (month).
6583

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

7088
* `id` - ID of the resource.
71-
89+
* `public_access_endpoint` - Public Network Access Point.
90+
* `vpcs` - List of VPC Access Points.
91+
* `subnet_id` - Subnet ID.
92+
* `vpc_data_stream_endpoint_status` - Status Of Vpc Endpoint.
93+
* `vpc_endpoint` - VPC Endpoint.
94+
* `vpc_id` - VPC ID.
7295

7396

7497
## Import

0 commit comments

Comments
 (0)