-
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
feat(cli): assets can now depend on stacks #25536
Conversation
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
this.addNodes(...Object.values(graph.nodes)); | ||
} | ||
|
||
public hasFailed(): boolean { |
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 used to be public because it was being used in deploy.ts but now it is only being used in the private forAllArtifacts
method. I think we should make it private as well.
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 actually kinda like it. But you're right, we don't need it for now.
/** | ||
* Return the set of unblocked nodes | ||
*/ | ||
public ready(): ReadonlyArray<WorkNode> { |
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.
same for ready()
, this is being used in one test
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.
Yeah, but we do need to be able to write that test.
// }), | ||
// })); | ||
// }); | ||
// }); |
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.
was previously marked as resolved but i still see the commented out tests and I feel like if for some reason we wanted to keep these in here, then we should document better why that is the case.
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 extends #25536 by fixing issues with logging. - Asset building and publishing are now completely separate tasks, so there is never a need for the "Building and Publishing" message in cdk-assets. I've removed a good chunk of unnecessary private props in `AssetPublisher` and now we simply print `Building` when building an asset and `Publishing` when publishing an asset. No combos anymore. - Asset build/publish can now happen concurrently with stack deployments when there are no dependencies between the two, but if `--require-approval` is set (which it is by default), sensitive stack deployments prompt the user for a `y/n` response before deployment. Additional asset related messages may come in at this time, cluttering the log. The solution here is to implement a cork that is turned on when prompting the user and turned off after user input. When using the helper function `withCorkedLogging(callback)`, logs will instead be stored in memory and released when the cork is popped. Testing: There's not a great way to test these changes in code since they should only affect logging. Instead, I hope the following photos suffice: Before the lock change, logging looked like this: <img width="698" alt="Screen Shot 2023-05-18 at 4 59 35 PM" src="https://github.com/aws/aws-cdk/assets/36202692/c554c1f2-1034-422c-95e6-ebf15f09b35b"> Now it looks like this in the same scenario: <img width="697" alt="Screen Shot 2023-05-18 at 4 49 39 PM" src="https://github.com/aws/aws-cdk/assets/36202692/1257c20e-73c4-4fc2-b8cd-ae510f32c756"> The screenshots also show the logs that say `Building` and `Publishing` separately rather than `Building and Publishing` as it did before. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR introduces a new synthesizer inside the module `app-staging-synthesizer-alpha`. This new synthesizer produces staging resources alongside the CDK application and assets will be stored there. It removes the need for running `cdk bootstrap` before deploying a CDK app in a new account/region. Under the new synthesizer, assets between different CDK applications will be separated which means they can be cleaned up and lifecycle controlled independently. To get started, add the following to your CDK application: ```ts const app = new App({ defaultStackSynthesizer: AppStagingSynthesizer.defaultResources({ appId: 'my-app-id', // put a unique id here }), }); ``` The new format of staging resources will look something like this: ```text ┌─────────────────────────────┐┌───────────────────────────────────────┐┌───────────────────────────────────────┐ │ ││ ││ │ │ ┌───────────────┐ ││ ┌──────────────┐ ││ ┌──────────────┐ │ │ │Bootstrap Stack│ ││ │ CDK App 1 │ ││ │ CDK App 2 │ │ │ └───────────────┘ ││ └──────────────┘ ││ └──────────────┘ │ │ ││┌──────────────────┐ ││┌──────────────────┐ │ │ │││ ┌──────────────┐ │ │││ ┌──────────────┐ │ │ │ │││ │Staging Stack │ │ │││ │Staging Stack │ │ │ │ │││ └──────────────┘ │ │││ └──────────────┘ │ │ │ │││ │ │││ │ │ │ │││ │ │││ │ │ │ │││┌────────────────┐│ ┌────────────┐│││┌────────────────┐│ ┌────────────┐│ │ ││││ IAM Role for ││ ┌───│ S3 Asset │││││ IAM Role for ││ ┌───│ S3 Asset ││ │ ││││File Publishing ││ │ └────────────┘││││File Publishing ││ │ └────────────┘│ │ │││└────────────────┘│ │ ││││ IAM Role for ││ │ │ │ │││ │ │ ││││Image Publishing││ │ │ │┌───────────────────────────┐│││ │ │ │││└────────────────┘│ │ │ ││IAM Role for CFN execution ││││ │ │ │││ │ │ │ ││ IAM Role for lookup ││││ │ │ │││ │ │ │ ││ IAM Role for deployment ││││┌────────────────┐│ │ │││┌────────────────┐│ │ │ │└───────────────────────────┘││││ S3 Bucket for ││ │ ││││ S3 Bucket for ││ │ │ │ ││││ Staging Assets │◀─┘ ││││ Staging Assets │◀─┘ │ │ │││└────────────────┘│ │││└────────────────┘│ ┌───────────┐│ │ │││ │ │││ │ ┌───│ ECR Asset ││ │ │││ │ │││┌────────────────┐│ │ └───────────┘│ │ │││ │ ││││ ECR Repository ││ │ │ │ │││ │ ││││ for Staging │◀──┘ │ │ │││ │ ││││ Assets ││ │ │ │││ │ │││└────────────────┘│ │ │ │││ │ │││ │ │ │ │││ │ │││ │ │ │ │││ │ │││ │ │ │ │││ │ │││ │ │ │ │││ │ │││ │ │ │ ││└──────────────────┘ ││└──────────────────┘ │ └─────────────────────────────┘└───────────────────────────────────────┘└───────────────────────────────────────┘ ``` This feature is heavily experimental and the API may break in the future. It does not work with CDK Pipelines yet. Depended on #25536. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…25846) In #25536 we introduced the new work graph orchestration for the CLI which had a bug when the same asset was shared by multiple stacks. #25719 was an attempt at fixing this bug, and while it fixed it for some cases it didn't fix all of them. The issue is that for cosmetic reasons, asset publishing steps inherit the dependencies of the stacks they are publishing for (so that the printed output of asset publishing doesn't interfere with the in-place updated progress bar of stack deployment and make it lose track of the terminal state). There were two bugs: * These extra dependencies could cause cycles (#25719 addressed direct cycles, where `Publish <--> Stack`, but not indirect cycles, where `Publish -> StackA -> StackB -> Publish`). * Publishing nodes would overwrite other nodes with the same ID, and the dependency set they would end up with would be somewhat nondeterministic, making this problem hard to isolate. Fixes #25806. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Introduce a work graph, in which building assets, publishing assets, and deploying stacks are nodes. Each can have their own sets of dependencies which will be respected in a parallel deployment.
This change supports an upcoming change for asset publishing.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license