Skip to content

Commit 38d47ef

Browse files
committed
merge master
2 parents 8968703 + f823ded commit 38d47ef

File tree

58 files changed

+10028
-82
lines changed

Some content is hidden

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

58 files changed

+10028
-82
lines changed

CHANGELOG.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1-
## 1.21.3 (Unreleased)
1+
## 1.22.1 (Unreleased)
2+
BUG FIXES:
3+
* Fixed docs of CAM
4+
5+
## 1.22.0 (November 05, 2019)
6+
7+
FEATURES:
8+
9+
* **New Data Source**: `tencentcloud_cfs_file_systems`
10+
* **New Data Source**: `tencentcloud_cfs_access_groups`
11+
* **New Data Source**: `tencentcloud_cfs_access_rules`
12+
* **New Data Source**: `tencentcloud_scf_functions`
13+
* **New Data Source**: `tencentcloud_scf_namespaces`
14+
* **New Data Source**: `tencentcloud_scf_logs`
15+
* **New Resource**: `tencentcloud_cfs_file_system`
16+
* **New Resource**: `tencentcloud_cfs_access_group`
17+
* **New Resource**: `tencentcloud_cfs_access_rule`
18+
* **New Resource**: `tencentcloud_scf_function`
19+
* **New Resource**: `tencentcloud_scf_namespace`
20+
221
## 1.21.2 (October 29, 2019)
322

423
BUG FIXES:
@@ -53,6 +72,7 @@ BUG FIXES:
5372

5473
* Resource: `tencentcloud_gaap_http_domain` fix sometimes can't enable realserver auth
5574

75+
5676
## 1.20.1 (October 08, 2019)
5777

5878
ENHANCEMENTS:

