diff --git a/.changelog/2868.txt b/.changelog/2868.txt new file mode 100644 index 0000000000..b1edac28c5 --- /dev/null +++ b/.changelog/2868.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_cos_bucket: fix the issue where acl_body a cannot be modified +``` \ No newline at end of file diff --git a/tencentcloud/services/cos/resource_tc_cos_bucket.go b/tencentcloud/services/cos/resource_tc_cos_bucket.go index af185ff10e..cbb63f2cc8 100644 --- a/tencentcloud/services/cos/resource_tc_cos_bucket.go +++ b/tencentcloud/services/cos/resource_tc_cos_bucket.go @@ -1887,7 +1887,14 @@ func ACLBodyDiffFunc(olds, news string, d *schema.ResourceData) (result bool) { } // diff: ACL element - for _, oldGrantee := range oldRoot.FindElements("//Grantee") { + oldGrantees := oldRoot.FindElements("//Grantee") + newGrantees := newRoot.FindElements("//Grantee") + // check count + if len(oldGrantees) != len(newGrantees) { + return false + } + // check content + for _, oldGrantee := range oldGrantees { for _, attr := range oldGrantee.Attr { if attr.Key != "type" { // only need to handle the type attribute @@ -1959,7 +1966,9 @@ func ACLBodyDiffFunc(olds, news string, d *schema.ResourceData) (result bool) { uid = oldGranteeURI.Text() } log.Printf("[DEBUG] diff verification passed for grantee:[%s:%s]\n", oldGranteeType, uid) - break + } + if !result { + return false } } }