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

Config generation wraps numbers and booleans in jsonencode #35983

Closed
bplotnick opened this issue Nov 11, 2024 · 2 comments · Fixed by #35984
Closed

Config generation wraps numbers and booleans in jsonencode #35983

bplotnick opened this issue Nov 11, 2024 · 2 comments · Fixed by #35984
Labels
bug new new issue not yet triaged

Comments

@bplotnick
Copy link
Contributor

Terraform Version

HEAD

Terraform Configuration Files

import {
  to = test_resource.foo
  id = "someresourceid"
}

Debug Output

N/A

Expected Behavior

When running with -generate-config-out=generate.tf, if the returned resource has is a string type, but contains a number or a bool, the output attribute should be a string. e.g.

resource "test_resource" "foo" {
  some_string_attribute = "1234"
}

Actual Behavior

resource "test_resource" "foo" {
  some_string_attribute = jsonencode(1234)
}

Steps to Reproduce

Create an import block for a resource with a string attribute, but with a value that is a primitive, deserializable json type (number or bool) and run terraform plan -generate-config-out=generated.tf

Additional Context

I have a fix for this. I am just opening the issue for posterity

References

No response

@bplotnick bplotnick added bug new new issue not yet triaged labels Nov 11, 2024
@crw
Copy link
Contributor

crw commented Nov 11, 2024

Thanks for filing this in conjunction with the pull request!

Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug new new issue not yet triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants