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(core): allow overriding the stage name #22223

Merged
merged 2 commits into from
Sep 30, 2022
Merged

Conversation

danilobuerger
Copy link
Contributor

@danilobuerger danilobuerger commented Sep 25, 2022

Currently the stage name is derived from the id of the stage and later becomes part of each stack name inside the stage:

this.stageName = [this.parentStage?.stageName, id].filter(x => x).join('-');

private generateStackName() {
const assembly = Stage.of(this);
const prefix = (assembly && assembly.stageName) ? `${assembly.stageName}-` : '';
return `${prefix}${this.generateStackId(assembly)}`;
}

Since the ids in a scope must be different, deploying the same stage in the same scope to multiple regions would require different ids and would then lead to different stack names in the end. To keep stack names uniform across regions, a stack already allows customising the stack name uncoupled from the id:

/**
* Name to deploy the stack with
*
* @default - Derived from construct path.
*/
readonly stackName?: string;

This PR follows up on that concept and also allows customising the stage name.

This would then allow to deploy the same stage in the same scope to multiple regions while keeping the resulting stack names the same across regions.


All Submissions:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Sep 25, 2022

@github-actions github-actions bot added the p2 label Sep 25, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team September 25, 2022 08:40
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Sep 25, 2022
Copy link

@github-actions github-actions bot 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 fails with the following errors:

❌ Features must contain a change to a README file.
❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

@danilobuerger
Copy link
Contributor Author

The README of core doesn't describe Stage in detail, is it really necessary to modify it for this change?

Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

Please make sure that your PR body describes the problem the PR is solving, and the design approach and alternatives considered. Explain why the PR solves the problem. A link to an issue is helpful, but does not replace an explanation of your thought process (See Contributing Guide, Pull Requests)

@danilobuerger
Copy link
Contributor Author

@TheRealAmazonKendra thanks for helping me. I updated the PR to explain my PR better. I hope its enough?

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 fails with the following errors:

❌ Features must contain a change to a README file.
❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

@corymhall corymhall added pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Sep 30, 2022
@corymhall corymhall dismissed stale reviews from TheRealAmazonKendra and github-actions[bot] September 30, 2022 12:59

comments addressed

corymhall
corymhall previously approved these changes Sep 30, 2022
@aws-cdk-automation aws-cdk-automation dismissed their stale review September 30, 2022 13:00

Pull Request updated. Dissmissing previous PRLinter Review.

@corymhall corymhall added the pr/do-not-merge This PR should not be merged at this time. label Sep 30, 2022
@corymhall corymhall removed the pr/do-not-merge This PR should not be merged at this time. label Sep 30, 2022
@mergify
Copy link
Contributor

mergify bot commented Sep 30, 2022

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: cec7eaf
  • 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 3d227e5 into aws:main Sep 30, 2022
@mergify
Copy link
Contributor

mergify bot commented Sep 30, 2022

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

arewa pushed a commit to arewa/aws-cdk that referenced this pull request Oct 8, 2022
Currently the stage name is derived from the id of the stage and later becomes part of each stack name inside the stage:

https://github.com/aws/aws-cdk/blob/c425e8ca1a3d296eb6a7fd7e005d07c1eadd16aa/packages/%40aws-cdk/core/lib/stage.ts#L139

https://github.com/aws/aws-cdk/blob/c425e8ca1a3d296eb6a7fd7e005d07c1eadd16aa/packages/%40aws-cdk/core/lib/stack.ts#L1139-L1143

Since the ids in a scope must be different, deploying the same stage in the same scope to multiple regions would require different ids and would then lead to different stack names in the end. To keep stack names uniform across regions, a stack already allows customising the stack name uncoupled from the id:

https://github.com/aws/aws-cdk/blob/c425e8ca1a3d296eb6a7fd7e005d07c1eadd16aa/packages/%40aws-cdk/core/lib/stack.ts#L106-L111

This PR follows up on that concept and also allows customising the stage name.

This would then allow to deploy the same stage in the same scope to multiple regions while keeping the resulting stack names the same across regions.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
homakk pushed a commit to homakk/aws-cdk that referenced this pull request Dec 1, 2022
Currently the stage name is derived from the id of the stage and later becomes part of each stack name inside the stage:

https://github.com/aws/aws-cdk/blob/c425e8ca1a3d296eb6a7fd7e005d07c1eadd16aa/packages/%40aws-cdk/core/lib/stage.ts#L139

https://github.com/aws/aws-cdk/blob/c425e8ca1a3d296eb6a7fd7e005d07c1eadd16aa/packages/%40aws-cdk/core/lib/stack.ts#L1139-L1143

Since the ids in a scope must be different, deploying the same stage in the same scope to multiple regions would require different ids and would then lead to different stack names in the end. To keep stack names uniform across regions, a stack already allows customising the stack name uncoupled from the id:

https://github.com/aws/aws-cdk/blob/c425e8ca1a3d296eb6a7fd7e005d07c1eadd16aa/packages/%40aws-cdk/core/lib/stack.ts#L106-L111

This PR follows up on that concept and also allows customising the stage name.

This would then allow to deploy the same stage in the same scope to multiple regions while keeping the resulting stack names the same across regions.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
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 p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants