iann0036 / former2

Generate CloudFormation / Terraform / Troposphere templates from your existing AWS resources.
https://former2.com
MIT License
2.21k stars 267 forks source link

terraform resource aws_s3_bucket_policy generated incorrect output #320

Open rorourke-iot opened 1 year ago

rorourke-iot commented 1 year ago

The resources for an S3 bucket were generated as

resource "aws_s3_bucket" "S3Bucket" {
    bucket = "my-bucket-XXX"
}

resource "aws_s3_bucket_policy" "S3BucketPolicy" {
    bucket = "my-bucket-XXX"
    policy = "{\"Version\":\"2008-10-17\",\"Statement\":[{\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"s3:GetObject\",\"Resource\":\"arn:aws:s3:::my-bucket-XXX/*\",\"Condition\":{\"Bool\":{\"aws:SecureTransport\":\"false\"}}}]}"
}

According to the docs, aws_s3_bucket_policy.bucket should be the id of the bucket. Use aws_s3_bucket.S3Bucket.id instead.

iann0036 commented 1 year ago

Hi @rorourke-iot,

Thanks for raising! As per the other issues comment, I've added the mapping for this specific instance.