Skip to content

Commit dfe3396

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents c706879 + 4171c7f commit dfe3396

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3454
-289
lines changed

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 1.43.0 (Unreleased)
1+
## 1.44.0 (Unreleased)
22

33
FEATURES:
44

@@ -7,10 +7,19 @@ FEATURES:
77
* **New Data Source**: `tencentcloud_cynosdb_clusters`
88
* **New Data Source**: `tencentcloud_cynosdb_readonly_instances`.
99

10-
## 1.42.3 (Unreleased)
10+
## 1.43.0 (September 18, 2020)
11+
12+
FEATURES:
13+
14+
* **New Resource**: `tencentcloud_image`
15+
* **New Resource**: `tencentcloud_audit`
16+
* **New Data Source**: `tencentcloud_audits`
17+
* **New Data Source**: `tencentcloud_audit_cos_regions`
18+
* **New Data Source**: `tencentcloud_audit_key_alias`
1119

1220
ENHANCEMENTS:
1321

22+
* Resource: `tencentcloud_instance` add new argument `data_disk_snapshot_id` to support data disk with `SnapshotId`([#469](https://github.com/tencentcloudstack/terraform-provider-tencentcloud/issues/469))
1423
* Data Source: `tencentcloud_instances` support filter by tags.
1524

1625
## 1.42.2 (September 14, 2020)
@@ -21,6 +30,7 @@ BUG FIXES:
2130
## 1.42.1 (September 10, 2020)
2231

2332
BUG FIXES:
33+
2434
* Resource: `tencentcloud_mongodb_instance` Fix the error of releasing associated resources when destroying mongodb postpaid instance.
2535
* Resource: `tencentcloud_mongodb_sharding_instance` Fix the error of releasing associated resources when destroying mongodb postpaid sharding instance.
2636
* Resource: `tencentcloud_mongodb_standby_instance` Fix the error of releasing associated resources when destroying mongodb postpaid standby instance.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
data "tencentcloud_audit_cos_regions" "example" {
2+
}
3+
4+
data "tencentcloud_audits" "example" {
5+
}
6+
7+
data "tencentcloud_audit_key_alias" "example" {
8+
region = "ap-hongkong"
9+
}
10+
11+
resource "tencentcloud_audit" "example_kms" {
12+
name = "example_kms"
13+
cos_bucket = "test"
14+
cos_region = "ap-hongkong"
15+
enable_kms_encry = true
16+
log_file_prefix = "exampleprefix"
17+
key_id = data.tencentcloud_audit_key_alias.example.audit_key_alias_list.0.key_id
18+
audit_switch = true
19+
read_write_attribute = 3
20+
}
21+
22+
data "tencentcloud_audits" "name_example" {
23+
name = "example_kms"
24+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform {
2+
required_version = ">= 0.12"
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
provider "tencentcloud" {
2+
region = "ap-guangzhou"
3+
}
4+
5+
resource "tencentcloud_image" "image_instance" {
6+
image_name = var.image_imstance_name
7+
instance_id = "ins-2ju245xg"
8+
data_disk_ids = ["disk-gii0vtwi"]
9+
force_poweroff = true
10+
sysprep = false
11+
image_description = "create image with instance"
12+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
variable "image_imstance_name" {
2+
default = "image-instance-keep"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform {
2+
required_version = ">= 0.12"
3+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/mattn/go-colorable v0.1.6 // indirect
1616
github.com/mitchellh/go-homedir v1.1.0
1717
github.com/pkg/errors v0.9.1
18-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.19
18+
github.com/tencentcloud/tencentcloud-sdk-go v1.0.24
1919
github.com/yangwenmai/ratelimit v0.0.0-20180104140304-44221c2292e1
2020
github.com/zclconf/go-cty v1.4.2 // indirect
2121
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect

go.sum

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -469,17 +469,8 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
469469
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
470470
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 h1:Xr9gkxfOP0KQWXKNqmwe8vEeSUiUj4Rlee9CMVX2ZUQ=
471471
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
472-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.13 h1:0jZzFAkyl5usFYpxfVoFZssgwlCkY2as7kaD9oubZo0=
473-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.13/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
474-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.16 h1:Xz7RGIUzoRgCUUCLlAboeDd5m6awKBnoDDlA62CR4GY=
475-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.16/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
476-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.17 h1:/LMW7FO2ke4J7w+xhdHI/lyS/bc1bx6XwzLHlaCYohA=
477-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.17/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
478-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.19 h1:JUjHBXGADNHDI4etTWdPheNyysFauvDrETlQxdGZyvw=
479-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.19/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
480-
github.com/tencentcloud/tencentcloud-sdk-go v3.0.229+incompatible h1:ZlFfQuJYC+g2bEjlZUvIUQUifHhzWM69GTzFh0qzLl4=
481-
github.com/tencentcloud/tencentcloud-sdk-go v3.0.229+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4=
482-
github.com/tencentcloud/tencentcloud-sdk-go v3.0.233+incompatible h1:q+D/Y9jla3afgsIihtyhwyl0c2W+eRWNM9ohVwPiiPw=
472+
github.com/tencentcloud/tencentcloud-sdk-go v1.0.24 h1:N/2RtegEJHVp+piscvLovjkPGTgUlgI2nN4jQVxtsCg=
473+
github.com/tencentcloud/tencentcloud-sdk-go v1.0.24/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
483474
github.com/tetafro/godot v0.3.7 h1:+mecr7RKrUKB5UQ1gwqEMn13sDKTyDR8KNIquB9mm+8=
484475
github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
485476
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e h1:RumXZ56IrCj4CL+g1b9OL/oH0QnsF976bC8xQFYUD5Q=
@@ -683,16 +674,13 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
683674
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
684675
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
685676
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
686-
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
687677
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
688678
gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
689679
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
690-
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
691680
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
692681
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
693682
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
694683
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
695-
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
696684
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
697685
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
698686
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

tencentcloud/connectivity/client.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
cfs "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cfs/v20190719"
1717
ckafka "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ckafka/v20190819"
1818
clb "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317"
19+
audit "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319"
1920
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
2021
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
2122
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
@@ -71,6 +72,7 @@ type TencentCloudClient struct {
7172
sqlserverConn *sqlserver.Client
7273
postgreConn *postgre.Client
7374
ckafkaConn *ckafka.Client
75+
auditConn *audit.Client
7476
cynosConn *cynosdb.Client
7577
}
7678

@@ -446,6 +448,19 @@ func (me *TencentCloudClient) UseCkafkaClient() *ckafka.Client {
446448
return me.ckafkaConn
447449
}
448450

451+
// UseAuditClient returns audit client for service
452+
func (me *TencentCloudClient) UseAuditClient() *audit.Client {
453+
if me.auditConn != nil {
454+
return me.auditConn
455+
}
456+
457+
cpf := me.NewClientProfile(300)
458+
me.auditConn, _ = audit.NewClient(me.Credential, me.Region, cpf)
459+
me.auditConn.WithHttpTransport(&LogRoundTripper{})
460+
461+
return me.auditConn
462+
}
463+
449464
// UseCynosdbClient returns cynosdb client for service
450465
func (me *TencentCloudClient) UseCynosdbClient() *cynosdb.Client {
451466
if me.cynosConn != nil {
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
Use this data source to query the cos region list supported by the audit.
3+
4+
Example Usage
5+
```hcl
6+
data "tencentcloud_audit_cos_regions" "foo" {
7+
}
8+
```
9+
*/
10+
package tencentcloud
11+
12+
import (
13+
"context"
14+
"log"
15+
16+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
17+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
18+
audit "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319"
19+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
20+
)
21+
22+
func dataSourceTencentCloudAuditCosRegions() *schema.Resource {
23+
return &schema.Resource{
24+
Read: dataSourceTencentCloudAuditCosRegionsRead,
25+
26+
Schema: map[string]*schema.Schema{
27+
"result_output_file": {
28+
Type: schema.TypeString,
29+
Optional: true,
30+
Description: "Used to save results.",
31+
},
32+
"audit_cos_region_list": {
33+
Type: schema.TypeList,
34+
Computed: true,
35+
Description: "List of available regions supported by audit cos.",
36+
Elem: &schema.Resource{
37+
Schema: map[string]*schema.Schema{
38+
"cos_region": {
39+
Type: schema.TypeString,
40+
Computed: true,
41+
Description: "Cos region.",
42+
},
43+
"cos_region_name": {
44+
Type: schema.TypeString,
45+
Computed: true,
46+
Description: "Cos region chinese name.",
47+
},
48+
},
49+
},
50+
},
51+
},
52+
}
53+
}
54+
55+
func dataSourceTencentCloudAuditCosRegionsRead(d *schema.ResourceData, meta interface{}) error {
56+
defer logElapsed("data_source.tencentcloud_audit_cos_regions.read")()
57+
58+
logId := getLogId(contextNil)
59+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
60+
auditService := AuditService{
61+
client: meta.(*TencentCloudClient).apiV3Conn,
62+
}
63+
64+
var regions []*audit.CosRegionInfo
65+
var errRet error
66+
err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
67+
regions, errRet = auditService.DescribeAuditCosRegions(ctx)
68+
if errRet != nil {
69+
return retryError(errRet, InternalError)
70+
}
71+
return nil
72+
})
73+
if err != nil {
74+
return err
75+
}
76+
77+
regionList := make([]map[string]interface{}, 0, len(regions))
78+
ids := make([]string, 0, len(regions))
79+
for _, region := range regions {
80+
mapping := map[string]interface{}{
81+
"cos_region": region.CosRegion,
82+
"cos_region_name": region.CosRegionName,
83+
}
84+
regionList = append(regionList, mapping)
85+
ids = append(ids, *region.CosRegion)
86+
}
87+
d.SetId(helper.DataResourceIdsHash(ids))
88+
err = d.Set("audit_cos_region_list", regionList)
89+
if err != nil {
90+
log.Printf("[CRITAL]%s audit cos read regions list fail, reason:%s\n ", logId, err.Error())
91+
return err
92+
}
93+
94+
output, ok := d.GetOk("result_output_file")
95+
if ok && output.(string) != "" {
96+
if e := writeToFile(output.(string), regionList); e != nil {
97+
return e
98+
}
99+
}
100+
return nil
101+
}

0 commit comments

Comments
 (0)