Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Extended s3 bucket properties like website, lifecycle_rule gets removed after migrate to new style #28068

Open
duc2019 opened this issue Nov 29, 2022 · 2 comments
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.

Comments

@duc2019
Copy link

duc2019 commented Nov 29, 2022

Terraform Core Version

1.3.5

AWS Provider Version

3.75.2

Affected Resource(s)

aws_s3_bucket

Expected Behavior

The second apply should update nothing.

Actual Behavior

The second apply removes website setting of s3 bucket.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_s3_bucket" "bucket" {
bucket = "test-bucket-name"
}

resource "aws_s3_bucket_website_configuration" "bucket-website" {
bucket = aws_s3_bucket.bucket.bucket
index_document { suffix = "index.html" }
error_document { key = "error.html" }
}

Steps to Reproduce

Reproduce steps:

Create a resource with deprecated style:

resource "aws_s3_bucket" "bucket" {
  bucket = "test-bucket-name"
  website {
    index_document = "index.html"
    error_document = "error.html"
  }
}

Migrate it to new style:

resource "aws_s3_bucket" "bucket" {
  bucket = "test-bucket-name"
}

resource "aws_s3_bucket_website_configuration" "bucket-website" {
  bucket = aws_s3_bucket.bucket.bucket
  index_document { suffix = "index.html" }
  error_document { key = "error.html" }
}

Run terraform apply, the first apply will successful.

Run terraform apply again, then I see this modification:

  # aws_s3_bucket.s3-frontend will be updated in-place
  ~ resource "aws_s3_bucket" "bucket" {
        id                          = "test-bucket-name"
        # (14 unchanged attributes hidden)

      - website {
          - error_document = "error.html" -> null
          - index_document = "index.html" -> null
        }

        # (1 unchanged block hidden)
    }

And If I continue the website setting of this bucket will become disabled.

Because of this bug I have to keep the depreacted style of s3 resources.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No response

@duc2019 duc2019 added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Nov 29, 2022
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/s3 Issues and PRs that pertain to the s3 service. label Nov 29, 2022
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Nov 29, 2022
@toddlucas
Copy link

This also applies to the logging sub-resource block and aws_s3_bucket_logging resource. The config is perpetually out of date. I also have to move back to the old deprecated style to stop the churn. I was fortunate because the deletion and re-creation of these resources was (mostly) non-destructive. I could see this being very painful if the operation applied to a resource that was destructive.

This should be a transparent migration, since the underlying resource shouldn't change. The only thing that is changing are the Terraform resources used to manage the config state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.
Projects
None yet
Development

No branches or pull requests

3 participants