After upgrade cdktf to 17.3 my stack fails to synth with the error TypeError: Cannot read properties of undefined (reading 'required_providers')
To summarize
const app = new App()
const stack = new TerraformStack(app, 'stack');
const eks1 = new EKSCluster(stack, 'eks1', {
...
}
const eks2 = new EKSCluster(stack, 'eks2', {
...
}
app.synth();
I originally made app to make a stack, and I added multiple eks clusters to that one stack. The problem is now that I have a stack called “stack” in cdktf.out that does not have “required_providers” since it’s not actual a terraform_stack
the cdk.tf.out of “stack” is this
"//": {
"metadata": {
"backend": "local",
"stackName": "anedot",
"version": "0.17.3"
},
"outputs": {
}
}
}
I tried adding a provider to the “stack” terraformstack. Doing that does allow me to run cdktf synth successfully however if I try to deploy any of the eks-stacks cdktf see it as being an entirely new stack and says it needs to destroy and recreate everything.
It was suggested that I look into the terraform migrate documentation but that does not apply to this situation. I am not trying to move resources from one stack to another, i am trying to move entire stacks to another stack.
The structure is currently
app → stack (no provider) → stack-eks1(with provider),stack-eks2(with provider)
But I need to go to either one of the following
- app → stack (with provider) → stack-eks1(with provider),stack-eks2(with provider)
- app → stack-eks1(with provider),stack-eks2(with provider)
The issue is doing either will make cdktf think stack-eks1 needs to be destroyed and rebuilt entirely. I need to be able to update the higher level stack/app while making stack-eks1,stack-eks2 remain the same.