aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

CloudFront Origin IDs

Open DfHlyu4aida opened this issue 5 years ago • 14 comments

Hey there, Currently we're migrating a serverless project to use the CDK. What we're experiencing now is that despite setting an ID for an Origin behavior it is always overwritten by origin{indexOfBehavior+1}. I also found that there is no typesafe way in TypeScript to set this property on Behavior, because it doesn't exist on that type. The parent construct CloudFrontWebDistribution is internally using an unexported type for behaviors called BehaviorWithOrigin. The constructor of CloudFrontWebDistribution is overwriting any specified (by sidestepping the typechecker) origin id, see here.

My question now is: is that the expected behavior of the CDK? Like, is this intentional to prevent people to have colliding origin IDs? Or is this a bug/feature?

DfHlyu4aida avatar Jun 05 '19 13:06 DfHlyu4aida

Indeed the current API doesn't allow specifying origin ID. I am curious, what is your use case for explicitly setting the origin ID?

eladb avatar Nov 17 '19 13:11 eladb

Closing for now since there hasn't been a response in a while. Feel free to reopen.

SomayaB avatar Mar 20 '20 20:03 SomayaB

doesn't need to reopen but I was lead here by google because I wanted to give my origins friendlier names to help make identifying them easier while troubleshooting, not the most critical use case but a would be nice for me anyway

dpistole avatar Jun 08 '20 13:06 dpistole

This feature exists in the actual service and other tools such as Terraform but not CDK. I can see why it is low priority but I can't see a reason NOT to implement it.

My use case is that we have a CloudFront distribution with a large number of cache behaviors. It acts as a sort of router to dispatch paths to various back end services. When looking at the list of behaviors in the console it would be very helpful if we could give the origins a meaningful name so we do not have to constantly flip back and forth between the behaviors and origins tab to see what "originN" is and try to remember all those.

vobarian avatar Dec 16 '20 22:12 vobarian

@njlynch Do you know if we can implement this now? Seems like the original issue was a while back

iliapolo avatar Dec 17 '20 16:12 iliapolo

Thanks for the tag, @iliapolo . Yes, I think this is a reasonable feature request. I'll re-open.

njlynch avatar Dec 17 '20 17:12 njlynch

Just came across the same limitation. Agree it's a pretty low priority, however, having human-readable names that match the purpose of the origins definitely makes debugging easier.

antonfelich avatar Feb 10 '21 22:02 antonfelich

We also need it please... helps a lot & can be done via SAM.

benm5678 avatar May 13 '21 16:05 benm5678

please add it

chtpl avatar May 28 '21 15:05 chtpl

Just stumbled upon this issue as well, and while not mission-critical it does feel bad not to be able to replicate some of my old CloudFormation templates completely using CDK despite the fact that I would really like to!

SkySails avatar Dec 17 '21 18:12 SkySails

one more thumbs up

omriman12 avatar Apr 20 '22 14:04 omriman12

I would also like to see this added, I have many origins going to lambda function URL's and there is nothing to identify them in the console. I can do some digging to figure it out, but it would be great if we could put an identifier there.

bradcondo avatar Jul 26 '22 23:07 bradcondo

one more thumbs up

etaroid avatar Aug 08 '22 07:08 etaroid

+1 on this one - auto-generated 'Origin Name' in the console is very difficult to read

vaughan-rich avatar Aug 11 '22 11:08 vaughan-rich

Are there any workarounds for setting the "Origin Name" when defining a HttpOrigin? It is almost impossible to navigate a CF distribution when you have many origins. Also the names become very long since the stack name is prepended..

Screenshot 2022-09-06 at 19 46 53

khromov avatar Sep 06 '22 17:09 khromov

Are there any workarounds for setting the "Origin Name" when defining a HttpOrigin?

You can use an escape hatch to post-process the generated resource, eg (in Java):

Distribution distribution = Distribution.Builder.create(this, "Distribution")
    ...
    build();

// Workaround https://github.com/aws/aws-cdk/issues/2756
CfnDistribution cfnDistribution = (CfnDistribution) distribution.getNode().getDefaultChild();
cfnDistribution.addPropertyOverride("DistributionConfig.Origins.0.Id", "my-origin");
cfnDistribution.addPropertyOverride("DistributionConfig.CacheBehaviors.0.TargetOriginId", "my-origin");

adrian-skybaker avatar Sep 07 '22 01:09 adrian-skybaker

This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue.

github-actions[bot] avatar Sep 11 '22 00:09 github-actions[bot]

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Oct 12 '22 15:10 github-actions[bot]