-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(core): validate maximum amount of resources in a stack #12193
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
rix0rrr
left a 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.
I like it, thanks!
With one change: I think we don't need the feature flag, this feels like something that can be enabled wholesale. The limit is unlikely to change anytime soon (it recently changed), and it's unlikely that there are valid use cases for having >500 resources in an undeployable template.
If you feel uncomfortable doing this, then I'd suggest putting the resource limit in a context settings, so people could set something like:
"context": {
"@aws-cdk/core.stackResourceLimit": 1000,
}
If they feel like it (and potentially we could have have 0 mean "no limit" to switch it off).
But honestly I don't think there's a need for such an elaborate mechanism.
packages/@aws-cdk/core/lib/stack.ts
Outdated
| if (numberOfResources > this.maxResources) { | ||
| throw new Error(`Number of resources: ${numberOfResources} is greater than allowed maximum of ${this.maxResources}`); | ||
| } else if (numberOfResources >= (this.maxResources * 0.8)) { | ||
| Annotations.of(this).addWarning(`Number of resources: ${numberOfResources} is approaching allowed maximum of ${this.maxResources}`); |
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.
Please change this into addMessage.
A warning may have the effect of breaking deployment, if deployment is run using --strict (which turns warnings into errors).
This is a warning, but it's a different kind of warning from the regular ones.
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.
Would you mean addInfo?
Because the addMessage is a private method from Annotations!
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.
Oh, doh. Yes addInfo.
|
Thank you for contributing! Your pull request will be updated from master 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 master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
closes #276
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license