terraform-cdk
terraform-cdk copied to clipboard
Duplicate backend configuration on remote.tf.json
Good Morning,
I have the next question, every time that I execute "cdktf synth" it creates a remote.tf.json, cdk.tf.json and some extra files.
Then when I tried to execute Terraform plan I get the next error :
what it is right, because checking the remote.tf.json inside it, I have this
another terraform backend, I would like to know how to avoid this issue, because currently I'm using a automatic process which is using "cdktf synth" and after than "Terraform plan" and it fails.
Basically I dont want to create in the cdk.tf.json automatically
"terraform": {
"backend": {
"local": {
"path": "C:\\D\\Cignium\\LM\\GitHubRepo\\infrastructure\\Platforms.LM.IAC\\src\\TerraformStack\\terraform.lm.tfstate"
}
},
Many thanks.
Are you using Terraform Cloud?
Do you have an azurerm backend configured somewhere?
The local backend is added automatically if no other backends are configured within the stack.
Hi @jsteinich
Yes, I'm using terraform. Yes, it was configured in two places, so I take one out.
Ok I see this last version brings backend in the same file, gotcha.
Trying to set up terraform init, I got the following errors, looks like the way to set up is different ??
According to what I read that is because of "Backend Local". Could you pls walk me thought ?
I need to run this "cdktf synth" and get the cdk.tf.json with "Backend" ready to apply the command above.
Many thanks.
Normally cdktf takes care of running terraform init. Your cdktf code can read in the configuration for a file, environment variable, or other sources.
If you do want to continue using terraform directly that should also be possible. It looks like you want to use Azure, so just define an instance of AzurermBackend within your code and put placeholders in place.
Hi @jsteinich
Gotcha, many thanks for the help !
Regards
@angeloCabezas Do I read it correctly that the issue is solved?
On a related note:
We're still referring to this.addOverride('terraform.backend' in some places and should upgrade that to using the RemoteBackend as using an override is not detected by the logic that inserts a LocalBackend as a fallback if none was found. E.g. our docs still recommend to use an override but they don't mention that one would need to clear the terraform.backend.local via an override, too (a user figured this out here).
I've got the duplication of all resources using the local state. I've got this behaviour two time already. I have no idea whats going on.
Hi @a0s, could you share some example code where this happens? I'm especially interested in any backend configuration and overrides. Also: are you using a monorepo and/or locally linked npm modules?
Hi there! 👋 We haven't heard from you in 30 days and would like to know if the problem has been resolved or if you still need help. If we don't hear from you before then, I'll auto-close this issue in 30 days.
I'm closing this issue because we haven't heard back in 60 days. ⌛️ If you still need help, feel free to comment or reopen the issue!
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've 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.