-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(core): make StackSynthesizer
easier to subclass
#22308
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
Conversation
`StackSynthesizer`s used to make heavy use of private APIs, which make it impossible for people outside the CDK core framework to implement their own Stack Synthesizers and modify the way assets are referenced. This question comes up more and more, so this PR opens up the facilities for doing that. The changes are as follows: - Implement `bind()` in `StackSynthesizer`, and add a getter called `boundStack` which will return the bound stack. - Change `synthesizeStackTemplate -> synthesizeTemplate`, `emitStackArtifact -> emitArtifact`, both of which will implicitly operate on the bound stack. - Add `addBootstrapVersionRule` so that any subclass can choose to use this or not. - Expose `AssetManifestBuilder`, which stack synthesizers can use to build an asset manifest. Refactor the class to do less at the same time. - Expose `cloudFormationLocationFrom...Asset` functions to translate a published asset location into a CloudFormation location. - Document the contract of each method better. The end result is that it will be easier to mix and match the different behaviors of the existing synthesizers together into new custom behavior. Two new unit test files have been added to show how it is possible to write ONE intruction to the asset manifest (to upload assets to a given location) while returning a completely different instruction to the template (referencing the asset bucket using a CloudFormation parameter).
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.
The Pull Request Linter fails with the following errors:
❌ Features must contain a change to a README file.
❌ Features must contain a change to an integration test file and the resulting snapshot.
PRs must pass status checks before we can provide a meaningful review.
Pull Request updated. Dissmissing previous PRLinter Review.
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.
The Pull Request Linter fails with the following errors:
❌ Features must contain a change to a README file.
❌ Features must contain a change to an integration test file and the resulting snapshot.
PRs must pass status checks before we can provide a meaningful review.
Pull Request updated. Dissmissing previous PRLinter Review.
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.
The Pull Request Linter fails with the following errors:
❌ Features must contain a change to a README file.
❌ Features must contain a change to an integration test file and the resulting snapshot.
PRs must pass status checks before we can provide a meaningful review.
Pull Request updated. Dissmissing previous PRLinter Review.
@Mergifyio update |
✅ Branch has been successfully updated |
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.
Looks good, added the do-not-merge
label in case you'd like another approval.
import { AssetManifestArtifact } from '@aws-cdk/cx-api'; | ||
import { DockerImageAsset } from '../lib'; | ||
|
||
// const DEMO_IMAGE_ASSET_HASH = '0a3355be12051c9984bf2b0b2bba4e6ea535968e5b6e7396449701732fe5ed14'; |
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.
Left over or should have more context to be considered part of docs?
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
`StackSynthesizer`s used to make heavy use of private APIs, which make it impossible for people outside the CDK core framework to implement their own Stack Synthesizers and modify the way assets are referenced. This question comes up more and more, so this PR opens up the facilities for doing that. The changes are as follows: - Implement `bind()` in `StackSynthesizer`, and add a getter called `boundStack` which will return the bound stack. - Change `synthesizeStackTemplate -> synthesizeTemplate`, `emitStackArtifact -> emitArtifact`, both of which will implicitly operate on the bound stack. - Add `addBootstrapVersionRule` so that any subclass can choose to use this or not. - Expose `AssetManifestBuilder`, which stack synthesizers can use to build an asset manifest. Refactor the class to do less at the same time. - Expose `cloudFormationLocationFrom...Asset` functions to translate a published asset location into a CloudFormation location. - Document the contract of each method better. The end result is that it will be easier to mix and match the different behaviors of the existing synthesizers together into new custom behavior. Two new unit test files have been added to show how it is possible to write ONE intruction to the asset manifest (to upload assets to a given location) while returning a completely different instruction to the template (referencing the asset bucket using a CloudFormation parameter). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
`StackSynthesizer`s used to make heavy use of private APIs, which make it impossible for people outside the CDK core framework to implement their own Stack Synthesizers and modify the way assets are referenced. This question comes up more and more, so this PR opens up the facilities for doing that. The changes are as follows: - Implement `bind()` in `StackSynthesizer`, and add a getter called `boundStack` which will return the bound stack. - Change `synthesizeStackTemplate -> synthesizeTemplate`, `emitStackArtifact -> emitArtifact`, both of which will implicitly operate on the bound stack. - Add `addBootstrapVersionRule` so that any subclass can choose to use this or not. - Expose `AssetManifestBuilder`, which stack synthesizers can use to build an asset manifest. Refactor the class to do less at the same time. - Expose `cloudFormationLocationFrom...Asset` functions to translate a published asset location into a CloudFormation location. - Document the contract of each method better. The end result is that it will be easier to mix and match the different behaviors of the existing synthesizers together into new custom behavior. Two new unit test files have been added to show how it is possible to write ONE intruction to the asset manifest (to upload assets to a given location) while returning a completely different instruction to the template (referencing the asset bucket using a CloudFormation parameter). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
StackSynthesizer
s used to make heavy use of private APIs, which make it impossible for people outside the CDK core framework to implement their own Stack Synthesizers and modify the way assets are referenced. This question comes up more and more, so this PR opens up the facilities for doing that.The changes are as follows:
bind()
inStackSynthesizer
, and add a getter calledboundStack
which will return the bound stack.synthesizeStackTemplate -> synthesizeTemplate
,emitStackArtifact -> emitArtifact
, both of which will implicitly operate on the bound stack.addBootstrapVersionRule
so that any subclass can choose to use this or not.AssetManifestBuilder
, which stack synthesizers can use to build an asset manifest. Refactor the class to do less at the same time.cloudFormationLocationFrom...Asset
functions to translate a published asset location into a CloudFormation location.The end result is that it will be easier to mix and match the different behaviors of the existing synthesizers together into new custom behavior.
Two new unit test files have been added to show how it is possible to write ONE intruction to the asset manifest (to upload assets to a given location) while returning a completely different instruction to the template (referencing the asset bucket using a CloudFormation parameter).
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license