Skip to content

Commit b502025

Browse files
committed
gen docs about kms resource and data source
1 parent 7f009c8 commit b502025

File tree

8 files changed

+221
-10
lines changed

8 files changed

+221
-10
lines changed

tencentcloud/data_source_tc_kms_key.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ func dataSourceTencentCloudKmsKey() *schema.Resource {
7474
Optional: true,
7575
Description: "Tags to filter CMK.",
7676
},
77+
"result_output_file": {
78+
Type: schema.TypeString,
79+
Optional: true,
80+
Description: "Used to save results.",
81+
},
7782
"key_list": {
7883
Type: schema.TypeList,
7984
Computed: true,
@@ -133,7 +138,7 @@ func dataSourceTencentCloudKmsKey() *schema.Resource {
133138
"deletion_date": {
134139
Type: schema.TypeString,
135140
Computed: true,
136-
Description: "Delete time of CMK.`1970-01-01T12:00:00Z` means it does not delete.",
141+
Description: "Delete time of CMK.",
137142
},
138143
"origin": {
139144
Type: schema.TypeString,
@@ -143,7 +148,7 @@ func dataSourceTencentCloudKmsKey() *schema.Resource {
143148
"valid_to": {
144149
Type: schema.TypeString,
145150
Computed: true,
146-
Description: "Valid when Origin is EXTERNAL, it means the effective date of the key material.`1970-01-01T12:00:00Z` means it does not expire.",
151+
Description: "Valid when Origin is EXTERNAL, it means the effective date of the key material.",
147152
},
148153
},
149154
},
@@ -211,13 +216,21 @@ func dataSourceTencentCloudKmsKeyRead(d *schema.ResourceData, meta interface{})
211216
"creator_uin": key.CreatorUin,
212217
"key_rotation_enabled": key.KeyRotationEnabled,
213218
"owner": key.Owner,
214-
"deletion_date": helper.FormatUnixTime(*key.DeletionDate),
215219
"origin": key.Origin,
216-
"valid_to": helper.FormatUnixTime(*key.ValidTo),
217220
}
218221
if *key.KeyRotationEnabled {
219222
mapping["next_rotate_time"] = helper.FormatUnixTime(*key.NextRotateTime)
220223
}
224+
if *key.KeyState == KMS_KEY_STATE_PENDINGDELETE {
225+
mapping["deletion_date"] = helper.FormatUnixTime(*key.DeletionDate)
226+
}
227+
if *key.Origin == KMS_ORIGIN_EXTERNAL {
228+
if *key.ValidTo != 0 {
229+
mapping["valid_to"] = helper.FormatUnixTime(*key.ValidTo)
230+
} else {
231+
mapping["valid_to"] = "never expire"
232+
}
233+
}
221234
keyList = append(keyList, mapping)
222235
ids = append(ids, *key.KeyId)
223236
}

tencentcloud/provider.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,14 @@ VPN
502502
tencentcloud_vpn_customer_gateway
503503
tencentcloud_vpn_gateway
504504
tencentcloud_vpn_connection
505+
506+
KMS
507+
Data Source
508+
tencentcloud_kms_key
509+
510+
Resource
511+
tencentcloud_kms_key
512+
tencentcloud_kms_external_key
505513
*/
506514
package tencentcloud
507515

