Skip to content

fix(cloudfront): add region to autogenerated name for cloudfront origin request policy #34348

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rclark
Copy link

@rclark rclark commented May 3, 2025

Issue # (if applicable)

Closes #34336

Reason for this change

So that a stack defining an origin request policy can be easily deployed into more than one region in a single account.

Description of changes

Followed the same naming convention already in place for cache policies, which was added in #13737

Describe any new or updated permissions being added

Description of how you validated changes

Adjusted an existing unit test to recognize the new name

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team May 3, 2025 23:19
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels May 3, 2025
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:

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

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.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@rclark rclark changed the title Add region to autogenerated name for cloudfront origin request policy fix(cloudfront): Add region to autogenerated name for cloudfront origin request policy May 3, 2025
@rclark rclark changed the title fix(cloudfront): Add region to autogenerated name for cloudfront origin request policy fix(cloudfront): add region to autogenerated name for cloudfront origin request policy May 3, 2025
@rclark
Copy link
Author

rclark commented May 3, 2025

Exemption Request:

Fixes must contain a change to an integration test file and the resulting snapshot.

The existing integration test for cache policy & origin request policy explicitly set the resource name properties

Not sure if you'd want to see the autogenerated name behavior in the integration suite or not?

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@aws-cdk-automation aws-cdk-automation added pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels May 5, 2025
@@ -94,7 +94,7 @@ export class OriginRequestPolicy extends Resource implements IOriginRequestPolic
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

const originRequestPolicyName = props.originRequestPolicyName ?? Names.uniqueId(this);
const originRequestPolicyName = props.originRequestPolicyName ?? `${Names.uniqueId(this).slice(0, 110)}-${Stack.of(this).region}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

can you confirm whether this will cause replacement of the existing resource ?

Copy link
Author

Choose a reason for hiding this comment

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

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-originrequestpolicy.html

Docs state that changing the OriginRequestPolicyConfig require no interruption.

Furthermore, changing the Name inside the OriginRequestPolicyConfig also says it requires no interruption.

@shikha372
Copy link
Contributor

Exemption Request:

Fixes must contain a change to an integration test file and the resulting snapshot.

The existing integration test for cache policy & origin request policy explicitly set the resource name properties

Not sure if you'd want to see the autogenerated name behavior in the integration suite or not?

Thanks for identifying the missing integ test gap, i think we should add new one for this use-case.

@shikha372 shikha372 removed the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label May 6, 2025
@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 May 6, 2025
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 bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-cloudfront: default origin request policy name should include region
3 participants