diff --git a/huaweicloud/resource_huaweicloud_s3_bucket.go b/huaweicloud/resource_huaweicloud_s3_bucket.go index 7ecea6b7e0..5e1d9b778c 100644 --- a/huaweicloud/resource_huaweicloud_s3_bucket.go +++ b/huaweicloud/resource_huaweicloud_s3_bucket.go @@ -353,11 +353,11 @@ func resourceS3BucketUpdate(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error creating HuaweiCloud s3 client: %s", err) } - /* - if err := setTagsS3(s3conn, d); err != nil { - return fmt.Errorf("%q: %s", d.Get("bucket").(string), err) - } - */ + // update tags + if err := setTagsS3(s3conn, d); err != nil { + return fmt.Errorf("%q: %s", d.Get("bucket").(string), err) + } + if d.HasChange("policy") { if err := resourceS3BucketPolicyUpdate(s3conn, d); err != nil { return err @@ -778,16 +778,15 @@ func resourceS3BucketRead(d *schema.ResourceData, meta interface{}) error { } } - /* - tagSet, err := getTagSetS3(s3conn, d.Id()) - if err != nil { - return err - } + // get tags + tagSet, err := getTagSetS3(s3conn, d.Id()) + if err != nil { + return err + } - if err := d.Set("tags", tagsToMapS3(tagSet)); err != nil { - return err - } - */ + if err := d.Set("tags", tagsToMapS3(tagSet)); err != nil { + return err + } // UNUSED? //d.Set("arn", fmt.Sprintf("arn:%s:s3:::%s", meta.(*Config).partition, d.Id())) diff --git a/website/docs/d/s3_bucket_object.html.markdown b/website/docs/d/s3_bucket_object.html.markdown index cd8f2f7b18..1dbb84e10c 100644 --- a/website/docs/d/s3_bucket_object.html.markdown +++ b/website/docs/d/s3_bucket_object.html.markdown @@ -20,6 +20,7 @@ data "huaweicloud_s3_bucket_object" "b" { bucket = "my-test-bucket" key = "hello-world.zip" } +``` ## Argument Reference diff --git a/website/docs/r/s3_bucket.html.markdown b/website/docs/r/s3_bucket.html.markdown index 8b6043da17..91af7ca5c8 100644 --- a/website/docs/r/s3_bucket.html.markdown +++ b/website/docs/r/s3_bucket.html.markdown @@ -12,12 +12,17 @@ Provides a S3 bucket resource. ## Example Usage -### Private Bucket w/ Tags +### Private Bucket with Tags ```hcl resource "huaweicloud_s3_bucket" "b" { bucket = "my-tf-test-bucket" acl = "private" + + tags = { + foo = "bar" + Env = "Test" + } } ``` @@ -147,8 +152,9 @@ The following arguments are supported: * `bucket` - (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. * `bucket_prefix` - (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with `bucket`. * `acl` - (Optional) The [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) to apply. Defaults to "private". -* `policy` - (Optional) A valid [bucket policy](https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html) JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a `terraform plan`. In this case, please make sure you use the verbose/specific version of the policy. +* `tags` - (Optional) A mapping of tags to assign to the bucket. * `force_destroy` - (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are *not* recoverable. +* `policy` - (Optional) A valid [bucket policy](https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html) JSON document. Note that if the policy document is not specific enough (but still valid), Terraform may view the policy as constantly changing in a `terraform plan`. In this case, please make sure you use the verbose/specific version of the policy. * `website` - (Optional) A website object (documented below). * `cors_rule` - (Optional) A rule of [Cross-Origin Resource Sharing](https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html) (documented below). * `versioning` - (Optional) A state of [versioning](https://docs.aws.amazon.com/AmazonS3/latest/dev/Versioning.html) (documented below)