Skip to content

Commit

Permalink
Support tags in s3_bucket (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiChangkuo authored Feb 6, 2020
1 parent 349b764 commit e846462
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
27 changes: 13 additions & 14 deletions huaweicloud/resource_huaweicloud_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()))
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/s3_bucket_object.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ data "huaweicloud_s3_bucket_object" "b" {
bucket = "my-test-bucket"
key = "hello-world.zip"
}
```

## Argument Reference

Expand Down
10 changes: 8 additions & 2 deletions website/docs/r/s3_bucket.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
```

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e846462

Please sign in to comment.