Skip to content

Commit 0050121

Browse files
committed
add tag with resource datasource NAT POSTGRE and add cos_bucket_url with COS
1 parent 04e557e commit 0050121

20 files changed

+189
-5
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
## 1.45.4 (Unreleased)
2+
3+
ENHANCEMENTS:
4+
5+
* Resource: `tencentcloud_cos_bucket` add new argument `cos_bucket_url`.
6+
* Resource: `tencentcloud_nat_gateway` add new argument `tags`.
7+
* Resource: `tencentcloud_postgresql_instance` add new argument `tags`.
8+
* Data Source: `tencentcloud_cos_buckets` add new argument `cos_bucket_url`.
9+
* Data Source: `tencentcloud_nat_gateways` add new argument `tags`.
10+
* Data Source: `tencentcloud_postgresql_instances` add new argument `tags`.
11+
212
## 1.45.3 (October 21, 2020)
313

414
BUG FIXES:

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,6 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
458458
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
459459
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 h1:Xr9gkxfOP0KQWXKNqmwe8vEeSUiUj4Rlee9CMVX2ZUQ=
460460
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
461-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.25 h1:tLExcllerEwYTIx/58PA9r5v69uPfpc2yf6DLtDggTo=
462-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.25/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
463461
github.com/tencentcloud/tencentcloud-sdk-go v1.0.37 h1:zNJfC6+5sj/OloSq6GzmdSC9lwlZbgQ438zz3qH+v4k=
464462
github.com/tencentcloud/tencentcloud-sdk-go v1.0.37/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
465463
github.com/tetafro/godot v0.3.7 h1:+mecr7RKrUKB5UQ1gwqEMn13sDKTyDR8KNIquB9mm+8=

tencentcloud/data_source_tc_cos_buckets.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ func dataSourceTencentCloudCosBuckets() *schema.Resource {
173173
Computed: true,
174174
Description: "The tags of a bucket.",
175175
},
176+
"cos_bucket_url": {
177+
Type: schema.TypeString,
178+
Computed: true,
179+
Description: "The URL of this cos bucket.",
180+
},
176181
},
177182
},
178183
},
@@ -234,7 +239,7 @@ LOOP:
234239
}
235240

236241
bucket["tags"] = respTags
237-
242+
bucket["cos_bucket_url"] = fmt.Sprintf("%s.cos.%s.myqcloud.com", *v.Name, meta.(*TencentCloudClient).apiV3Conn.Region)
238243
bucketList = append(bucketList, bucket)
239244
}
240245

tencentcloud/data_source_tc_cos_buckets_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func TestAccTencentCloudCosBucketDataSource_basic(t *testing.T) {
2424
resource.TestCheckResourceAttr("data.tencentcloud_cos_buckets.bucket_list", "bucket_list.0.cors_rules.#", "0"),
2525
resource.TestCheckResourceAttr("data.tencentcloud_cos_buckets.bucket_list", "bucket_list.0.lifecycle_rules.#", "0"),
2626
resource.TestCheckResourceAttr("data.tencentcloud_cos_buckets.bucket_list", "bucket_list.0.website.#", "0"),
27+
resource.TestCheckResourceAttrSet("data.tencentcloud_cos_buckets.bucket_list", "bucket_list.0.cos_bucket_url"),
2728
),
2829
},
2930
},

tencentcloud/data_source_tc_nat_gateways.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ func dataSourceTencentCloudNatGateways() *schema.Resource {
9696
Computed: true,
9797
Description: "Create time of the NAT gateway.",
9898
},
99+
"tags": {
100+
Type: schema.TypeMap,
101+
Computed: true,
102+
Description: "The available tags within this NAT gateway.",
103+
},
99104
},
100105
},
101106
},
@@ -170,6 +175,13 @@ func dataSourceTencentCloudNatGatewaysRead(d *schema.ResourceData, meta interfac
170175
"assigned_eip_set": flattenAddressList((*nat).PublicIpAddressSet),
171176
"create_time": *nat.CreatedTime,
172177
}
178+
if nat.TagSet != nil {
179+
tags := make(map[string]interface{}, len(nat.TagSet))
180+
for _, t := range nat.TagSet {
181+
tags[*t.Key] = *t.Value
182+
}
183+
mapping["tags"] = tags
184+
}
173185
natList = append(natList, mapping)
174186
ids = append(ids, *nat.NatGatewayId)
175187
}

