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

fix(cloudfront): propagate originAccessControlId CloudFront Origin property to CloudFormation templates #32020

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ivanbarlog
Copy link

Issue

Closes #32018.

Reason for this change

The originAccessControlId property of CloudFront Origin has not been propagated to CloudFormation templates.

Description of changes

Propagate the property to render function.

Description of how you validated changes

have run the run build over the whole repo - my computer almost exploded.

I have also run tests for the aws-cloudfront which run successfully.

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 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. labels Nov 5, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team November 5, 2024 06:12
@github-actions github-actions bot added the p2 label Nov 5, 2024
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.

@ivanbarlog ivanbarlog changed the title propagate originAccessControlId CloudFront Origin property to CloudFormation templates fix(cloudfront origin): propagate originAccessControlId CloudFront Origin property to CloudFormation templates Nov 5, 2024
@ivanbarlog
Copy link
Author

Exemption Request

I've just fixed the place where the value which supposed to be rendered in the CloudFormation template was missing. It was set in the L2 construct but not propagated to the CloudFormation template.

I don't really see how can I write test for this.

Can you please guide me with this?

@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 Nov 5, 2024
@ivanbarlog ivanbarlog changed the title fix(cloudfront origin): propagate originAccessControlId CloudFront Origin property to CloudFormation templates fix(cloudfront): propagate originAccessControlId CloudFront Origin property to CloudFormation templates Nov 7, 2024
@github-actions github-actions bot added the effort/small Small work item – less than a day of effort label Nov 7, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review November 7, 2024 19:18

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

@ivanbarlog ivanbarlog force-pushed the issue-32018 branch 3 times, most recently from 7878d5a to 46c5e96 Compare November 13, 2024 16:29
Copy link
Contributor

@gracelu0 gracelu0 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 opening a PR! I left a comment on updating the tests. I don't think we need an integration test here so once unit tests are updated I can add the exemption label.

defaultBehavior: { origin: new origins.FunctionUrlOrigin(fnUrl) },
defaultBehavior: {
origin: new origins.FunctionUrlOrigin(fnUrl, {
originAccessControlId: oac.attrId,
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 we can add a new unit test instead of updating this integration test. For the unit test I'd suggest:

  • adding a new function to test-origin.ts here which returns a test origin with originAccessControlId defined
  • adding a unit test to distribution.test.ts which sets up a distribution using the test origin from above and check that the Origin property in DistributionConfig contains OriginAccessControlId (can reference existing unit test here)

Let me know if you need more guidance on this.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @gracelu0, thanks for the feedback!

I have removed the integration tests (which your automated CI forced me to write) and I hope I've added the unit tests correctly. It has run for me so let's see what CI will tell us :-)

Thanks for help!

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.

@gracelu0 gracelu0 added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Nov 21, 2024
@gracelu0
Copy link
Contributor

@ivanbarlog I think the build failed due to some lint errors, try running yarn lint --fix from the root to fix the formatting issues and then I believe the build should pass

@aws-cdk-automation aws-cdk-automation dismissed their stale review November 21, 2024 22:45

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@gracelu0 gracelu0 removed the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Nov 22, 2024
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.17%. Comparing base (01f2dcd) to head (2ab6331).
Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #32020   +/-   ##
=======================================
  Coverage   77.17%   77.17%           
=======================================
  Files         105      105           
  Lines        7169     7169           
  Branches     1315     1315           
=======================================
  Hits         5533     5533           
  Misses       1455     1455           
  Partials      181      181           
Flag Coverage Δ
suite.unit 77.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 77.17% <ø> (ø)
---- 🚨 Try these New Features:

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/small Small work item – less than a day of effort p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-cloudfront: setting originAccessControlId in aws-cloudfront-origins does nothing
3 participants