-
Notifications
You must be signed in to change notification settings - Fork 4k
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(cloudfront): add origin group selection criteria to L2 Distribution and L2 OriginGroup #32740
feat(cloudfront): add origin group selection criteria to L2 Distribution and L2 OriginGroup #32740
Conversation
add integration test
There was a problem hiding this 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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32740 +/- ##
=======================================
Coverage 80.78% 80.78%
=======================================
Files 232 232
Lines 14111 14111
Branches 2453 2453
=======================================
Hits 11400 11400
Misses 2431 2431
Partials 280 280
Flags with carried forward coverage won't be shown. Click here to find out more.
|
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
… better with existing interfaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍 Left some comments for adjustments
* | ||
* @default - none |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | |
* @default - none |
enum
declarations don't need a @default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad! removed
DEFAULT='default', | ||
/** | ||
* Selection based on media quality. | ||
*/ | ||
MEDIA_QUALITY_BASED='media-quality-based', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEFAULT='default', | |
/** | |
* Selection based on media quality. | |
*/ | |
MEDIA_QUALITY_BASED='media-quality-based', | |
DEFAULT = 'default', | |
/** | |
* Selection based on media quality. | |
*/ | |
MEDIA_QUALITY_BASED = 'media-quality-based', |
Formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
* The failover selection for the Distribution. | ||
* | ||
* @default - nothing is returned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The failover selection for the Distribution. | |
* | |
* @default - nothing is returned | |
* The selection criteria for the origin group. | |
* | |
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/high_availability_origin_failover.html#concept_origin_groups.creating | |
* | |
* @default - OriginSelectionCriteria.DEFAULT |
I assume CFN will enforce default
if not specified by CDK?
Can you please align the documentation in the other variable declarations as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - if it is undefined, then it'll default to default - even if we pass undefined, do you want the docs to reflect the "default" setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these test cases should be added to the existing distribution.test.ts file.
Also, the Ensure default is undefined
case seems redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved them to distribution.test.ts - i removed that test, but have added in a test where "default" is explicitly set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍 Please update the documentation for the variable in origin-group.ts
as well
/** | ||
* The selection criteria for the origin group. | ||
* | ||
* @default - nothing is returned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @default - nothing is returned | |
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/high_availability_origin_failover.html#concept_origin_groups.creating | |
* | |
* @default - OriginSelectionCriteria.DEFAULT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done! thanks!
Hey, is there anything else I need to complete to get a maintainer review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing @jamiepmullan . Overall this looks good to me, just a couple of minor comments on the tests/formatting. Once addressed I'm happy to approve.
@@ -1434,3 +1437,93 @@ describe('attachWebAclId', () => { | |||
}); | |||
|
|||
}); | |||
|
|||
test('Selection criteria does set Media Quality Based failover for Origin Group', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move these tests to origin-group.test.ts
instead? I was going to ask to add unit tests for origin group but I think it would be redundant with these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
}, | ||
}); | ||
|
||
new IntegTest(app, 'origin-group-selection-criteria', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add an assertion here to call getDistributionConfig
and check the value of SelectionCriteria
is as expected? An example integ test you can use for reference: https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk-testing/framework-integ/test/aws-cloudfront-origins/test/integ.s3-origin-oac.ts#L25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to do this but SelectionCriteria
isn't returned at the moment - I wonder if the aws-sdk needs updating? Apologies, not deep dived this part of CDK yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gracelu0 - I've taken another look, and dived into the logs in CloudWatch - but the JSON body returned on the call doesn't include the SelectionCriteria
- any advice on trying to get it? Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yea I didn't see it returned when using AWS CLI to call get-distribution-config
but after upgrading the CLI version to the latest SelectionCriteria
was included in the response. Let me check for the integration test framework, if there's no quick workaround then I'm good to approve without the assertion as I verified the test deploys and correctly configures the setting.
this.addOriginGroup(originGroupId, | ||
originBindConfig.failoverConfig.statusCodes, | ||
originId, failoverOriginId, | ||
originBindConfig.selectionCriteria); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.addOriginGroup(originGroupId, | |
originBindConfig.failoverConfig.statusCodes, | |
originId, failoverOriginId, | |
originBindConfig.selectionCriteria); | |
this.addOriginGroup( | |
originGroupId, | |
originBindConfig.failoverConfig.statusCodes, | |
originId, | |
failoverOriginId, | |
originBindConfig.selectionCriteria | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
private addOriginGroup(originGroupId: string, | ||
statusCodes: number[] | undefined, | ||
originId: string, failoverOriginId: string, | ||
selectionCriteria: OriginSelectionCriteria | undefined): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private addOriginGroup(originGroupId: string, | |
statusCodes: number[] | undefined, | |
originId: string, failoverOriginId: string, | |
selectionCriteria: OriginSelectionCriteria | undefined): void { | |
private addOriginGroup( | |
originGroupId: string, | |
statusCodes: number[] | undefined, | |
originId: string, | |
failoverOriginId: string, | |
selectionCriteria: OriginSelectionCriteria | undefined | |
): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Pull request has been modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing!
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). |
This pull request has been removed from the queue for the following reason: The pull request can't be updated You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. If you want to requeue this pull request, you need to post a comment with the text: |
@Mergifyio update |
❌ Pull request can't be updated with latest base branch changesMergify needs the author permission to update the base branch of the pull request. |
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). |
Pull request has been modified.
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). |
Pull request has been modified.
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #.
Reason for this change
add origin selection criteria to L2 Distribution & L2 OriginGroup
add unit + integration tests
Description of changes
Add Selection Criteria to Distribution L2 construct. CFN docs can be found here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-origingroup.html#cfn-cloudfront-distribution-origingroup-selectioncriteria
Description of how you validated changes
Added unit + integration tests for this new feature - by default it can be undefined, so shouldn't impact other configurations.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license