Cheers. First timer here.
Posted it as a possible bug on
Getting error when multistacking in a CDK project.
I don´t understand why a cross reff is set up. Also I´m not using workspace.
The stacks should not reff each other. See update for resolution. Which I don’t understand.
cdktf plan “app-dev”
Error :
⠋ Processing
[2024-02-24T01:36:36.851] [ERROR] default - ╷
│ Error: Unable to find remote state
│
│ with data.terraform_remote_state.cross-stack-reference-input-app-dev,
│ on cdk.tf.json line 64, in data.terraform_remote_state.cross-stack-reference-input-cargostream-gateway-dev:
│ 64: "workspace": "${terraform.workspace}"
│
│ No stored state was found for the given workspace in the given backend.
cargostream-dev ╷
│ Error: Unable to find remote state
│
│ with data.terraform_remote_state.cross-stack-reference-input-cargostream-gateway-dev,
│ on cdk.tf.json line 64, in data.terraform_remote_state.cross-stack-reference-input-cargostream-gateway-dev:
│ 64: "workspace": "${terraform.workspace}"
│
│ No stored state was found for the given workspace in the given backend.
ts - code
```class ApiStack extends TerraformStack {
constructor(scope: Construct, id: string, envConfig: EnvConfig) {
super(scope, id);
setupProvidersAndStateBackend(this, envConfig, tags);
new ApiGateway(this, "gateway");
}
}
const app = new App();
// statekeys are backed into to config.
// domain/app/env-dev.tfstate
// commerce/cargostream/cargostream-dev.tfstate
new cargostream(app, "app-dev", devConfig);
// domain/app/env-api-dev.tfstate
new ApiStack(app, "app-api-dev", devApiConfig);
app.synth();
Update:
I removed the ExternalProvider from provider setup. The provider generated two outputs.
I don´t understand why this created the cross stack error though
thx for the feedback. I found the issue. The reason was because I changed the “tags” constant. Meaning it made a cross stack reff for when multiple stacks used the same “tags” const.
Fixed it by creating a copy instead.