Hi,
I’m trying to model a cross account stack approach (an administration stack with a local state file for creating the remote state resources, and an environment stack that uses the remote state resources for its state). Whenever I try to do that I get the stack dependency error -
0 Stacks deploying 0 Stacks done 0 Stacks waiting Error: Usage Error: The following dependencies are not included in the stacks to run: cdktf-infra-eventreporting-administration. Either add them or add the --ignore-missing-stack-dependencies flag.
Am I doing this incorrectly?
Code -
`
import { Construct } from "constructs";
import {App, LocalBackend, S3Backend, TerraformStack} from "cdktf";
import {S3Bucket} from "@cdktf/provider-aws/lib/s3-bucket";
import {AwsProvider} from "@cdktf/provider-aws/lib/provider";
import {S3BucketVersioningA} from "@cdktf/provider-aws/lib/s3-bucket-versioning";
class AdministrationStack extends TerraformStack {
public terraformStateBucket: S3Bucket;
constructor(scope: Construct, id: string) {
super(scope, id);
new AwsProvider(this, "AWS", {
region: "us-west-1",
});
new LocalBackend(this, {
path: "./terraform.tfstate"
});
// define resources here
this.terraformStateBucket = new S3Bucket(this, "terraformStateBucket", {
bucketPrefix: "hts-eventreporting-terraform-state-",
});
new S3BucketVersioningA(this, "terraformStateBucketVersioning", {
bucket: this.terraformStateBucket.id,
versioningConfiguration: {
status: "Enabled"
}
});
}
}
interface MyStackProps {
remoteStateBucketName: string
}
class MyStack extends TerraformStack {
constructor(scope: Construct, id: string, myStackProps: MyStackProps) {
super(scope, id);
// define resources here
new S3Backend(this, {
bucket: myStackProps.remoteStateBucketName,
key: "mystack"
});
}
}
const app = new App();
const administrationStack = new AdministrationStack(app, "cdktf-infra-eventreporting-administration");
const myStack = new MyStack(app, "cdktf-infra-eventreporting", {
remoteStateBucketName: administrationStack.terraformStateBucket.id
});
myStack.addDependency(administrationStack);
app.synth();