-
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(appconfig): constrain environments to a single deployment at a time #29500
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.
a6b974d
to
39218f8
Compare
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
17211d0
to
e64d69d
Compare
e64d69d
to
5f7015f
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.
Looks good overall 👍
Left notes for some adjustments
@@ -154,6 +179,7 @@ export class Environment extends EnvironmentBase { | |||
public readonly applicationId = applicationId; | |||
public readonly environmentId = environmentId; | |||
public readonly environmentArn = environmentArn; | |||
public readonly name?: string | undefined; |
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.
public readonly name?: string | undefined; | |
public readonly name?: string; |
I'm not sure this will be set so probably for environments imported with fromEnvironmentArn
the this.name!
in addDeployment
will throw.
Can you please verify?
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.
Yes, it will throw in that scenario and when the name is not provided to fromEnvironmentAttributes
.
My understanding is that behavior is the same for the current implementation.
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.
Thanks 👍
@@ -154,6 +183,7 @@ export class Environment extends EnvironmentBase { | |||
public readonly applicationId = applicationId; | |||
public readonly environmentId = environmentId; | |||
public readonly environmentArn = environmentArn; | |||
public readonly name? = undefined; |
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.
public readonly name? = undefined; | |
public readonly name = undefined; |
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 think having name as an optional property here is ok as it's only required when using the new methods.
|
||
public addDeployment(configuration: IConfiguration): void { | ||
if (this.name === undefined) { | ||
throw new Error('Environment name must be known to add a Deployment'); |
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.
Just a note.
We can probably change this behavior by using the environmentId
to build the CfnDeployment
id.
However, it would require a feature flag and it's out of scope for this PR.
72448c3
to
02fb3f2
Compare
02fb3f2
to
1121054
Compare
1121054
to
9673773
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.
Thanks for the contribution @M-Hawkins and thank you for your patience in waiting for a review! The changes looks reasonable to me, I've left a few comments on the descriptions and one question on the login in addDeployment()
.
@@ -154,6 +183,7 @@ export class Environment extends EnvironmentBase { | |||
public readonly applicationId = applicationId; | |||
public readonly environmentId = environmentId; | |||
public readonly environmentArn = environmentArn; | |||
public readonly name? = undefined; |
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 think having name as an optional property here is ok as it's only required when using the new methods.
9673773
to
54b8341
Compare
Thanks for taking a look @paulhcsun ! |
Thanks again for this contribution @M-Hawkins!! And thanks as always for the review @lpizzinidev! |
✅ Branch has been successfully updated |
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). |
☑️ Nothing to do
|
@Mergifyio update |
✅ Branch has been successfully updated |
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). |
Issue # (if applicable)
Closes #29345.
Reason for this change
The current L2 AppConfig constructs do not have any guardrails
that prevent simultaneous Deployments to a single Environment.
This is not allowed, and will result in Cfn deploy-time conflicts.
Description of changes
This commit adds a pair of new public methods to IEnvironment that
enable the addition of a new Deployment for a given IConfiguration.
It then updates the creation of new Deployments in ConfigurationBase
to utilize these new methods instead of the current resource creation.
These new methods interact with an internal queue.
This queue creates a chain of Cfn dependencies between Deployments
in order to enforce that only a single Deployment can be in progress
for the Environment at any given time.
Description of how you validated changes
Added new unit and integ test coverage.
Deployed the new integ test without these changes and confirmed that Cfn failed at deployment time.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license