Cloudfront customOriginSource with s3 reference seems to be broken
See original GitHub issueGiven the following resources:
const bucket = new s3.Bucket(this, `${props.name}Bucket`, {
publicReadAccess: true,
websiteIndexDocument: "index.html",
websiteErrorDocument: "404.html",
removalPolicy: cdk.RemovalPolicy.Orphan
});
new cloudfront.CloudFrontWebDistribution(
this,
`${props.name}Distribution`,
{
aliasConfiguration: {
names: props.domainNames,
acmCertRef: props.certificateArn
},
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.RedirectToHTTPS,
priceClass: cloudfront.PriceClass.PriceClass200,
originConfigs: [
{
customOriginSource: {
originProtocolPolicy: cloudfront.OriginProtocolPolicy.HttpOnly,
domainName: bucket.bucketWebsiteUrl
},
behaviors: [{ isDefaultBehavior: true }]
}
]
}
);
The stack synthesizes properly, but the creation fails with the following error message:
5/10 | 11:37:27 PM | CREATE_FAILED | AWS::CloudFront::Distribution | LivejamDistribution/LivejamMainDistribution/CFDistribution (LivejamDistributionLivejamMainDistributionCFDistribution579AF62B) The parameter origin name cannot contain a colon. (Service: AmazonCloudFront; Status Code: 400; Error Code: InvalidArgument; Request ID: ed592c47-394d-11e9-9a3d-7928c3cc16b1)
When I provide the domainName
as string input, it works as expected.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Troubleshoot CloudFront file access with an S3 origin
I'm using an Amazon Simple Storage Service (Amazon S3) bucket as the origin of my Amazon CloudFront distribution but I'm not able to...
Read more >AWS CDK: There can only be one default behavior across all ...
It means that you need to have only single default behavior. But you can add multiple behaviors. Cloudfront let's you create multiple behaviors ......
Read more >Deploying create-react-app to S3 and CloudFront
The React CLI tool, create-react-app, helps front end developers finally focus on building applications, rather than configuring them.
Read more >Why You Shouldn't Use AWS S3 or CloudFront to Deliver ...
AWS is THE cool kid in the town. Every comparison of different cloud providers is incomplete unless you compare them with AWS at...
Read more >Getting started with a simple CloudFront distribution
Stores the original versions of your objects in an Amazon Simple Storage Service (Amazon S3) bucket. Makes your objects accessible to everyone. Uses...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A quick workaround for getting rid of
http://
orhttps://
is splitting theWebsiteURL
of the bucket. See theDomainName
value in the following snippet:For anyone others who stumble into the same issues, I found 2 working solutions: