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

Viewed 1075

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)
    }
1 Answers

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.

Related