Skip to content

Commit c9a2da3

Browse files
authored
Merge pull request #5 from terraform-providers/master
+
2 parents e8f0677 + 048a136 commit c9a2da3

25 files changed

+738
-187
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ FEATURES:
44

55
* **New Data Source**: `tencentcloud_availability_regions`
66

7+
ENHANCEMENTS:
8+
9+
* Data Source: `tencentcloud_redis_instances` add new argument `charge_type` to support prepaid type.
10+
* Resource: `tencentcloud_redis_instance` add new argument `charge_type`, `prepaid_period` and `force_delete` to support prepaid type.
11+
* Resource: `tencentcloud_mysql_instance` add new argument `force_delete` to support soft deletion.
12+
* Resource: `tencentcloud_mysql_readonly_instance` add new argument `force_delete` to support soft deletion.
13+
14+
BUG FIXES:
15+
16+
* Resource: `tencentcloud_instance` fix `allocate_public_ip` inconsistency when eip is attached to the cvm.
17+
18+
DEPRECATED:
19+
* Data Source: `tencentcloud_mysql_instances`: optional argument `pay_type` is no longer supported, replace by `charge_type`.
20+
* Resource: `tencentcloud_mysql_instance`: optional arguments `pay_type` and `period` are no longer supported, replace by `charge_type` and `prepaid_period`.
21+
* Resource: `tencentcloud_mysql_readonly_instance`: optional arguments `pay_type` and `period` are no longer supported, replace by `charge_type` and `prepaid_period`.
22+
723
## 1.35.1 (June 02, 2020)
824

925
ENHANCEMENTS:

examples/tencentcloud-redis/main.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,19 @@ data "tencentcloud_redis_instances" "redis-tags" {
2626
zone = var.availability_zone
2727
tags = tencentcloud_redis_instance.redis_instance_test.tags
2828
}
29+
30+
resource "tencentcloud_redis_instance" "redis_instance_prepaid_test" {
31+
availability_zone = var.availability_zone
32+
type_id = 2
33+
password = "test12345789"
34+
mem_size = 8192
35+
name = "terrform_prepaid_test"
36+
port = 6379
37+
charge_type = "PREPAID"
38+
prepaid_period = 1
39+
force_delete = true
40+
41+
tags = {
42+
"test" = "prepaid test"
43+
}
44+
}

examples/tencentcloud-vpn/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ data "tencentcloud_vpn_connections" "example" {
6464
id = tencentcloud_vpn_connection.example.id
6565
}
6666

67-
# The example below shows how to create a vpng gateway in ccn type if it is needed. Then could be used when creating
67+
# The example below shows how to create a vpn gateway in ccn type if it is needed. Then could be used when creating
6868
# vpn tunnel in the usual way.
6969
resource tencentcloud_vpn_gateway ccn_vpngw_example {
7070
name = "ccn-vpngw-example"

tencentcloud/basic_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,16 @@ resource "tencentcloud_mysql_instance" "default" {
137137
availability_zone = var.availability_zone
138138
}
139139
`
140+
141+
const mysqlInstanceHighPerformancePrepaidTestCase = defaultVpcVariable + `
142+
resource "tencentcloud_mysql_instance" "default" {
143+
mem_size = 1000
144+
volume_size = 50
145+
pay_type = 0
146+
instance_name = var.instance_name
147+
engine_version = "5.7"
148+
root_password = "0153Y474"
149+
availability_zone = var.availability_zone
150+
force_delete = true
151+
}
152+
`

tencentcloud/connectivity/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (me *TencentCloudClient) UseCosClient() *s3.S3 {
9797
resolver := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) {
9898
if service == endpoints.S3ServiceID {
9999
return endpoints.ResolvedEndpoint{
100-
URL: fmt.Sprintf("http://cos.%s.myqcloud.com", region),
100+
URL: fmt.Sprintf("https://cos.%s.myqcloud.com", region),
101101
SigningRegion: region,
102102
}, nil
103103
}

tencentcloud/data_source_tc_mysql_instance.go

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,15 @@ func dataSourceTencentCloudMysqlInstance() *schema.Resource {
5050
"pay_type": {
5151
Type: schema.TypeInt,
5252
Optional: true,
53+
Deprecated: "It has been deprecated from version 1.36.0.",
5354
ValidateFunc: validateAllowedIntValue([]int{0, 1}),
54-
Description: "Pay type of instance, 0: prepay, 1: postpay. NOTES: Only prepay is supported.",
55+
Description: "Pay type of instance, 0: prepay, 1: postpay.",
56+
},
57+
"charge_type": {
58+
Type: schema.TypeString,
59+
Optional: true,
60+
ValidateFunc: validateAllowedStringValue([]string{MYSQL_CHARGE_TYPE_PREPAID, MYSQL_CHARGE_TYPE_POSTPAID}),
61+
Description: "Pay type of instance, valid values are `PREPAID` and `POSTPAID`.",
5562
},
5663
"instance_name": {
5764
Type: schema.TypeString,
@@ -222,7 +229,12 @@ func dataSourceTencentCloudMysqlInstance() *schema.Resource {
222229
"pay_type": {
223230
Type: schema.TypeInt,
224231
Computed: true,
225-
Description: "Pay type of instance, 0: prepay, 1: postpay. NOTES: Only prepay is supported.",
232+
Description: "Pay type of instance, 0: prepaid, 1: postpaid.",
233+
},
234+
"charge_type": {
235+
Type: schema.TypeString,
236+
Computed: true,
237+
Description: "Pay type of instance.",
226238
},
227239
"create_time": {
228240
Type: schema.TypeString,
@@ -295,6 +307,16 @@ func dataSourceTencentCloudMysqlInstanceRead(d *schema.ResourceData, meta interf
295307
payTypeValue := uint64(payType.(int))
296308
request.PayTypes = []*uint64{&payTypeValue}
297309
}
310+
if chargeType, ok := d.GetOk("charge_type"); ok {
311+
var payType int
312+
if chargeType == MYSQL_CHARGE_TYPE_PREPAID {
313+
payType = MysqlPayByMonth
314+
} else {
315+
payType = MysqlPayByUse
316+
}
317+
payTypeValue := uint64(payType)
318+
request.PayTypes = []*uint64{&payTypeValue}
319+
}
298320
if instanceName, ok := d.GetOk("instance_name"); ok {
299321
instanceNameValue := instanceName.(string)
300322
request.InstanceNames = []*string{&instanceNameValue}
@@ -338,41 +360,39 @@ func dataSourceTencentCloudMysqlInstanceRead(d *schema.ResourceData, meta interf
338360
return fmt.Errorf("api[DescribeDBInstances]fail, return %s", err.Error())
339361
}
340362

341-
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
342-
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
343-
344363
instanceDetails := response.Response.Items
345364
instanceList := make([]map[string]interface{}, 0, len(instanceDetails))
346365
ids := make([]string, 0, len(instanceDetails))
347366
for _, item := range instanceDetails {
348367
mapping := map[string]interface{}{
349-
"mysql_id": *item.InstanceId,
350-
"instance_name": *item.InstanceName,
368+
"mysql_id": item.InstanceId,
369+
"instance_name": item.InstanceName,
351370
"instance_role": MYSQL_ROLE_MAP[*item.InstanceType],
352-
"init_flag": *item.InitFlag,
353-
"status": *item.Status,
354-
"zone": *item.Zone,
355-
"auto_renew_flag": *item.AutoRenew,
356-
"engine_version": *item.EngineVersion,
357-
"cpu_core_count": *item.Cpu,
358-
"memory_size": *item.Memory,
359-
"volume_size": *item.Volume,
360-
"internet_status": *item.WanStatus,
361-
"internet_host": *item.WanDomain,
362-
"internet_port": *item.WanPort,
363-
"intranet_ip": *item.Vip,
364-
"intranet_port": *item.Vport,
365-
"project_id": *item.ProjectId,
366-
"vpc_id": *item.UniqVpcId,
367-
"subnet_id": *item.UniqSubnetId,
368-
"slave_sync_mode": *item.ProtectMode,
369-
"device_type": *item.DeviceType,
370-
"pay_type": *item.PayType,
371-
"create_time": *item.CreateTime,
372-
"dead_line_time": *item.DeadlineTime,
371+
"init_flag": item.InitFlag,
372+
"status": item.Status,
373+
"zone": item.Zone,
374+
"auto_renew_flag": item.AutoRenew,
375+
"engine_version": item.EngineVersion,
376+
"cpu_core_count": item.Cpu,
377+
"memory_size": item.Memory,
378+
"volume_size": item.Volume,
379+
"internet_status": item.WanStatus,
380+
"internet_host": item.WanDomain,
381+
"internet_port": item.WanPort,
382+
"intranet_ip": item.Vip,
383+
"intranet_port": item.Vport,
384+
"project_id": item.ProjectId,
385+
"vpc_id": item.UniqVpcId,
386+
"subnet_id": item.UniqSubnetId,
387+
"slave_sync_mode": item.ProtectMode,
388+
"device_type": item.DeviceType,
389+
"pay_type": item.PayType,
390+
"create_time": item.CreateTime,
391+
"dead_line_time": item.DeadlineTime,
392+
"charge_type": MYSQL_CHARGE_TYPE[int(*item.PayType)],
373393
}
374394
if item.MasterInfo != nil {
375-
mapping["master_instance_id"] = *item.MasterInfo.InstanceId
395+
mapping["master_instance_id"] = item.MasterInfo.InstanceId
376396
} else {
377397
mapping["master_instance_id"] = ""
378398
}

tencentcloud/data_source_tc_mysql_instance_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func TestAccTencentCloudMysqlInstanceDataSource(t *testing.T) {
2323
resource.TestCheckResourceAttr("data.tencentcloud_mysql_instance.mysql", "instance_list.0.engine_version", "5.7"),
2424
resource.TestCheckResourceAttrSet("data.tencentcloud_mysql_instance.mysql", "instance_list.0.vpc_id"),
2525
resource.TestCheckResourceAttrSet("data.tencentcloud_mysql_instance.mysql", "instance_list.0.subnet_id"),
26+
resource.TestCheckResourceAttrSet("data.tencentcloud_mysql_instance.mysql", "instance_list.0.auto_renew_flag"),
2627
),
2728
},
2829
},

tencentcloud/data_source_tc_redis_instances.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ func dataSourceTencentRedisInstances() *schema.Resource {
148148
Computed: true,
149149
Description: "Tags of an instance.",
150150
},
151+
// payment
152+
"charge_type": {
153+
Type: schema.TypeString,
154+
Computed: true,
155+
Description: "The charge type of instance. Valid values are `POSTPAID` and `PREPAID`. Default value is `POSTPAID`.",
156+
},
151157
},
152158
},
153159
},
@@ -223,28 +229,23 @@ instanceLoop:
223229
}
224230

225231
var instanceDes = make(map[string]interface{})
226-
227232
instanceDes["redis_id"] = instance.RedisId
228233
instanceDes["name"] = instance.Name
229234
instanceDes["zone"] = instance.Zone
230-
231235
instanceDes["project_id"] = instance.ProjectId
232236
instanceDes["type"] = instance.Type
233237
instanceDes["mem_size"] = instance.MemSize
234-
235238
instanceDes["status"] = instance.Status
236239
instanceDes["vpc_id"] = instance.VpcId
237240
instanceDes["subnet_id"] = instance.SubnetId
238-
239241
instanceDes["ip"] = instance.Ip
240242
instanceDes["port"] = instance.Port
241243
instanceDes["create_time"] = instance.CreateTime
242-
243244
instanceDes["tags"] = instance.Tags
244245
instanceDes["redis_shard_num"] = instance.RedisShardNum
245246
instanceDes["redis_replicas_num"] = instance.RedisReplicasNum
246247
instanceDes["type_id"] = instance.TypeId
247-
248+
instanceDes["charge_type"] = instance.BillingMode
248249
instanceList = append(instanceList, instanceDes)
249250
}
250251

tencentcloud/data_source_tc_redis_instances_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func TestAccTencentCloudRedisInstancesDataSource(t *testing.T) {
2525
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_instances.redis", "instance_list.0.ip"),
2626
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_instances.redis", "instance_list.0.port"),
2727
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_instances.redis", "instance_list.0.create_time"),
28+
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_instances.redis", "instance_list.0.charge_type"),
2829

2930
resource.TestMatchResourceAttr("data.tencentcloud_redis_instances.redis-tags", "instance_list.#", regexp.MustCompile(`^[1-9]\d*$`)),
3031
resource.TestCheckResourceAttrSet("data.tencentcloud_redis_instances.redis-tags", "instance_list.0.name"),

tencentcloud/extension_mysql.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ var (
8787
MysqlPayByUse = 1
8888
)
8989

90+
const (
91+
MYSQL_CHARGE_TYPE_PREPAID = "PREPAID"
92+
MYSQL_CHARGE_TYPE_POSTPAID = "POSTPAID"
93+
)
94+
95+
var MYSQL_CHARGE_TYPE = map[int]string{
96+
MysqlPayByMonth: MYSQL_CHARGE_TYPE_PREPAID,
97+
MysqlPayByUse: MYSQL_CHARGE_TYPE_POSTPAID,
98+
}
99+
90100
const (
91101
MysqlInstanceIdNotFound = "InvalidParameter.InstanceNotFound"
92102
MysqlInstanceIdNotFound2 = "InvalidParameter"

0 commit comments

Comments
 (0)