Trying to provision a static website bucket that's distributed by CloudFront.
The following CloudFormation template works if I omit the Logging
configuration for the distribution:
{
...
"PrimeBucket": {
"Properties": {
"AccessControl": "PublicRead",
"WebsiteConfiguration": {
"ErrorDocument": "error.html",
"IndexDocument": "index.html"
}
},
"Type": "AWS::S3::Bucket"
},
"PrimeBucketDistribution": {
"Properties": {
"DistributionConfig": {
"DefaultCacheBehavior": {
"AllowedMethods": [
"GET",
"HEAD",
"OPTIONS"
],
"ForwardedValues": {
"QueryString": "false"
},
"TargetOriginId": "BucketOrigin",
"ViewerProtocolPolicy": "allow-all"
},
"Enabled": "true",
"Logging": {
"Bucket": {
"Ref": "PrimeBucketLogs"
},
"IncludeCookies": "false"
},
"Origins": [
{
"DomainName": {
"Fn::GetAtt": [
"PrimeBucket",
"DomainName"
]
},
"Id": "BucketOrigin",
"S3OriginConfig": {}
}
]
}
},
"Type": "AWS::CloudFront::Distribution"
},
"PrimeBucketLogs": {
"Type": "AWS::S3::Bucket"
}
}
If I include Logging
I get the error:
The parameter Logging Bucket does not refer to a valid S3 bucket.
Is there any extra magic that needs to be applied to the logging bucket in order for it to be compatible with CloudFront? Couldn't find anything in the docs.
Click on the “ON” option to initiate the Logging feature of CloudFront to log all viewer requests for files in your distribution. Click on “Bucket for Logs” feature and specify the Amazon S3 bucket in which you want CloudFront to save web access logs. Click on Log Prefix which is optional for the names of log files.
1 Answer. The correct answer is option A (CloudFront cannot serve content from a non-AWS origin server). We can configure multiple origin servers for Amazon CloudFront. They can be either Amazon resources or non-AWS origin servers.
Standard logs (access logs) CloudFront standard logs are delivered to the Amazon S3 bucket of your choice. CloudFront doesn't charge for standard logs, though you incur Amazon S3 charges for storing and accessing the log files.
Try specifying your bucket name as "bucketname.s3.amazonaws.com"
instead of just "bucketname"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With