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): use literal for stack.partition (under feature flag) #21420

Merged
merged 5 commits into from
Aug 12, 2022

Conversation

jgrebholz
Copy link
Contributor

@jgrebholz jgrebholz commented Aug 2, 2022

closes #4092

When a Stack's region is a string literal, we can return a string
literal from Stack.partition, resulting in easier to read generated
templates.

The feature flag to enable this behavior is @aws-cdk/core:enablePartitionLiterals.


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

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 Aug 2, 2022

@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 labels Aug 2, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team August 2, 2022 13:51
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.

For any customers relying on the output of partition(), this will be a breaking change, as evidenced by the integration tests being broken in other parts of the code base.

I suppose that it can be submitted under a feature flag but I'm not sure the value of it is worth adding another one.

@jgrebholz
Copy link
Contributor Author

Thanks for your review @TheRealAmazonKendra I've updated the PR to include a feature flag, a minor update to the README, and confirmed the previously failing aws-iam integ tests are passing now.

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.

Looks like there are more test failures to attend to. Note that integration tests have feature flags enabled by default so anywhere that's using this function without a token will update. This may take a few rounds to discover all the locations of the failures.

@@ -867,6 +867,43 @@ describe('stack', () => {
expect(stack.resolve(stack.region)).toEqual('es-norst-1');
});

describe('@aws-cdk/core:enablePartitionLiterals', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make this descriptive instead of listing the flag. Better readability that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done in the latest update; thanks

@TheRealAmazonKendra TheRealAmazonKendra changed the title feat(core): use literal for stack.partition (#4092) feat(core): use literal for stack.partition Aug 2, 2022
@TheRealAmazonKendra
Copy link
Contributor

Oh, I almost forgot, now that this is behind a feature flag, please update your PR to reflect that. We have specific formatting instructions in our contributing guide.

Comment on lines +322 to +328
* AWS:
* Fn::Join:
* - ""
* - - "arn:"
* - Ref: AWS::Partition
* - :iam::123456789876:root
Copy link
Contributor

@rix0rrr rix0rrr Aug 8, 2022

Choose a reason for hiding this comment

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

Comments are in Markdown. This needs triple backticks around it to be formatted in monospace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review, I'll get this fixed in the next push

Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

This PR changes suspiciously little. I would have expected literally every integration test to blow up, and how confident are we that RegionInfo is correct for all these regions?

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review August 11, 2022 06:29

Pull request has been modified.

@jgrebholz jgrebholz changed the title feat(core): use literal for stack.partition feat(core): use literal for stack.partition (under feature flag) Aug 11, 2022
@jgrebholz
Copy link
Contributor Author

The most recent push includes the results of yarn integ --update-on-failed for each of the failing integration tests needed for my local run of ./build.sh to succeed. I'll review the results of the build fleet tomorrow and update as needed. I'm not sure why so many integ tests reported UNCHANGED on their snapshot comparisons, but I'm happy to investigate any that you think should be objecting. Is it possible they're using AWS.Region or a stack parameter for region?

The RegionInfo looks correct to me with 30 regions:

$ cat built-ins.generated.ts | grep FactName.PARTITION | awk '{print $3, $7;}'
"af-south-1", "aws"
"ap-east-1", "aws"
"ap-northeast-1", "aws"
"ap-northeast-2", "aws"
"ap-northeast-3", "aws"
"ap-south-1", "aws"
"ap-southeast-1", "aws"
"ap-southeast-2", "aws"
"ap-southeast-3", "aws"
"ca-central-1", "aws"
"cn-north-1", "aws-cn"
"cn-northwest-1", "aws-cn"
"eu-central-1", "aws"
"eu-north-1", "aws"
"eu-south-1", "aws"
"eu-south-2", "aws"
"eu-west-1", "aws"
"eu-west-2", "aws"
"eu-west-3", "aws"
"me-south-1", "aws"
"sa-east-1", "aws"
"us-east-1", "aws"
"us-east-2", "aws"
"us-gov-east-1", "aws-us-gov"
"us-gov-west-1", "aws-us-gov"
"us-iso-east-1", "aws-iso"
"us-iso-west-1", "aws-iso"
"us-isob-east-1", "aws-iso-b"
"us-west-1", "aws"
"us-west-2", "aws"

@TheRealAmazonKendra TheRealAmazonKendra added pr-linter/exempt-readme The PR linter will not require README changes and removed pr-linter/exempt-readme The PR linter will not require README changes labels Aug 11, 2022
@TheRealAmazonKendra
Copy link
Contributor

I'm confused about why the linter is failing. There are updates to READMEs in this change.

@TheRealAmazonKendra TheRealAmazonKendra added the pr-linter/exempt-readme The PR linter will not require README changes label Aug 11, 2022
@mergify
Copy link
Contributor

mergify bot commented Aug 12, 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).

1 similar comment
@mergify
Copy link
Contributor

mergify bot commented Aug 12, 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: 0f82798
  • 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 401b428 into aws:main Aug 12, 2022
@mergify
Copy link
Contributor

mergify bot commented Aug 12, 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).

josephedward pushed a commit to josephedward/aws-cdk that referenced this pull request Aug 30, 2022
…#21420)

closes aws#4092

When a Stack's region is a string literal, we can return a string
literal from Stack.partition, resulting in easier to read generated
templates.

The feature flag to enable this behavior is `@aws-cdk/core:enablePartitionLiterals`.

----

### All Submissions:

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

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*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
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 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.

Make stack.partition concrete if region is concrete
4 participants