hashicorp / learn-terraform-console

https://learn.hashicorp.com/tutorials/terraform/console?in=terraform/cli
Mozilla Public License 2.0
2 stars 3 forks source link

Error putting S3 policy: AccessDenied: Access Denied #7

Open AudiArduino opened 1 year ago

AudiArduino commented 1 year ago

to apply the policy for the bucket I had this error: Error: Error putting S3 policy: AccessDenied: Access Denied I fixed it by adding my AWS User ARN (can be copied after clicking on security credentials in aws console) in the principal of the policy as: resource "aws_s3_bucket_policy" "public_read" { bucket = aws_s3_bucket.data.id

policy = jsonencode({ "Statement" = [ {

    "Action" = [
      "s3:GetObject",
      "s3:GetObjectVersion",
    ]
    "Effect"    = "Allow"
    "Principal": {
            "AWS": [

                "arn:aws:iam::11111111111:user/Khaled"
            ]
        },
    "Resource" = [
      "${aws_s3_bucket.data.arn}/*",
    ]
    "Sid" = "PublicRead"
  },
]
"Version" = "2012-10-17"

}) }