According to The CloudFront Documentation 'S3OriginConfig' is not a required field, yet trying to create a distribution without it will result in a "The specified origin server does not exist or is not valid." error. Just throwing a // REQUIRED next to 'S3OriginConfig' would have saved me a lot of pain!
Thanks for reaching out to us @GriffinMeyer. 'S3OriginConfig' is not documented as a required field because it should not be present if the origin being configured for the CreateDistribution call is a custom (non-S3) origin. That being said, the error received when omitting this field during the creation of an S3-backed distribution could certainly be improved. I'll bring this up with the rest of the team next week to determine the best approach to resolve this.
Aha, that makes perfect sense. A better error would definitely be nice. Thank you for responding!
I am having issues witt this, I am trying to make distribution with one of my ELB.
What to put _TargetOriginId_ under _DefaultCacheBehavior_ and what to put _Origins -> Items_?
If my ELB dns is _xxxxx.eu-west-1.elb.amazonaws.com_, what goes where?
Hi @consigliere23. The TargetOriginId value set in DefaultCacheBehavior corresponds to the Id value specified under _Origins -> Items_ for the origin you want to use in the distribution's default cache behavior. Below is an example of a bare-bones, functional, non-S3 origin item - in this case, I would want to set my TargetOriginId to MyOriginId since the value I am assigning to my origin's Id.
'Origins' => [
'Items' => [
[
'DomainName' => "xxxxx.eu-west-1.elb.amazonaws.com",
'Id' => 'MyOriginId',
'CustomOriginConfig' => [
'HTTPPort' => 80,
'HTTPSPort' => 443,
'OriginProtocolPolicy' => 'match-viewer',
]
],
],
'Quantity' => 1,
],
I strongly suggest reviewing the remaining parameters for origin items in our docs to ensure you are using the desired configuration for your custom origin in addition to the parameters provided above.
Thanks, I made it, missed 'CustomOriginConfig' array :/ :/
Most helpful comment
Thanks for reaching out to us @GriffinMeyer. 'S3OriginConfig' is not documented as a required field because it should not be present if the origin being configured for the
CreateDistributioncall is a custom (non-S3) origin. That being said, the error received when omitting this field during the creation of an S3-backed distribution could certainly be improved. I'll bring this up with the rest of the team next week to determine the best approach to resolve this.