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

feat(cloudfront-origins): allow setting a user defined origin id #22349

Merged
merged 3 commits into from
Oct 12, 2022
Merged

feat(cloudfront-origins): allow setting a user defined origin id #22349

merged 3 commits into from
Oct 12, 2022

Conversation

corymhall
Copy link
Contributor

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:

  • 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

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
@corymhall corymhall added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Oct 4, 2022
@gitpod-io
Copy link

gitpod-io bot commented Oct 4, 2022

@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1 labels Oct 4, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team October 4, 2022 19:56
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 4, 2022
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:

❌ Features must contain a change to a README file.

PRs must pass status checks before we can provide a meaningful review.

@aws-cdk-automation aws-cdk-automation dismissed their stale review October 4, 2022 19:58

Pull Request updated. Dissmissing previous PRLinter Review.

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:

❌ Features must contain a change to a README file.

PRs must pass status checks before we can provide a meaningful review.

@aws-cdk-automation aws-cdk-automation dismissed their stale review October 4, 2022 19:59

Pull Request updated. Dissmissing previous PRLinter Review.

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:

❌ Features must contain a change to a README file.

PRs must pass status checks before we can provide a meaningful review.

@TheRealAmazonKendra
Copy link
Contributor

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Oct 4, 2022

update

✅ Branch has been successfully updated

@TheRealAmazonKendra
Copy link
Contributor

@corymhall why integ exempt?

@corymhall
Copy link
Contributor Author

@corymhall why integ exempt?

Our integ tests already set the id to some value that we generate. This change allows the user to define a different id. I don't think there is any behavior to test in this case. We would be testing that when you set the id CloudFormation does the right thing, which is not something integ tests should test.

I also don't think this needs a README update, but let me know if you disagree.

@corymhall corymhall added the pr-linter/exempt-readme The PR linter will not require README changes label Oct 5, 2022
@aws-cdk-automation aws-cdk-automation dismissed their stale review October 5, 2022 19:18

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

Copy link
Contributor

@kaizencc kaizencc left a 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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@kaizencc kaizencc added the pr/do-not-merge This PR should not be merged at this time. label Oct 11, 2022
@corymhall corymhall removed the pr/do-not-merge This PR should not be merged at this time. label Oct 12, 2022
@mergify
Copy link
Contributor

mergify bot commented Oct 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
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 8ca142d
  • 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 239215f into aws:main Oct 12, 2022
@mergify
Copy link
Contributor

mergify bot commented Oct 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
contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1 pr-linter/exempt-integ-test The PR linter will not require integ test changes 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.

CloudFront Origin IDs
4 participants