-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Recommendations or abstractions for deployment stages #1499
Comments
@eladb, what do you think about auto-deriving the stack name from the construct path (similar to logical IDs), then we can do something like: class MyApplication extends cdk.Construct {
constructor(scope: cdk.Construct, id: string, props: MyApplicationProps) {
new MyStack1(this, 'Stack1', { env: props.env });
new MyStack2(this, 'Stack2', { env: props.env });
new MyStack3(this, 'Stack3', { env: props.env });
}
}
// Creates Dev-Stack1, Dev-Stack2, Dev-Stack3
new MyApplication(app, 'Dev', { cheap: true, env: { accountId: '...', region: '...' }});
// Creates Prod-Stack1, Prod-Stack2, Prod-Stack3
new MyApplication(app, 'Prod', { env: { accountId: '...', region: '...' }}); Related ticket: #1479 |
(Not to say we shouldn't do configurable |
Somewhat related to how we implement nested stacks (#239) |
Any updates on this? The only solution I can think of is synthesizing one template per account, but that seems overly complex to me |
Can't say if this is "the way" but it's currently my way ;) -- I welcome any feedback! Pretty much all parameters for my stacks are using SSMParameterProvider. This provides me the by account/region configuration of a Stack I desire. I can use the same Important: Potential blocker: This doesn't account for optional parameters. Because cdk will fail to synth when it cannot locate an SSM Parameter with a given name, you must have an SSM Parameter with the desired name in every account/region you're going to launch the stack in. |
It appears there is no support for merging parameters, such as a deployment stage/application environment name (dev, qa, prod, etc) at deploy time, which would be ideal (so that I can build once and deploy many times), though not a deal breaker. However, I'm having trouble determining the best route for even passing them at synth time. It looks like I can pass context parameters using the I also see that I can add parameters into |
Might another way of handling this to be to have separate deployment stages to be separate files in Then I pick one to be the default in However, this doesn't neatly handle being able to create a deployment stage using a name I pass, ie creating a deployment based on the current git branch, or something. This could be bodged with environment variables I think, but I being able to create and teardown arbitrarily named deployments easily would be great. |
cicd is a key area where CDK could be useful, any guidance on how to do this correctly is greatly appreciated! |
This will be addressed as part of #3437 |
Maybe this can be of help: https://www.taimos.de/blog/deploying-your-cdk-app-to-different-stages-and-environments |
absolutely. Might be good to fix the contrast on the code syntax highlighting as the comments are pretty hard to read |
Thanks, fixed. |
An approach to deploying many stacks to different stages was outlined by @eladb on Gitter:
For this to work, each stack would need to have a different logical name based on the stage (e.g. "MyAppStackDev", "MyAppStackProd".
From @eladb
There is documentation to alludes to this approach in the docs, but I don't think the code sample there is still valid and it isn't clear to me how it would work.
The text was updated successfully, but these errors were encountered: