AWS CloudFormation scenarios to Create CloudFront Distribution with 'InvalidOrigin' scenarios
I recently switched to I'm working on a project and hit a roadblock. I'm stuck on something that should probably be simple. I've been struggling with this for a few days now and could really use some help. I'm trying to create a CloudFront distribution using AWS CloudFormation, but the stack fails with an 'InvalidOrigin' behavior. My CloudFormation template is structured to create a simple CloudFront distribution that serves content from an S3 bucket. Here's the relevant part of my template: ```yaml Resources: MyS3Bucket: Type: 'AWS::S3::Bucket' Properties: BucketName: my-unique-bucket-name AccessControl: PublicRead MyCloudFrontDistribution: Type: 'AWS::CloudFront::Distribution' Properties: DistributionConfig: Origins: - Id: MyS3Origin DomainName: !GetAtt MyS3Bucket.DomainName OriginPath: '' DefaultCacheBehavior: TargetOriginId: MyS3Origin ViewerProtocolPolicy: redirect-to-https AllowedMethods: - GET - HEAD CachedMethods: - GET - HEAD Enabled: true ``` I've ensured that the S3 bucket exists before the CloudFront distribution is created, and I have set the bucket policy to allow public access. However, when I try to create the stack, I get the following behavior: `An behavior occurred while creating the distribution: InvalidOrigin: The specified origin is invalid.` I've double-checked the syntax, but nothing seems out of place. I've also tried using both the `BucketName` and `DomainName` attributes for the S3 bucket, but I still get the same behavior. Is there something specific I might be missing regarding the origin configuration? Are there any best practices I should follow for creating CloudFront distributions with S3 origins? Any ideas what could be causing this? Any suggestions would be helpful. This is part of a larger CLI tool I'm building.