diff --git a/.changelog/3490.txt b/.changelog/3490.txt new file mode 100644 index 0000000000..f0ed1c2f30 --- /dev/null +++ b/.changelog/3490.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_ckafka_acl: optmize the value of principal +``` diff --git a/tencentcloud/services/ckafka/resource_tc_ckafka_acl.go b/tencentcloud/services/ckafka/resource_tc_ckafka_acl.go index 2b5da8b99b..ec81d96f82 100644 --- a/tencentcloud/services/ckafka/resource_tc_ckafka_acl.go +++ b/tencentcloud/services/ckafka/resource_tc_ckafka_acl.go @@ -121,7 +121,7 @@ func resourceTencentCloudCkafkaAclRead(d *schema.ResourceData, meta interface{}) _ = d.Set("operation_type", CKAFKA_ACL_OPERATION_TO_STRING[*info.Operation]) _ = d.Set("permission_type", CKAFKA_PERMISSION_TYPE_TO_STRING[*info.PermissionType]) _ = d.Set("host", info.Host) - _ = d.Set("principal", strings.TrimLeft(*info.Principal, CKAFKA_ACL_PRINCIPAL_STR)) + _ = d.Set("principal", strings.TrimPrefix(*info.Principal, CKAFKA_ACL_PRINCIPAL_STR)) return nil } diff --git a/tencentcloud/services/ckafka/resource_tc_ckafka_acl.md b/tencentcloud/services/ckafka/resource_tc_ckafka_acl.md index 78ea951375..dd34ef4a62 100644 --- a/tencentcloud/services/ckafka/resource_tc_ckafka_acl.md +++ b/tencentcloud/services/ckafka/resource_tc_ckafka_acl.md @@ -5,21 +5,27 @@ Example Usage Ckafka Acl ```hcl -resource "tencentcloud_ckafka_acl" "foo" { - instance_id = "ckafka-f9ife4zz" +resource "tencentcloud_ckafka_user" "example" { + instance_id = "ckafka-7k5nbnem" + account_name = "tf-example" + password = "Password@123" +} + +resource "tencentcloud_ckafka_acl" "example" { + instance_id = "ckafka-7k5nbnem" resource_type = "TOPIC" - resource_name = "topic-tf-test" + resource_name = "tf-example-resource" operation_type = "WRITE" permission_type = "ALLOW" host = "*" - principal = tencentcloud_ckafka_user.foo.account_name + principal = tencentcloud_ckafka_user.example.account_name } ``` Import -Ckafka acl can be imported using the instance_id#permission_type#principal#host#operation_type#resource_type#resource_name, e.g. +Ckafka Acl can be imported using the instance_id#permission_type#principal#host#operation_type#resource_type#resource_name, e.g. ``` -$ terraform import tencentcloud_ckafka_acl.foo ckafka-f9ife4zz#ALLOW#test#*#WRITE#TOPIC#topic-tf-test -``` \ No newline at end of file +$ terraform import tencentcloud_ckafka_acl.example ckafka-7k5nbnem#ALLOW#tf-example#*#WRITE#TOPIC#tf-example-resource +``` diff --git a/website/docs/r/ckafka_acl.html.markdown b/website/docs/r/ckafka_acl.html.markdown index b983ba9b42..31b820b681 100644 --- a/website/docs/r/ckafka_acl.html.markdown +++ b/website/docs/r/ckafka_acl.html.markdown @@ -16,14 +16,20 @@ Provides a resource to create a Ckafka Acl. ### Ckafka Acl ```hcl -resource "tencentcloud_ckafka_acl" "foo" { - instance_id = "ckafka-f9ife4zz" +resource "tencentcloud_ckafka_user" "example" { + instance_id = "ckafka-7k5nbnem" + account_name = "tf-example" + password = "Password@123" +} + +resource "tencentcloud_ckafka_acl" "example" { + instance_id = "ckafka-7k5nbnem" resource_type = "TOPIC" - resource_name = "topic-tf-test" + resource_name = "tf-example-resource" operation_type = "WRITE" permission_type = "ALLOW" host = "*" - principal = tencentcloud_ckafka_user.foo.account_name + principal = tencentcloud_ckafka_user.example.account_name } ``` @@ -49,9 +55,9 @@ In addition to all arguments above, the following attributes are exported: ## Import -Ckafka acl can be imported using the instance_id#permission_type#principal#host#operation_type#resource_type#resource_name, e.g. +Ckafka Acl can be imported using the instance_id#permission_type#principal#host#operation_type#resource_type#resource_name, e.g. ``` -$ terraform import tencentcloud_ckafka_acl.foo ckafka-f9ife4zz#ALLOW#test#*#WRITE#TOPIC#topic-tf-test +$ terraform import tencentcloud_ckafka_acl.example ckafka-7k5nbnem#ALLOW#tf-example#*#WRITE#TOPIC#tf-example-resource ```