Skip to content

feat(core): use literal for stack.partition (under feature flag)#21420

Merged
mergify[bot] merged 5 commits intoaws:mainfrom
jgrebholz:feat/partition_literal
Aug 12, 2022
Merged

feat(core): use literal for stack.partition (under feature flag)#21420
mergify[bot] merged 5 commits intoaws:mainfrom
jgrebholz:feat/partition_literal

Conversation

@jgrebholz
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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 jgrebholz force-pushed the feat/partition_literal branch from 8b5f370 to 95df59c Compare August 2, 2022 21:40
@mergify mergify bot dismissed TheRealAmazonKendra’s stale review August 2, 2022 21:41

Pull request has been modified.

@jgrebholz jgrebholz force-pushed the feat/partition_literal branch from 95df59c to 5d3ab5e Compare August 2, 2022 21:46
@jgrebholz
Copy link
Copy Markdown
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
Copy Markdown
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.

expect(stack.resolve(stack.region)).toEqual('es-norst-1');
});

describe('@aws-cdk/core:enablePartitionLiterals', () => {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

@jgrebholz jgrebholz force-pushed the feat/partition_literal branch from 5d3ab5e to 23bfcb3 Compare August 11, 2022 06:28
@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 jgrebholz force-pushed the feat/partition_literal branch from 23bfcb3 to 2b9eaf5 Compare August 11, 2022 06:33
@jgrebholz jgrebholz force-pushed the feat/partition_literal branch from 2b9eaf5 to 56cc0df Compare August 11, 2022 06:43
@jgrebholz
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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).

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