hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.41k stars 9.5k forks source link

wrap json data with `jsonencode` when generating configuration #34444

Closed EugenKon closed 7 months ago

EugenKon commented 9 months ago

Terraform Version

$ terraform --version
Terraform v1.6.4
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.67.0

Use Cases

terraform plan -generate-config-out=billing_policy.tf.import

Attempted Solutions

None

Proposal

image

Though terraform plan shows pretty printed version. image

It would be nice if this pretty printed version will be stored into a generated configuration file.

References

No response

crw commented 9 months ago

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

kmoe commented 9 months ago

Good idea. This could look really nice. The plan renderer does this for any string attribute value that starts with { or [ and parses as JSON. We could do the same in genconfig.

EugenKon commented 9 months ago

@kmoe Please, do not forget:

If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue.

github-actions[bot] commented 6 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.