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

CLI: HCL synth generates incorrect remote configuration with workspaces #3698

Open
1 task
Hi-Fi opened this issue Aug 12, 2024 · 2 comments
Open
1 task

CLI: HCL synth generates incorrect remote configuration with workspaces #3698

Hi-Fi opened this issue Aug 12, 2024 · 2 comments
Labels
bug/has-workaround A bug with a workaround (may not be elegant) bug Something isn't working priority/important-soon High priority, to be worked on as part of our current release or the following one.

Comments

@Hi-Fi
Copy link

Hi-Fi commented Aug 12, 2024

Expected Behavior

Terraform can be initialized with CDKTF synthesized stack in HCL format. Remote configuration would look like:

terraform {
  backend "remote" {
    organization = "test-organization"
    workspaces {
      name = "test-stack"
    }
    hostname = "test.artifactory.local"
  }
}

Actual Behavior

CDKTF synthesized incorrect remove configuration

terraform {
  backend "remote" {
    organization = "test-organization"
    workspaces = {
      name = "test-stack"
    }
    hostname = "test.artifactory.local"
  }
}

When manually removing that = after workspaces, init works fine.

Steps to Reproduce

  1. Initialize empty CDKTF project
  2. Add following remote backend to it
  3. Synthesize stack to HCL (cdktf synth --hcl)
  4. Go to output directory of stack and run terraform init

Versions

language: typescript
cdktf-cli: 0.20.8
node: v20.13.1
cdktf: 0.20.8
constructs: 10.3.0
jsii: null
terraform: 1.9.4
arch: arm64
os: darwin 23.6.0

Providers

No response

Gist

No response

Possible Solutions

Probably some specific handling needed for that part. Didn't had any other places with similar issues. Datasource to remote works different way and it requires that = sign.

Workarounds

Don't use HCL (not working for me as HCL is needed for Sonarqube analysis)

Anything Else?

No response

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
@Hi-Fi Hi-Fi added bug Something isn't working new Un-triaged issue labels Aug 12, 2024
@mutahhir
Copy link
Member

Another alternative is to use the cloud block. (Docs), which is recommended by terraform anyway over the remote backend. From my understanding, that doesn't have this problem.

The remote backend is a bug nonetheless. We will be fixing it in a future release.

@mutahhir mutahhir added priority/important-soon High priority, to be worked on as part of our current release or the following one. bug/has-workaround A bug with a workaround (may not be elegant) and removed new Un-triaged issue labels Aug 12, 2024
@Hi-Fi
Copy link
Author

Hi-Fi commented Aug 14, 2024

We use Artifactory as state backend, I understood that Cloud backend is reserved for HCP Terraform (ex-Terraform Cloud) (and it's Enterprise version) and remote is for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/has-workaround A bug with a workaround (may not be elegant) bug Something isn't working priority/important-soon High priority, to be worked on as part of our current release or the following one.
Projects
None yet
Development

No branches or pull requests

2 participants