Skip to content

Commit 6b87f29

Browse files
committed
fix conflicts
2 parents 704a74b + bc50aa5 commit 6b87f29

10 files changed

+58
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ FEATURES:
66
* **New Resource**: `tencentcloud_kms_external_key`
77
* **New Data Source**: `tencentcloud_kms_keys`
88

9+
ENHANCEMENTS:
10+
11+
* Resource `tencentcloud_instance` add `cam_role_name` to support binding role to cvm instance.
12+
13+
BUG FIXES:
14+
15+
* Resource `tencentcloud_instance` fix bug that waiting 5 minutes when cloud disk sold out.
16+
* Resource: `tencentcloud_tcr_instance` fix bug that only one tag is effective when setting multiple tags.
17+
918
## 1.53.7 (March 10, 2021)
1019

1120
ENHANCEMENTS:

tencentcloud/data_source_tc_instances.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ func dataSourceTencentCloudInstances() *schema.Resource {
231231
Computed: true,
232232
Description: "The way that CVM instance will be renew automatically or not when it reach the end of the prepaid tenancy.",
233233
},
234+
"cam_role_name": {
235+
Type: schema.TypeString,
236+
Computed: true,
237+
Description: "CAM role name authorized to access.",
238+
},
234239
},
235240
},
236241
},
@@ -311,6 +316,7 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
311316
"create_time": instance.CreatedTime,
312317
"expired_time": instance.ExpiredTime,
313318
"instance_charge_type_prepaid_renew_flag": instance.RenewFlag,
319+
"cam_role_name": instance.CamRoleName,
314320
}
315321
if len(instance.PublicIpAddresses) > 0 {
316322
mapping["public_ip"] = *instance.PublicIpAddresses[0]

tencentcloud/extension_cvm.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const (
4848
CVM_IMAGE_LOGIN = "TRUE"
4949
CVM_IMAGE_LOGIN_NOT = "FALSE"
5050

51-
CVM_ZONE_NOT_SUPPORT_ERROR = "InvalidParameterValue.ZoneNotSupported"
51+
CVM_ZONE_NOT_SUPPORT_ERROR = "InvalidParameterValue.ZoneNotSupported"
52+
CVM_CLOUD_DISK_SOLD_OUT_ERROR = "ResourceInsufficient.CloudDiskSoldOut"
5253
)
5354

5455
var CVM_CHARGE_TYPE = []string{

tencentcloud/resource_tc_instance.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ resource "tencentcloud_instance" "my_awesome_app" {
5353
subnet_id = tencentcloud_subnet.app.id
5454
internet_max_bandwidth_out = 20
5555
count = 2
56+
cam_role_name = "CVM_QcsRole"
5657
5758
data_disks {
5859
data_disk_type = "CLOUD_PREMIUM"
@@ -87,6 +88,7 @@ import (
8788
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
8889
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
8990
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
91+
sdkErrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
9092
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
9193
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
9294
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/ratelimit"
@@ -383,6 +385,13 @@ func resourceTencentCloudInstance() *schema.Resource {
383385
Default: false,
384386
Description: "Indicate whether to force delete the instance. Default is `false`. If set true, the instance will be permanently deleted instead of being moved into the recycle bin. Note: only works for `PREPAID` instance.",
385387
},
388+
// role
389+
"cam_role_name": {
390+
Type: schema.TypeString,
391+
ForceNew: true,
392+
Optional: true,
393+
Description: "CAM role name authorized to access.",
394+
},
386395
// Computed values.
387396
"instance_status": {
388397
Type: schema.TypeString,
@@ -434,6 +443,9 @@ func resourceTencentCloudInstanceCreate(d *schema.ResourceData, meta interface{}
434443
if v, ok := d.GetOk("hostname"); ok {
435444
request.HostName = helper.String(v.(string))
436445
}
446+
if v, ok := d.GetOk("cam_role_name"); ok {
447+
request.CamRoleName = helper.String(v.(string))
448+
}
437449

438450
if v, ok := d.GetOk("instance_charge_type"); ok {
439451
instanceChargeType := v.(string)
@@ -599,6 +611,10 @@ func resourceTencentCloudInstanceCreate(d *schema.ResourceData, meta interface{}
599611
if err != nil {
600612
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
601613
logId, request.GetAction(), request.ToJsonString(), err.Error())
614+
e, ok := err.(*sdkErrors.TencentCloudSDKError)
615+
if ok && e.Code == CVM_CLOUD_DISK_SOLD_OUT_ERROR {
616+
return resource.NonRetryableError(e)
617+
}
602618
return retryError(err)
603619
}
604620
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
@@ -775,6 +791,7 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
775791
_ = d.Set("instance_status", instance.InstanceState)
776792
_ = d.Set("create_time", instance.CreatedTime)
777793
_ = d.Set("expired_time", instance.ExpiredTime)
794+
_ = d.Set("cam_role_name", instance.CamRoleName)
778795

779796
if _, ok := d.GetOkExists("allocate_public_ip"); !ok {
780797
_ = d.Set("allocate_public_ip", len(instance.PublicIpAddresses) > 0)

tencentcloud/resource_tc_kubernetes_cluster.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,10 @@ func tkeGetCvmRunInstancesPara(dMap map[string]interface{}, meta interface{},
10781078
request.InstanceCount = &count
10791079

10801080
if v, ok := dMap["hostname"]; ok {
1081-
request.HostName = helper.String(v.(string))
1081+
hostname := v.(string)
1082+
if hostname != "" {
1083+
request.HostName = &hostname
1084+
}
10821085
}
10831086

10841087
cvmJson = request.ToJsonString()

tencentcloud/resource_tc_postgresql_instance.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ func resourceTencentCloudPostgresqlInstanceCreate(d *schema.ResourceData, meta i
278278
return outErr
279279
}
280280
//check init status
281-
281+
checkErr := postgresqlService.CheckDBInstanceStatus(ctx, instanceId)
282+
if checkErr != nil {
283+
return checkErr
284+
}
282285
//set open public access
283286
public_access_switch := false
284287
if v, ok := d.GetOkExists("public_access_switch"); ok {
@@ -298,6 +301,11 @@ func resourceTencentCloudPostgresqlInstanceCreate(d *schema.ResourceData, meta i
298301
}
299302
}
300303

304+
//check creation done
305+
checkErr = postgresqlService.CheckDBInstanceStatus(ctx, instanceId)
306+
if checkErr != nil {
307+
return checkErr
308+
}
301309
//set name
302310
outErr = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
303311
inErr := postgresqlService.ModifyPostgresqlInstanceName(ctx, instanceId, name)
@@ -311,7 +319,7 @@ func resourceTencentCloudPostgresqlInstanceCreate(d *schema.ResourceData, meta i
311319
}
312320

313321
//check creation done
314-
checkErr := postgresqlService.CheckDBInstanceStatus(ctx, instanceId)
322+
checkErr = postgresqlService.CheckDBInstanceStatus(ctx, instanceId)
315323
if checkErr != nil {
316324
return checkErr
317325
}
@@ -483,6 +491,10 @@ func resourceTencentCloudPostgresqlInstanceRead(d *schema.ResourceData, meta int
483491
outErr = resource.Retry(readRetryTimeout, func() *resource.RetryError {
484492
instance, has, inErr = postgresqlService.DescribePostgresqlInstanceById(ctx, d.Id())
485493
if inErr != nil {
494+
ee, ok := inErr.(*sdkErrors.TencentCloudSDKError)
495+
if ok && ee.GetCode() == "ResourceNotFound.InstanceNotFoundError" {
496+
return nil
497+
}
486498
return retryError(inErr)
487499
}
488500
return nil

tencentcloud/service_tencentcloud_postgresql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func (me *PostgresqlService) DescribePostgresqlInstanceById(ctx context.Context,
227227
errRet = err
228228
return
229229
}
230-
if ee.Code == "InvalidParameter" {
230+
if ee.Code == "InvalidParameter" || ee.Code == "ResourceNotFound.InstanceNotFoundError" {
231231
errRet = nil
232232
} else {
233233
errRet = err

tencentcloud/service_tencentcloud_tcr.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ func (me *TCRService) CreateTCRInstance(ctx context.Context, name string, instan
3030
if len(tags) > 0 {
3131
tagSpec := tcr.TagSpecification{ResourceType: helper.String("instance"), Tags: make([]*tcr.Tag, 0)}
3232
for k, v := range tags {
33-
tag := tcr.Tag{Value: &v, Key: &k}
33+
key, value := k, v
34+
tag := tcr.Tag{Value: &value, Key: &key}
3435
tagSpec.Tags = append(tagSpec.Tags, &tag)
3536
}
3637
request.TagSpecification = &tagSpec

website/docs/d/instances.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ In addition to all arguments above, the following attributes are exported:
3939
* `instance_list` - An information list of cvm instance. Each element contains the following attributes:
4040
* `allocate_public_ip` - Indicates whether public ip is assigned.
4141
* `availability_zone` - The available zone that the CVM instance locates at.
42+
* `cam_role_name` - CAM role name authorized to access.
4243
* `cpu` - The number of CPU cores of the instance.
4344
* `create_time` - Creation time of the instance.
4445
* `data_disks` - An information list of data disk. Each element contains the following attributes:

website/docs/r/instance.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ resource "tencentcloud_instance" "my_awesome_app" {
6363
subnet_id = tencentcloud_subnet.app.id
6464
internet_max_bandwidth_out = 20
6565
count = 2
66+
cam_role_name = "CVM_QcsRole"
6667
6768
data_disks {
6869
data_disk_type = "CLOUD_PREMIUM"
@@ -83,6 +84,7 @@ The following arguments are supported:
8384
* `availability_zone` - (Required, ForceNew) The available zone for the CVM instance.
8485
* `image_id` - (Required, ForceNew) The image to use for the instance. Changing `image_id` will cause the instance to be destroyed and re-created.
8586
* `allocate_public_ip` - (Optional, ForceNew) Associate a public IP address with an instance in a VPC or Classic. Boolean value, Default is false.
87+
* `cam_role_name` - (Optional, ForceNew) CAM role name authorized to access.
8688
* `data_disks` - (Optional, ForceNew) Settings for data disks.
8789
* `disable_monitor_service` - (Optional) Disable enhance service for monitor, it is enabled by default. When this options is set, monitor agent won't be installed.
8890
* `disable_security_service` - (Optional) Disable enhance service for security, it is enabled by default. When this options is set, security agent won't be installed.

0 commit comments

Comments
 (0)