Home > Back-end >  With aws_s3_bucket_object deprecated, should I upload files using aws_s3_bucket only?
With aws_s3_bucket_object deprecated, should I upload files using aws_s3_bucket only?

Time:04-11

There's a note on the aws_s3_bucket_object page saying it's deprecated and to use aws_s3_bucket instead:

The aws_s3_bucket_object resource is DEPRECATED and will be removed in a future version! Use aws_s3_object instead, where new features and fixes will be added. When replacing aws_s3_bucket_object with aws_s3_object in your configuration, on the next apply, Terraform will recreate the object. If you prefer to not have Terraform recreate the object, import the object using aws_s3_object.

When I go over to the aws_s3_bucket page, there's no example of how to upload a file, only how to create a bucket. A number of articles online also point to use aws_s3_bucket to create the bucket but still use aws_s3_bucket_object to upload files, is this still the correct practice?

CodePudding user response:

If you take a look at the documentation of the aws_s3_object and compare it to the documentation of the older aws_s3_bucket_object, you can see that they are very similar. If you are using some online tutorial for Terraform, switching aws_s3_bucket_object to aws_s3_object in the code will probably work without major issue.

Obviously, you will face issues, if you already applied a plan and decide to switch aws_s3_bucket_object to aws_s3_object. In this case you need to import the object into the current state.

Currently the latest AWS provider is 4.9.0, which marks aws_s3_bucket_object as deprecated, but not removed. As long as you don't plan to upgrade the provider, your code will work. If you want to future-proof your code, you will need to use aws_s3_object.

  • Related