-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Stacks are getting deployed in Alphabetical order #1635
Comments
The CDK now understands dependencies between the stacks and will honor them (#1436, #1511) -- this conscious ordering decision had a side effect of causing your stack's previous "definition order" to be lost there. Your issue in essence here is that the way you're doing the At the same time as the dependency order deployment, a change was introduced to allow for transparent cross-stack references (#1436). You could hence change your code to something like: #!/usr/bin/env node
import s3 = require('@aws-cdk/aws-s3');
import cdk = require('@aws-cdk/cdk');
import cloudtrail = require('@aws-cdk/aws-cloudtrail')
interface ACdkStackProps extends cdk.StackProps {
bucket: s3.IBucket;
}
class ACdkStack extends cdk.Stack {
constructor(scope: cdk.App, name: string, props: ACdkStackProps) {
super(scope, name, props);
new cloudtrail.CfnTrail(this, 'Trail', {
includeGlobalServiceEvents: true,
isMultiRegionTrail: true,
trailName: "testing",
isLogging: true,
s3BucketName: props.bucket.bucketName,
s3KeyPrefix: 'cloudtrail'
});
}
}
class BCdkStack extends cdk.Stack {
public readonly bucket: s3.IBucket;
constructor(scope: cdk.App, name: string, props?: cdk.StackProps) {
super(scope, name, props);
this.bucket = new s3.Bucket(this, 'BucketRef', {
bucketName: "testing202020asd"
});
}
}
const app = new cdk.App();
const bStack = new BCdkStack(app, 'BCdkStack');
new ACdkStack(app, 'ACdkStack', { bucket: bStack.bucket });
app.run(); |
@RomainMuller Thanks for the clarification. The previous example had s3 bucket created through cdk so created dependencies between stack but how do i make order between two stacks which has custom resource type or external templates include by using Please refer the below example, I need to deploy BCdkStack first before ACdkStack. So, how do i define dependency here?
|
@RomainMuller How do i make dependency between two stacks created through Custom resource and CDK include feature. Please advise me on this. |
You can do the following:
Stack2 will deploy before stack1 after doing that. |
Can someone please give an example of how this is done . Stack1.addDependency(stack2) |
I have noticed the Stacks are getting deployed in Alphabetical order on the latest version(0.22.0) which is not happened on the old version(0.14.0 - Which I used before the latest version).
With the below example, was expecting BCdkStack should be deployed before ACdkStack as i have order in my stack definition.
But on the V0.22.0, the stacks are getting deployed as Alphabetical order which breaking the deployment.
Have attached screenshot which shows the
cdk deploy
behavior for two different versions.Please suggest is it a expected behavior on the latest version, if so let me know how to define dependency between stacks.
Version 0.22.0
Version 0.14.0
The text was updated successfully, but these errors were encountered: