Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
510 views
in Technique[技术] by (71.8m points)

Terraform import on aws_s3_bucket asking me both acl=private and grants blocks

I used terraform import to link an aws_s3_bucket resources with the least parameters. Since the bucket is in my state, it's allow me to reflect the real resource paramters (the first terraform apply failed, but it's intended).

I have some buckets with acl="private" which gave me errors and invite me to add some grants blocks. When i'm doing it, of course terraform gave me two ConflictWith errors since acl and grants cannont be used together.

But if for example i use a s3 bucket with the proper grants blocks, terraform invite me to add an acl="private" statement.

On the same time, I have a strange behavior with the force_destroy = false block. Which seems to be not detected.

Can somebody help me with me ? maybe i'm doing something wrong.

Thanks.

Code example:

resource "aws_s3_bucket" "s3-bucket-example" {
  bucket = "s3-bucket-example"
  force_destroy = false

  grant {
           permissions = [
               "READ",
               "READ_ACP",
               "WRITE",
            ] 
           type        = "Group" 
           uri         = "http://acs.amazonaws.com/groups/s3/LogDelivery" 
  }
  
  grant {
           id          = "xxxxxxxxxxxxxxx" 
           permissions = [
               "FULL_CONTROL",
            ] 
           type        = "CanonicalUser" 
  }
}

Result

# aws_s3_bucket.s3-bucket-jolivdi-acces will be updated in-place
  ~ resource "aws_s3_bucket" "s3-bucket-example" {
      + acl                         = "private"
      + force_destroy               = false
        id                          = "s3-bucket-example"
        # (7 unchanged attributes hidden)

        # (4 unchanged blocks hidden)
    }
question from:https://stackoverflow.com/questions/65882399/terraform-import-on-aws-s3-bucket-asking-me-both-acl-private-and-grants-blocks

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your code is absolutely right and working fine.

enter image description here

I had checked the ACLs for the S3 bucket also. The permissions are perfectly applied as written in the terraform code.

If you still have any problems then please elaborate a bit in a comment.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...