tencentcloud/data_source_tc_nat_gateways_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestAccTencentCloudNatGatewaysDataSource(t *testing.T) {
1818
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateways.multi_nat", "nats.#", "2"),
1919
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateways.multi_nat", "nats.0.name", "terraform_test_nats"),
2020
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateways.multi_nat", "nats.1.bandwidth", "500"),
21+
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateways.multi_nat", "nats.0.tags.tf", "test"),
2122
),
2223
},
2324
},
@@ -44,6 +45,10 @@ resource "tencentcloud_nat_gateway" "dev_nat" {
4445
assigned_eip_set = [
4546
tencentcloud_eip.eip_dev_dnat.public_ip,
4647
]
48+
49+
tags = {
50+
tf = "test"
51+
}
4752
}
4853
resource "tencentcloud_nat_gateway" "test_nat" {
4954
vpc_id = tencentcloud_vpc.main.id

tencentcloud/data_source_tc_postgresql_instances.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ func dataSourceTencentCloudPostgresqlInstances() *schema.Resource {
148148
Computed: true,
149149
Description: "Create time of the postgresql instance.",
150150
},
151+
"tags": {
152+
Type: schema.TypeMap,
153+
Computed: true,
154+
Description: "The available tags within this postgresql.",
155+
},
151156
},
152157
},
153158
},
@@ -185,6 +190,8 @@ func dataSourceTencentCloudPostgresqlInstanceRead(d *schema.ResourceData, meta i
185190

186191
ids := make([]string, 0, len(instanceList))
187192
list := make([]map[string]interface{}, 0, len(instanceList))
193+
tcClient := meta.(*TencentCloudClient).apiV3Conn
194+
tagService := &TagService{client: tcClient}
188195

189196
for _, v := range instanceList {
190197
listItem := make(map[string]interface{})
@@ -222,6 +229,15 @@ func dataSourceTencentCloudPostgresqlInstanceRead(d *schema.ResourceData, meta i
222229
} else {
223230
listItem["charge_type"] = COMMON_PAYTYPE_POSTPAID
224231
}
232+
233+
//the describe list API is delayed with argument `tag`
234+
tagList, err := tagService.DescribeResourceTags(ctx, "postgres", "DBInstanceId", tcClient.Region, *v.DBInstanceId)
235+
if err != nil {
236+
return err
237+
}
238+
239+
listItem["tags"] = tagList
240+
225241
list = append(list, listItem)
226242
ids = append(ids, *v.DBInstanceId)
227243
}

tencentcloud/data_source_tc_postgresql_instances_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func TestAccTencentCloudDataPostgresqlInstances(t *testing.T) {
2121
resource.TestCheckResourceAttr(testDataPostgresqlInstancesName, "instance_list.#", "1"),
2222
resource.TestCheckResourceAttrSet(testDataPostgresqlInstancesName, "instance_list.0.id"),
2323
resource.TestCheckResourceAttrSet(testDataPostgresqlInstancesName, "instance_list.0.create_time"),
24-
resource.TestCheckResourceAttrSet(testDataPostgresqlInstancesName, "instance_list.0.id"),
2524
resource.TestCheckResourceAttr(testDataPostgresqlInstancesName, "instance_list.0.charge_type", "POSTPAID_BY_HOUR"),
2625
resource.TestCheckResourceAttr(testDataPostgresqlInstancesName, "instance_list.0.engine_version", "9.3.5"),
2726
resource.TestCheckResourceAttr(testDataPostgresqlInstancesName, "instance_list.0.project_id", "0"),
@@ -31,6 +30,7 @@ func TestAccTencentCloudDataPostgresqlInstances(t *testing.T) {
3130
resource.TestCheckResourceAttrSet(testDataPostgresqlInstancesName, "instance_list.0.private_access_port"),
3231
resource.TestCheckResourceAttrSet(testDataPostgresqlInstancesName, "instance_list.0.public_access_switch"),
3332
resource.TestCheckResourceAttrSet(testDataPostgresqlInstancesName, "instance_list.0.charset"),
33+
resource.TestCheckResourceAttr(testDataPostgresqlInstancesName, "instance_list.0.tags.tf", "test"),
3434
),
3535
},
3636
},
@@ -52,6 +52,10 @@ charset = "UTF8"
5252
project_id = 0
5353
memory = 2
5454
storage = 10
55+
56+
tags = {
57+
tf = "test"
58+
}
5559
}
5660
5761
data "tencentcloud_postgresql_instances" "id_test"{

tencentcloud/resource_tc_cos_bucket.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ func resourceTencentCloudCosBucket() *schema.Resource {
271271
Optional: true,
272272
Description: "The tags of a bucket.",
273273
},
274+
//computed
275+
"cos_bucket_url": {
276+
Type: schema.TypeString,
277+
Computed: true,
278+
Description: "The URL of this cos bucket.",
279+
},
274280
},
275281
}
276282
}
@@ -323,6 +329,8 @@ func resourceTencentCloudCosBucketRead(d *schema.ResourceData, meta interface{})
323329
}
324330
}
325331

332+
cosBuckeUrl := fmt.Sprintf("%s.cos.%s.myqcloud.com", d.Id(), meta.(*TencentCloudClient).apiV3Conn.Region)
333+
_ = d.Set("cos_bucket_url", cosBuckeUrl)
326334
// set bucket in the import case
327335
if _, ok := d.GetOk("bucket"); !ok {
328336
_ = d.Set("bucket", d.Id())

tencentcloud/resource_tc_cos_bucket_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func TestAccTencentCloudCosBucket_basic(t *testing.T) {
8282
testAccCheckCosBucketExists("tencentcloud_cos_bucket.bucket_basic"),
8383
resource.TestCheckResourceAttr("tencentcloud_cos_bucket.bucket_basic", "encryption_algorithm", "AES256"),
8484
resource.TestCheckResourceAttr("tencentcloud_cos_bucket.bucket_basic", "versioning_enable", "true"),
85+
resource.TestCheckResourceAttrSet("tencentcloud_cos_bucket.bucket_basic", "cos_bucket_url"),
8586
),
8687
},
8788
{

0 commit comments

Comments
 (0)