gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.09k stars 981 forks source link

force_path_style in S3 backend is now deprecated #3472

Open lazzurs opened 1 month ago

lazzurs commented 1 month ago

Describe the bug

force_path_style is now deprecated and should be replaced with use_path_style

Steps To Reproduce

Steps to reproduce the behavior, code snippets and examples which can be used to reproduce the issue.

Be sure that the maintainers can actually reproduce the issue. Bug reports that are too vague or hard to reproduce are hard to troubleshoot and fix.

force_path_style = true

Will produce the error

tofu: │ Warning: Deprecated Parameter
tofu: │
tofu: │   on provider.tf line 6, in terraform:
tofu: │    6:   backend "s3" {}
tofu: │
tofu: │ Parameter "force_path_style" is deprecated. Use "use_path_style" instead.

This should be changed to

```hcl
use_path_style = true

Versions

Additional context

https://developer.hashicorp.com/terraform/language/backend/s3#force_path_style

I have a branch with the code changes to change the existing configuration option to the new one. It is a straight replacement. If the community thinks it is better I can add both but I think a straight replacement with a breaking change warning would be better as it will stop any new deployments of the deprecated configuration option.

denis256 commented 1 month ago

It looks like use_path_style was introduced since version 1.6.0, we may need to track the version of Terraform/Tofu to know which field to pass

https://github.com/hashicorp/terraform/pull/33765

yhakbar commented 1 month ago

So, to give concrete next steps:

  1. Support both, as this is a scenario where it's better to avoid a breaking change.
  2. Leverage OpenTofu/Terraform version information to decide whether to emit a warning that they are using a deprecated field.
  3. (Optional) When #3424 is merged, consider adding a strict control that users can use to opt-in to a requirement that they use the latest configuration here.

As long as OpenTofu/Terraform versions that use force_path_style are supported by Terragrunt, we won't remove the ability to set it.

lazzurs commented 3 weeks ago

I have updated the PR to support both options.

If needed I can add version checks to see which to use but I don't think this is done for other commands and is generally left for the user to manage. Happy to be corrected on this of course.