tencentcloud/resource_tc_kms_external_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func resourceTencentCloudKmsExternalKey() *schema.Resource {
8787
Type: schema.TypeString,
8888
Optional: true,
8989
Sensitive: true,
90-
Description: "The base64-encoded key material encrypted with the public_key.For regions using the national secret version, the length of the imported key material is required to be 128 bits, and for regions using the FIPS version, the length of the imported key material is required to be 256 bits",
90+
Description: "The base64-encoded key material encrypted with the public_key.For regions using the national secret version, the length of the imported key material is required to be 128 bits, and for regions using the FIPS version, the length of the imported key material is required to be 256 bits.",
9191
},
9292
"valid_to": {
9393
Type: schema.TypeInt,

tencentcloud/resource_tc_kms_key.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ KMS keys can be imported using the id, e.g.
2222
$ terraform import tencentcloud_kms_key.foo 287e8f40-7cbb-11eb-9a3a-5254004f7f94
2323
```
2424
*/
25-
2625
package tencentcloud
2726

2827
import (
@@ -77,7 +76,7 @@ func resourceTencentCloudKmsKey() *schema.Resource {
7776
Optional: true,
7877
Computed: true,
7978
ValidateFunc: validateAllowedStringValue(KMS_KEY_USAGE),
80-
Description: "Usage of CMK.Available values include `ENCRYPT_DECRYPT`, `ASYMMETRIC_DECRYPT_RSA_2048`, `ASYMMETRIC_DECRYPT_SM2`, `ASYMMETRIC_SIGN_VERIFY_SM2`, `ASYMMETRIC_SIGN_VERIFY_RSA_2048`, `ASYMMETRIC_SIGN_VERIFY_ECC`.",
79+
Description: "Usage of CMK.Available values include `ENCRYPT_DECRYPT`, `ASYMMETRIC_DECRYPT_RSA_2048`, `ASYMMETRIC_DECRYPT_SM2`, `ASYMMETRIC_SIGN_VERIFY_SM2`, `ASYMMETRIC_SIGN_VERIFY_RSA_2048`, `ASYMMETRIC_SIGN_VERIFY_ECC`.Default value is `ENCRYPT_DECRYPT`.",
8180
},
8281
"key_rotation_enabled": {
8382
Type: schema.TypeBool,
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
subcategory: "KMS"
3+
layout: "tencentcloud"
4+
page_title: "TencentCloud: tencentcloud_kms_key"
5+
sidebar_current: "docs-tencentcloud-datasource-kms_key"
6+
description: |-
7+
Use this data source to query detailed information of KMS key
8+
---
9+
10+
# tencentcloud_kms_key
11+
12+
Use this data source to query detailed information of KMS key
13+
14+
## Example Usage
15+
16+
```hcl
17+
data "tencentcloud_kms_key" "foo" {
18+
search_key_alias = "test"
19+
key_state = "All"
20+
origin = "TENCENT_KMS"
21+
key_usage = "ALL"
22+
}
23+
```
24+
25+
## Argument Reference
26+
27+
The following arguments are supported:
28+
29+
* `key_state` - (Optional) State of CMK.Available values include `All`, `Enabled`, `Disabled`, `PendingDelete`, `PendingImport`, `Archived`.
30+
* `key_usage` - (Optional) Usage of CMK.Available values include `ALL`, `ENCRYPT_DECRYPT`, `ASYMMETRIC_DECRYPT_RSA_2048`, `ASYMMETRIC_DECRYPT_SM2`, `ASYMMETRIC_SIGN_VERIFY_SM2`, `ASYMMETRIC_SIGN_VERIFY_RSA_2048`, `ASYMMETRIC_SIGN_VERIFY_ECC`.Default value is `ENCRYPT_DECRYPT`.
31+
* `order_type` - (Optional) Order to sort the CMK create time.`0` - desc, `1` - asc.Default value is `0`.
32+
* `origin` - (Optional) Origin of CMK.`TENCENT_KMS` - CMK created by KMS, `EXTERNAL` - CMK imported by user, `ALL` - All CMK.Default value is `ALL`.
33+
* `result_output_file` - (Optional) Used to save results.
34+
* `role` - (Optional) Role of the CMK creator.`0` - created by user, `1` - created by cloud product.Default value is `0`.
35+
* `search_key_alias` - (Optional) Words used to match the results,and the words can be: key_id and alias.
36+
* `tags` - (Optional) Tags to filter CMK.
37+
38+
## Attributes Reference
39+
40+
In addition to all arguments above, the following attributes are exported:
41+
42+
* `key_list` - A list of KMS keys.
43+
* `alias` - Name of CMK.
44+
* `create_time` - Create time of CMK.
45+
* `creator_uin` - Uin of CMK Creator.
46+
* `deletion_date` - Delete time of CMK.
47+
* `description` - Description of CMK.
48+
* `key_id` - ID of CMK.
49+
* `key_rotation_enabled` - Specify whether to enable key rotation.
50+
* `key_state` - State of CMK.Available values include `Enabled`, `Disabled`, `PendingDelete`, `PendingImport`, `Archived`.
51+
* `key_usage` - Usage of CMK.Available values include `ENCRYPT_DECRYPT`, `ASYMMETRIC_DECRYPT_RSA_2048`, `ASYMMETRIC_DECRYPT_SM2`, `ASYMMETRIC_SIGN_VERIFY_SM2`, `ASYMMETRIC_SIGN_VERIFY_RSA_2048`, `ASYMMETRIC_SIGN_VERIFY_ECC`.
52+
* `next_rotate_time` - Next rotate time of CMK when key_rotation_enabled is true.
53+
* `origin` - Origin of CMK.`TENCENT_KMS` - CMK created by KMS, `EXTERNAL` - CMK imported by user.
54+
* `owner` - Creator of CMK.
55+
* `valid_to` - Valid when Origin is EXTERNAL, it means the effective date of the key material.
56+
57+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
subcategory: "KMS"
3+
layout: "tencentcloud"
4+
page_title: "TencentCloud: tencentcloud_kms_external_key"
5+
sidebar_current: "docs-tencentcloud-resource-kms_external_key"
6+
description: |-
7+
Provide a resource to create a KMS external import key.
8+
---
9+
10+
# tencentcloud_kms_external_key
11+
12+
Provide a resource to create a KMS external import key.
13+
14+
## Example Usage
15+
16+
```hcl
17+
resource "tencentcloud_kms_external_key" "foo" {
18+
alias = "test"
19+
description = "describe key test message."
20+
wrapping_algorithm = "RSAES_PKCS1_V1_5"
21+
key_material_base64 = "MTIzMTIzMTIzMTIzMTIzQQ=="
22+
valid_to = 2147443200
23+
}
24+
```
25+
26+
## Argument Reference
27+
28+
The following arguments are supported:
29+
30+
* `alias` - (Required) Name of CMK.The name can only contain English letters, numbers, underscore and hyphen '-'.The first character must be a letter or number.
31+
* `description` - (Optional) Description of CMK.The maximum is 1024 bytes.
32+
* `key_id` - (Optional) ID of CMK.
33+
* `key_material_base64` - (Optional) The base64-encoded key material encrypted with the public_key.For regions using the national secret version, the length of the imported key material is required to be 128 bits, and for regions using the FIPS version, the length of the imported key material is required to be 256 bits.
34+
* `key_state` - (Optional) State of CMK.Available values include `Enabled`, `Disabled`, `PendingDelete`, `PendingImport`, `Archived`.
35+
* `pending_delete_window_in_days` - (Optional) Duration in days after which the key is deleted after destruction of the resource, must be between 7 and 30 days. Defaults to 7 days.
36+
* `tags` - (Optional) Tags of CMK.
37+
* `valid_to` - (Optional) this value means the effective timestamp of the key material, 0 means it does not expire.Need to be greater than the current time point, the maximum support is 2147443200.
38+
* `wrapping_algorithm` - (Optional) The algorithm for encrypting key material.Available values include `RSAES_PKCS1_V1_5`, `RSAES_OAEP_SHA_1` and `RSAES_OAEP_SHA_256`.
39+
40+
## Attributes Reference
41+
42+
In addition to all arguments above, the following attributes are exported:
43+
44+
* `id` - ID of the resource.
45+
46+
47+
48+
## Import
49+
50+
KMS external keys can be imported using the id, e.g.
51+
52+
```
53+
$ terraform import tencentcloud_kms_external_key.foo 287e8f40-7cbb-11eb-9a3a-5254004f7f94
54+
```
55+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
subcategory: "KMS"
3+
layout: "tencentcloud"
4+
page_title: "TencentCloud: tencentcloud_kms_key"
5+
sidebar_current: "docs-tencentcloud-resource-kms_key"
6+
description: |-
7+
Provide a resource to create a KMS key.
8+
---
9+
10+
# tencentcloud_kms_key
11+
12+
Provide a resource to create a KMS key.
13+
14+
## Example Usage
15+
16+
```hcl
17+
resource "tencentcloud_kms_key" "foo" {
18+
alias = "test"
19+
description = "describe key test message."
20+
key_rotation_enabled = true
21+
tags = {
22+
"test-tag" : "key-test"
23+
}
24+
}
25+
```
26+
27+
## Argument Reference
28+
29+
The following arguments are supported:
30+
31+
* `alias` - (Required) Name of CMK.The name can only contain English letters, numbers, underscore and hyphen '-'.The first character must be a letter or number.
32+
* `description` - (Optional) Description of CMK.The maximum is 1024 bytes.
33+
* `key_id` - (Optional) ID of CMK.
34+
* `key_rotation_enabled` - (Optional) Specify whether to enable key rotation.
35+
* `key_state` - (Optional) State of CMK.Available values include `Enabled`, `Disabled`, `PendingDelete`, `Archived`.
36+
* `key_usage` - (Optional) Usage of CMK.Available values include `ENCRYPT_DECRYPT`, `ASYMMETRIC_DECRYPT_RSA_2048`, `ASYMMETRIC_DECRYPT_SM2`, `ASYMMETRIC_SIGN_VERIFY_SM2`, `ASYMMETRIC_SIGN_VERIFY_RSA_2048`, `ASYMMETRIC_SIGN_VERIFY_ECC`.Default value is `ENCRYPT_DECRYPT`.
37+
* `pending_delete_window_in_days` - (Optional) Duration in days after which the key is deleted after destruction of the resource, must be between 7 and 30 days. Defaults to 7 days.
38+
* `tags` - (Optional) Tags of CMK.
39+
40+
## Attributes Reference
41+
42+
In addition to all arguments above, the following attributes are exported:
43+
44+
* `id` - ID of the resource.
45+
46+
47+
48+
## Import
49+
50+
KMS keys can be imported using the id, e.g.
51+
52+
```
53+
$ terraform import tencentcloud_kms_key.foo 287e8f40-7cbb-11eb-9a3a-5254004f7f94
54+
```
55+

website/tencentcloud.erb

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,30 @@
807807
</li>
808808
</ul>
809809
</li>
810+
<li>
811+
<a href="#">KMS</a>
812+
<ul class="nav">
813+
<li>
814+
<a href="#">Data Sources</a>
815+
<ul class="nav nav-auto-expand">
816+
<li>
817+
<a href="/docs/providers/tencentcloud/d/kms_key.html">tencentcloud_kms_key</a>
818+
</li>
819+
</ul>
820+
</li>
821+
<li>
822+
<a href="#">Resources</a>
823+
<ul class="nav nav-auto-expand">
824+
<li>
825+
<a href="/docs/providers/tencentcloud/r/kms_key.html">tencentcloud_kms_key</a>
826+
</li>
827+
<li>
828+
<a href="/docs/providers/tencentcloud/r/kms_external_key.html">tencentcloud_kms_external_key</a>
829+
</li>
830+
</ul>
831+
</li>
832+
</ul>
833+
</li>
810834
<li>
811835
<a href="#">MongoDB</a>
812836
<ul class="nav">
@@ -1230,13 +1254,13 @@
12301254
<a href="#">Resources</a>
12311255
<ul class="nav nav-auto-expand">
12321256
<li>
1233-
<a href="/docs/providers/tencentcloud/r/vpn_customer_gateway.html">tencentcloud_vpn_customer_gateway</a>
1257+
<a href="/docs/providers/tencentcloud/r/vpn_connection.html">tencentcloud_vpn_connection</a>
12341258
</li>
12351259
<li>
1236-
<a href="/docs/providers/tencentcloud/r/vpn_gateway.html">tencentcloud_vpn_gateway</a>
1260+
<a href="/docs/providers/tencentcloud/r/vpn_customer_gateway.html">tencentcloud_vpn_customer_gateway</a>
12371261
</li>
12381262
<li>
1239-
<a href="/docs/providers/tencentcloud/r/vpn_connection.html">tencentcloud_vpn_connection</a>
1263+
<a href="/docs/providers/tencentcloud/r/vpn_gateway.html">tencentcloud_vpn_gateway</a>
12401264
</li>
12411265
</ul>
12421266
</li>

0 commit comments

Comments
 (0)