-
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
feat: decouple "synth" and "deploy" through cloud assemblies #2636
Conversation
formalize the concept of a cloud assembly to allow decoupling "synth" and "deploy". the main motivation is to allow "deploy" to run in a controlled environment without needing to execute the app for security purposes. "cdk synth" now produces a self-contained assembly in the output directory, which we call a "cloud assembly". this directory includes synthesized templates (similar to current behavior) but also a "manifest.json" file and the asset staging directories. "cdk deploy -a <assembly-dir>" will now skip synthesis and will directly deploy the assembly. to that end, we modified the behavior of asset staging such that all synth output always goes to the output directory, which is by default `cdk.out` (can be set with `--output`). if there's a single template, it is printed to stdout, otherwise the name of output directory is printed. BREAKING CHANGE: apps created with this version cannot be deployed using a previous version of the CLI and vice versa. Both have to be >= 0.32.0. - @aws-cdk/cdk.App member synthesizeStack has been removed - @aws-cdk/cdk.App member synthesizeStacks has been removed - @aws-cdk/cdk.FileSystemStore has been removed - @aws-cdk/cdk.InMemoryStore has been removed - @aws-cdk/cdk.SynthesisSession member addBuildStep has been removed - @aws-cdk/cdk.SynthesisSession member store has been removed - @aws-cdk/cdk.FileSystemStoreOptions has been removed - @aws-cdk/cdk.ISessionStore has been removed - @aws-cdk/cdk.ISynthesisSession member addBuildStep has been removed - @aws-cdk/cdk.ISynthesisSession member store has been removed - @aws-cdk/cdk.ManifestOptions member legacyManifest has been removed - @aws-cdk/cdk.ResolveContext has been removed - @aws-cdk/cdk.SynthesisOptions member legacyManifest has been removed - @aws-cdk/cdk.SynthesisOptions member store has been removed - @aws-cdk/cx-api.BuildManifest has been removed - @aws-cdk/cx-api.BuildStep has been removed - @aws-cdk/cx-api.SynthesizeResponse has been removed - @aws-cdk/cx-api.SynthesizedStack has been removed - @aws-cdk/cx-api.BuildStepType has been removed - --interactive has been removed - --numbered has been removed
I don't like this behavior. It's good for humans but horrible to script around. Let's make our tools easy to automate, please?
I agree with the ultimate refactorings, which we've talked about previously, but I hope this is not a stepping stone towards |
I agree with @rix0rrr on this one. I prefer the tool behaves in exactly one way. If you want to keep the behavior of outputting to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty good overall! I don't have much to say here, besides a couple of things that look a little odd to me (possibly waved away with an explanation?) or having names that I don't like much.
|
||
private validateDeps() { | ||
for (const artifact of this.artifacts) { | ||
ignore(artifact.depends); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this read artifact.dependencies
?
this.assets = this.buildAssets(); | ||
} | ||
|
||
private buildAssets() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sort of suggested to me that the actual build process was happening here - but this really just makes an array... Could call collectAssets
instead.
@@ -88,7 +88,7 @@ function invalidateContext(context: Context, key: string) { | |||
// Unset! | |||
if (context.has(key)) { | |||
context.unset(key); | |||
print(`Context value ${colors.blue(key)} reset. It will be refreshed on the next SDK synthesis run.`); | |||
print(`Context value ${colors.blue(key)} reset. It will be refreshed on next synthesis`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should hint that it means network + credentials are needed on the next execution.
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Formalize the concept of a cloud assembly to allow decoupling "synth" and "deploy". the main
motivation is to allow "deploy" to run in a controlled environment without needing to execute the app for security purposes.
cdk synth
now produces a self-contained assembly in the output directory, which we call a "cloud assembly". this directory includes synthesized templates (similar to current behavior) but also a "manifest.json" file and the asset staging directories.cdk deploy -a assembly-dir
will now skip synthesis and will directly deploy the assembly.To that end, we modified the behavior of asset staging such that all synth output always goes to the output directory, which is by default
cdk.out
(can be set with--output
). if there's a single template, it is printed to stdout, otherwise the name of output directory is printed.This PR also includes multiple clean ups and deprecations of stale APIs and modules such as:
cdk.AppProps
includes various new options.ConstructNode.root
which returns the tree root.TESTING: verified that all integration tests passed and added a few tests to verify zip and docker assets as well as cloud assemblies. See: https://github.com/awslabs/cdk-ops/pull/364
Closes #1893
Closes #2093
Closes #1954
Closes #2310
Related #2073
Closes #1245
Closes #341
Closes #956
Closes #233
BREAKING CHANGE: IMPORTANT: apps created with the CDK version 0.33.0 and above cannot be used with an older CLI version.
--interactive
has been removed--numbered
has been removed--staging
is now a boolean flag that indicates whether assets should be copied to the--output
directory or directly referenced (--no-staging
is useful for e.g. local debugging with SAM CLI)SynthUtils.templateForStackName
has been removed (useSynthUtils.synthesize(stack).template
).cxapi.SynthesizedStack
renamed tocxapi.CloudFormationStackArtifact
with multiple API changes.cdk.App.run()
now returns acxapi.CloudAssembly
instead ofcdk.ISynthesisSession
.cdk.App.synthesizeStack
andsynthesizeStacks
has been removed. Thecxapi.CloudAssembly
object returned fromapp.run()
can be used as an alternative to explore a synthesized assembly programmatically (resolves App.synthesize methods are marked as deprecated with no replacement #2016).cdk.CfnElement.creationTimeStamp
may now returnundefined
if there is no stack trace captured.cdk.ISynthesizable.synthesize
now accepts acxapi.CloudAssemblyBuilder
instead ofISynthesisSession
.cdk
: The concepts of a synthesis session and session stores have been removed (cdk.FileSystemStore
, cdk.InMemoryStore,
cdk.SynthesisSession,
cdk.ISynthesisSessionand
cdk.SynthesisOptions`).cdk.ManifestOptions
memberlegacyManifest
has been removed)cxapi.BuildManifest
,cxapi.BuildStep
, etc).cxapi
module (cxapi.AppRuntime
has been renamed tocxapi.RuntimeInfo
,cxapi.SynthesizeResponse
,cxapi.SynthesizedStack
has been removed)@aws-cdk/applet-js
program is no longer available. Use decdk as an alternative.Pull Request Checklist
design
folderBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.