-
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-origins): allow setting a user defined origin id #22349
Conversation
This PR adds the ability to set a custom user defined origin identifier. The default identifier that is generated is not very descriptive and some users would like the ability to define a custom identifier. Since ids have to be unique per distribution, I also added validation that will throw an error if it is not. fixes #2756
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 fails with the following errors:
❌ Features must contain a change to a README file.
PRs must pass status checks before we can provide a meaningful review.
Pull Request updated. Dissmissing previous PRLinter 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.
The Pull Request Linter fails with the following errors:
❌ Features must contain a change to a README file.
PRs must pass status checks before we can provide a meaningful review.
Pull Request updated. Dissmissing previous PRLinter 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.
The Pull Request Linter fails with the following errors:
❌ Features must contain a change to a README file.
PRs must pass status checks before we can provide a meaningful review.
@Mergifyio update |
✅ Branch has been successfully updated |
@corymhall why integ exempt? |
Our integ tests already set the I also don't think this needs a README update, but let me know if you disagree. |
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter 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.
Approved with dnm for one minor nit comment. Feel free to resolve however you want.
@@ -370,7 +374,7 @@ export class Distribution extends Resource implements IDistribution { | |||
this.addOriginGroup(originGroupId, originBindConfig.failoverConfig.statusCodes, originId, failoverOriginId); | |||
return originGroupId; | |||
} | |||
return originId; | |||
return originBindConfig.originProperty?.id ?? originId; |
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.
Is this necessary? originBindConfig.originProperty.id === originId
under our implementation of OriginBase.bind()
.
I suppose someone could write their own CustomOrigin extends IOrigin
and implement bind
where the given originId
does not become the originBindConfig.originProperty.id
, but is that what we are defending against here?
If so... fine. But these will 99% of the time be the same value.
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.
They will be different if the user provides their own ID.
For example.
const origin = new S3Origin(bucket, { originId: 'MyCustomOrigin' });
When we then call bind on line 358
we pass in the generated originId (from line 357
. The change I made in bind
is to take the originId passed in S3Origin
first. So originBindConfig.originProperty.id will be MyCustomOrigin
.
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). |
This PR adds the ability to set a custom user defined origin identifier. The default identifier that is generated is not very descriptive and some users would like the ability to define a custom identifier.
Since ids have to be unique per distribution, I also added validation that will throw an error if it is not.
fixes #2756
All Submissions:
Adding new Unconventional Dependencies:
New Features
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