examples/tencentcloud-cfs/main.tf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
resource "tencentcloud_vpc" "vpc" {
2+
name = "test-cfs-vpc"
3+
cidr_block = "10.2.0.0/16"
4+
}
5+
6+
resource "tencentcloud_subnet" "subnet" {
7+
vpc_id = "${tencentcloud_vpc.vpc.id}"
8+
name = "test-cfs-subnet"
9+
cidr_block = "10.2.11.0/24"
10+
availability_zone = "${var.availability_zone}"
11+
}
12+
13+
resource "tencentcloud_cfs_access_group" "foo" {
14+
name = "test_cfs_access_rule"
15+
}
16+
17+
resource "tencentcloud_cfs_access_rule" "foo" {
18+
access_group_id = "${tencentcloud_cfs_access_group.foo.id}"
19+
auth_client_ip = "10.10.1.0/24"
20+
rw_permission = "RW"
21+
user_permission = "root_squash"
22+
priority = 1
23+
}
24+
25+
resource "tencentcloud_cfs_file_system" "foo" {
26+
name = "test_cfs_file_system"
27+
availability_zone = "${var.availability_zone}"
28+
access_group_id = "${tencentcloud_cfs_access_group.foo.id}"
29+
protocol = "${var.protocol}"
30+
vpc_id = "${tencentcloud_vpc.vpc.id}"
31+
subnet_id = "${tencentcloud_subnet.subnet.id}"
32+
}
33+
34+
data "tencentcloud_cfs_file_systems" "file_systems" {
35+
file_system_id = "${tencentcloud_cfs_file_system.foo.id}"
36+
name = "${tencentcloud_cfs_file_system.foo.name}"
37+
}
38+
39+
data "tencentcloud_cfs_access_rules" "access_rules" {
40+
access_group_id = "${tencentcloud_cfs_access_group.foo.id}"
41+
access_rule_id = "${tencentcloud_cfs_access_rule.foo.id}"
42+
}
43+
44+
data "tencentcloud_cfs_access_groups" "access_groups" {
45+
access_group_id = "${tencentcloud_cfs_access_group.foo.id}"
46+
name = "${tencentcloud_cfs_access_group.foo.name}"
47+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
variable "availability_zone" {
2+
default = "ap-guangzhou-3"
3+
}
4+
5+
variable "protocol" {
6+
default = "NFS"
7+
}

examples/tencentcloud-scf/main.tf

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
resource "tencentcloud_cos_bucket" "foo" {
2+
bucket = "scf-cos1-1258798060"
3+
acl = "public-read"
4+
}
5+
6+
resource "tencentcloud_cos_bucket" "bar" {
7+
bucket = "scf-cos2-1258798060"
8+
acl = "public-read"
9+
}
10+
11+
resource "tencentcloud_cos_bucket_object" "myobject" {
12+
bucket = "${tencentcloud_cos_bucket.foo.bucket}"
13+
key = "/new_object_key.zip"
14+
source = "code.zip"
15+
acl = "public-read"
16+
}
17+
18+
resource "tencentcloud_cam_role" "foo" {
19+
name = "ci-scf-role"
20+
document = "${var.role_document}"
21+
description = "ci-scf-role"
22+
console_login = true
23+
}
24+
25+
resource "tencentcloud_scf_namespace" "foo" {
26+
namespace = "ci-test-scf"
27+
description = "test1"
28+
}
29+
30+
resource "tencentcloud_vpc" "test_vpc" {
31+
name = "Used for testing subnets"
32+
cidr_block = "10.1.0.0/16"
33+
}
34+
35+
resource "tencentcloud_subnet" "test_subnet" {
36+
vpc_id = "${tencentcloud_vpc.test_vpc.id}"
37+
name = "terraform test subnet"
38+
cidr_block = "10.1.1.0/24"
39+
availability_zone = "${var.availability_zone}"
40+
}
41+
42+
resource "tencentcloud_scf_function" "foo" {
43+
name = "ci-test-function"
44+
description = "test"
45+
handler = "main.do_it"
46+
runtime = "Python3.6"
47+
namespace = "${tencentcloud_scf_namespace.foo.id}"
48+
role = "${tencentcloud_cam_role.foo.id}"
49+
vpc_id = "${tencentcloud_vpc.test_vpc.id}"
50+
subnet_id = "${tencentcloud_subnet.test_subnet.id}"
51+
52+
cos_bucket_name = "${tencentcloud_cos_bucket.foo.id}"
53+
cos_object_name = "${tencentcloud_cos_bucket_object.myobject.key}"
54+
cos_bucket_region = "ap-guangzhou"
55+
56+
triggers {
57+
name = "ci-test-fn-api-gw"
58+
type = "timer"
59+
trigger_desc = "*/5 * * * * * *"
60+
}
61+
62+
triggers {
63+
name = "${tencentcloud_cos_bucket.bar.id}"
64+
type = "cos"
65+
trigger_desc = "${var.trigger_desc}"
66+
}
67+
68+
tags = {
69+
"test" = "test"
70+
}
71+
}
72+
73+
data "tencentcloud_scf_functions" "foo" {
74+
name = "${tencentcloud_scf_function.foo.name}"
75+
description = "${tencentcloud_scf_function.foo.description}"
76+
namespace = "${tencentcloud_scf_function.foo.namespace}"
77+
tags = "${tencentcloud_scf_function.foo.tags}"
78+
}
79+
80+
data "tencentcloud_scf_namespaces" "foo" {
81+
namespace = "${tencentcloud_scf_namespace.foo.id}"
82+
description = "${tencentcloud_scf_namespace.foo.description}"
83+
}
84+
85+
data "tencentcloud_scf_logs" "foo" {
86+
function_name = "${tencentcloud_scf_function.foo.name}"
87+
namespace = "${tencentcloud_scf_function.foo.namespace}"
88+
offset = 0
89+
limit = 100
90+
order = "desc"
91+
order_by = "duration"
92+
ret_code = "UserCodeException"
93+
start_time = "2017-05-16 20:00:00"
94+
end_time = "2017-05-17 20:00:00"
95+
}

examples/tencentcloud-scf/variable.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
variable "role_document" {
2+
default = "{\"version\":\"2.0\",\"statement\":[{\"action\":[\"name/sts:AssumeRole\"],\"effect\":\"allow\",\"principal\":{\"qcs\":[\"qcs::cam::uin/100009461222:uin/100009461222\"]}}]}"
3+
}
4+
5+
variable "trigger_desc" {
6+
default = "{\"event\":\"cos:ObjectCreated:Put\",\"filter\":{\"Prefix\":\"\",\"Suffix\":\"\"}}"
7+
}
8+
9+
variable "availability_zone" {
10+
default = "ap-guangzhou-3"
11+
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
github.com/hashicorp/terraform v0.12.12
1414
github.com/likexian/gokit v0.20.16
1515
github.com/mitchellh/go-homedir v1.1.0
16+
github.com/pkg/errors v0.8.1
1617
github.com/tencentcloud/tencentcloud-sdk-go v3.0.94+incompatible
1718
github.com/yangwenmai/ratelimit v0.0.0-20180104140304-44221c2292e1
1819
labix.org/v2/mgo v0.0.0-20140701140051-000000000287 // indirect

tencentcloud/common.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import (
1515

1616
"github.com/hashicorp/terraform/helper/resource"
1717
"github.com/likexian/gokit/assert"
18-
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
18+
"github.com/pkg/errors"
19+
sdkErrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
1920
)
2021

2122
const FILED_SP = "#"
@@ -73,26 +74,30 @@ func logElapsed(mark ...string) func() {
7374

7475
// retryError returns retry error
7576
func retryError(err error, additionRetryableError ...string) *resource.RetryError {
76-
if isExpectError(err, retryableErrorCode) {
77-
log.Printf("[CRITAL] Retryable defined error: %v", err)
78-
return resource.RetryableError(err)
79-
}
80-
81-
if len(additionRetryableError) > 0 {
82-
if isExpectError(err, additionRetryableError) {
83-
log.Printf("[CRITAL] Retryable addition error: %v", err)
77+
switch realErr := errors.Cause(err).(type) {
78+
case *sdkErrors.TencentCloudSDKError:
79+
if isExpectError(realErr, retryableErrorCode) {
80+
log.Printf("[CRITAL] Retryable defined error: %v", err)
8481
return resource.RetryableError(err)
8582
}
83+
84+
if len(additionRetryableError) > 0 {
85+
if isExpectError(realErr, additionRetryableError) {
86+
log.Printf("[CRITAL] Retryable addition error: %v", err)
87+
return resource.RetryableError(err)
88+
}
89+
}
90+
91+
default:
8692
}
8793

8894
log.Printf("[CRITAL] NonRetryable error: %v", err)
89-
9095
return resource.NonRetryableError(err)
9196
}
9297

9398
// isExpectError returns whether error is expect error
9499
func isExpectError(err error, expectError []string) bool {
95-
e, ok := err.(*errors.TencentCloudSDKError)
100+
e, ok := err.(*sdkErrors.TencentCloudSDKError)
96101
if !ok {
97102
return false
98103
}

tencentcloud/connectivity/client.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
cam "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam/v20190116"
1313
cbs "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs/v20170312"
1414
cdb "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdb/v20170320"
15+
cfs "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cfs/v20190719"
1516
clb "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317"
1617
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
1718
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
@@ -20,6 +21,7 @@ import (
2021
gaap "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/gaap/v20180529"
2122
mongodb "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb/v20180408"
2223
redis "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis/v20180412"
24+
scf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf/v20180416"
2325
tag "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tag/v20180813"
2426
tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525"
2527
vpc "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312"
@@ -46,6 +48,8 @@ type TencentCloudClient struct {
4648
camConn *cam.Client
4749
gaapConn *gaap.Client
4850
sslConn *ssl.Client
51+
cfsConn *cfs.Client
52+
scfConn *scf.Client
4953
}
5054

5155
// NewTencentCloudClient returns a new TencentCloudClient
@@ -281,3 +285,29 @@ func (me *TencentCloudClient) UseCamClient() *cam.Client {
281285

282286
return me.camConn
283287
}
288+
289+
// UseCfsClient returns cfs client for service
290+
func (me *TencentCloudClient) UseCfsClient() *cfs.Client {
291+
if me.cfsConn != nil {
292+
return me.cfsConn
293+
}
294+
295+
cpf := newTencentCloudClientProfile(300)
296+
me.cfsConn, _ = cfs.NewClient(me.Credential, me.Region, cpf)
297+
me.cfsConn.WithHttpTransport(&LogRoundTripper{})
298+
299+
return me.cfsConn
300+
}
301+
302+
// UseScfClient returns scf client for service
303+
func (me *TencentCloudClient) UseScfClient() *scf.Client {
304+
if me.scfConn != nil {
305+
return me.scfConn
306+
}
307+
308+
cpf := newTencentCloudClientProfile(300)
309+
me.scfConn, _ = scf.NewClient(me.Credential, me.Region, cpf)
310+
me.scfConn.WithHttpTransport(&LogRoundTripper{})
311+
312+
return me.scfConn
313+
}

0 commit comments

Comments
 (0)