Skip to content
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

Merged
merged 8 commits into from
Apr 19, 2024

Conversation

M-Hawkins
Copy link
Contributor

@M-Hawkins M-Hawkins commented Mar 15, 2024

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

@github-actions github-actions bot added feature-request A feature should be added or improved. p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Mar 15, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team March 15, 2024 01:26
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a 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.

@M-Hawkins M-Hawkins changed the title feat(appconfig): Constrain environments to a single deployment at a time feat(appconfig): constrain environments to a single deployment at a time Mar 15, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review March 15, 2024 04:45

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Mar 15, 2024
@M-Hawkins M-Hawkins force-pushed the 29345-appconfig branch 5 times, most recently from 17211d0 to e64d69d Compare March 15, 2024 23:57
@shikha372 shikha372 assigned shikha372 and unassigned shikha372 Mar 16, 2024
Copy link
Contributor

@lpizzinidev lpizzinidev left a 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

packages/aws-cdk-lib/aws-appconfig/lib/environment.ts Outdated Show resolved Hide resolved
@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Contributor Author

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.

packages/aws-cdk-lib/aws-appconfig/lib/configuration.ts Outdated Show resolved Hide resolved
packages/aws-cdk-lib/aws-appconfig/README.md Outdated Show resolved Hide resolved
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Mar 16, 2024
Copy link
Contributor

@lpizzinidev lpizzinidev left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public readonly name? = undefined;
public readonly name = undefined;

Copy link
Contributor

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');
Copy link
Contributor

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.

Copy link
Contributor

@paulhcsun paulhcsun left a 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().

packages/aws-cdk-lib/aws-appconfig/README.md Show resolved Hide resolved
packages/aws-cdk-lib/aws-appconfig/README.md Show resolved Hide resolved
@@ -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;
Copy link
Contributor

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.

@M-Hawkins
Copy link
Contributor Author

Thanks for taking a look @paulhcsun !
I've pushed a new commit based on your feedback.

@paulhcsun
Copy link
Contributor

@Mergifyio update

@paulhcsun
Copy link
Contributor

Thanks again for this contribution @M-Hawkins!! And thanks as always for the review @lpizzinidev!

Copy link
Contributor

mergify bot commented Apr 18, 2024

update

✅ Branch has been successfully updated

Copy link
Contributor

mergify bot commented Apr 18, 2024

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-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Apr 18, 2024
@paulhcsun paulhcsun changed the title feat(appconfig): constrain environments to a single deployment at a time feat(appconfig): constrain environments to a single deployment at a time. Apr 18, 2024
@paulhcsun paulhcsun changed the title feat(appconfig): constrain environments to a single deployment at a time. feat(appconfig): constrain environments to a single deployment at a time Apr 18, 2024
@paulhcsun
Copy link
Contributor

https://github.com/Mergifyio update

Copy link
Contributor

mergify bot commented Apr 18, 2024

update

☑️ Nothing to do

  • #commits-behind>0 [📌 update requirement]
  • -closed [📌 update requirement]
  • -conflict [📌 update requirement]
  • queue-position=-1 [📌 update requirement]

@aws-cdk-automation
Copy link
Collaborator

@Mergifyio update

Copy link
Contributor

mergify bot commented Apr 19, 2024

update

✅ Branch has been successfully updated

Copy link
Contributor

mergify bot commented Apr 19, 2024

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 871d095
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 3dd834d into aws:main Apr 19, 2024
9 checks passed
Copy link
Contributor

mergify bot commented Apr 19, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

appconfig: Constrain environments to a single deployment at a time
5 participants