-
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
fix(cdk): Resolve cross stack and default parameters for hotswaps #27195
Conversation
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 has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
…urrent modifications
fba873c
to
4261163
Compare
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.
I need to understand the addition of the sdk
to an EvaluateCloudFormationTemplate
before I can give this a better review.
account: this.account, | ||
region: this.region, | ||
partition: this.partition, | ||
urlSuffix: this.urlSuffix, | ||
listStackResources: listNestedStackResources, | ||
sdk: this.sdk, |
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.
why do we need this here?
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.
In current CDK, evaluate-cloudformation-template
can only evaluate CFN (Intrinsic) Fn references for resources in the same stack (Let's call it A) and hence it is passed a list of A's resources to assist in evaluation.
However the problem comes when a resource in A stack references resources in a different stack (Let's call it B). In that case evaluate-cloudformation-template
of A has no knowledge of it.
This PR refactors evaluate-cloudformation-template
in a way that it can recursively instantiate another evaluate-cloudformation-template
for the referenced stack. And to do that, A's evaluate-cloudformation-template
needs to pass in the list of B's resources while creating another instance and hence the sdk
needs to be passed in for the A's evaluate-cloudformation-template
so that it can call B's listResources
Now, instead of having the caller to get the list of stack's resources and pass it to evaluate-cloudformation-template
, it's better for evaluate-cloudformation-template
to manage it on it's own, since these resources are specifically being used by the evaluate-cloudformation-template
and instead just pass the sdk rather than both sdk
and the stackResources
// The current resources of the Stack. | ||
// We need them to figure out the physical name of a resource in case it wasn't specified by the user. | ||
// We fetch it lazily, to save a service call, in case all hotswapped resources have their physical names set. | ||
const listStackResources = new LazyListStackResources(sdk, stackArtifact.stackName); |
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 has been moved elsewhere, could you explain why? I don't see why this is necessary.
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.
Answered here #27195 (comment)
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.
Great work! This will merge soon, just need the integ tests to pass
Apologies, I stopped the integ test progress on this because I thought it was a change I pushed. I've restarted it now. |
➡️ PR build request submitted to A maintainer must now check the pipeline and add the |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
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). |
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). |
This PR solves two problems when doing hotswap deployments with nested stacks.
AWS::CloudFormation::Stack
type (i.e. a nested stack). In this PR, we are only resolvingOutputs
section ofAWS::CloudFormation::Stack
and it can be expanded to other fields in the future. See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-cloudformation.html#w2ab1c17c23c19b5 for CFN documentation around using Outputs ref parametersPartially helps #23533 and #25418
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license