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

[Python] cdktf synh --hcl produces unnecessary quotes and bad syntax #3531

Open
1 task
acwl-aiq opened this issue Mar 1, 2024 · 2 comments
Open
1 task
Labels
bug Something isn't working

Comments

@acwl-aiq
Copy link

acwl-aiq commented Mar 1, 2024

Expected Behavior

locals {
x = "x"
y = local.x
}

Actual Behavior

locals {
x = "x"
y = "${local.x}"
}

Steps to Reproduce

  1. Declare some local variables
x = TerraformLocal(self, "x", "x")
y = TerraformLocal(self, "y", x.as_string)
  1. Run cdktf synth --hcl

  2. Check cdktf.out

Versions

cdktf debug
language: python
cdktf-cli: 0.20.4
node: v21.5.0
cdktf: 0.20.4
constructs: 10.3.0
jsii: 1.94.0
terraform: 1.7.2
arch: x64
os: linux 5.10.102.1-microsoft-standard-WSL2
python: Python 3.8.10
pip: pip 24.0 from /home/andylai/.local/lib/python3.8/site-packages/pip (python 3.8)
pipenv: pipenv, version 2023.11.17
providers
aws@~> 4.63 (LOCAL)
terraform provider version: 4.67.0
cdktf-cdktf-provider-aws (PREBUILT)
terraform provider version: 5.39.0
prebuilt provider version: 19.8.0
cdktf version: ^0.20.0

Providers

│ Provider Name │ Provider Version │ CDKTF │ Constraint │ Package Name │ Package Version │
├───────────────┼──────────────────┼─────────┼────────────┼──────────────────────────┼─────────────────┤
│ aws │ 4.67.0 │ │ ~> 4.63 │ │ │
├───────────────┼──────────────────┼─────────┼────────────┼──────────────────────────┼─────────────────┤
│ aws │ 5.39.0 │ ^0.20.0 │ │ cdktf-cdktf-provider-aws │ 19.8.0 │

Gist

No response

Possible Solutions

No response

Workarounds

Hardcode the values

Anything Else?

This behaviour causes issues with the terraform linters which are blocking PRs.

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • 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
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@acwl-aiq acwl-aiq added bug Something isn't working new Un-triaged issue labels Mar 1, 2024
@DanielMSchmidt
Copy link
Contributor

Hi there,
Could you specify the "bad syntax" part? Wrapping this property in quotes is not necessary, but I checked the snippet and it's definitely valid.

@ansgarm ansgarm added waiting-on-answer and removed new Un-triaged issue labels Mar 11, 2024
@acwl-aiq
Copy link
Author

acwl-aiq commented Mar 26, 2024

It is still allowed for now, but it is not advised by mainstream conventions. Notably, quoted references are officially considered deprecated by Hashicorp a few years ago. And as a result, it wouldn't be ideal to continue to use such a syntax: https://discuss.hashicorp.com/t/terraform-0-12-14-released/3898

This also runs the risk of generated TF to be flagged by TF style checkers without additional intervention, which happens in my case.

Here's a similar ticket cut in another project:
terraform-google-modules/terraform-google-kubernetes-engine#373

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants