- Newest
- Most votes
- Most comments
The error you're encountering suggests that there's a mismatch between the region where your resources are located and the region being used in the CloudFormation template. Here are a few things to consider:
-
CloudFront Log Delivery: CloudFront always delivers logs from the us-east-1 region, regardless of where your distribution or S3 bucket is located. This explains why your S3 bucket policy allows PUT access from a us-east-1 based resource. This is normal and doesn't need to be changed.
-
Lambda Function Region: The Lambda function that processes the logs should be in the same region as your S3 bucket (eu-west-2 in your case). Make sure you've updated the Lambda function's region in the CloudFormation template.
-
S3 Bucket Configuration: Ensure that your S3 bucket is configured to allow access from the eu-west-2 region. The PermanentRedirect error suggests that the S3 bucket is trying to redirect to a different endpoint.
-
CloudFormation Stack Region: Make sure you're creating the CloudFormation stack in the eu-west-2 region.
-
Lambda Function Code: The reference to the Lambda function code (cloudfront-to-cloudwatch-blog/lambda_function.zip) should be updated to point to a location in your eu-west-2 region. You might need to upload this ZIP file to an S3 bucket in eu-west-2 and update the reference in the template.
-
IAM Roles and Policies: Ensure that any IAM roles and policies defined in the template are updated to reference the correct region and resource ARNs.
To resolve the issue:
- Double-check all region references in your CloudFormation template, ensuring they're set to eu-west-2.
- Update the Lambda function code location to a eu-west-2 S3 bucket.
- Verify that your S3 bucket allows access from the eu-west-2 region.
- Ensure you're creating the CloudFormation stack in the eu-west-2 region.
If the issue persists, you may need to review the S3 bucket configuration to ensure it's not enforcing region-specific endpoints that could cause the PermanentRedirect error.
Sources
Enable logging from AWS services - Amazon CloudWatch Logs
Configure standard logging (v2) - Amazon CloudFront
Amazon CloudFront now supports additional log formats and destinations for access logs - AWS
answered 2 years ago
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated 10 months ago
