S3OriginConfig example

Example showing what you need to make S3OriginConfig work:

      DistributionConfig: 
        Enabled: true
        Origins:
          -   
            Id: "WebsiteDistribution"
            DomainName: !Ref WebsiteBucket
            S3OriginConfig:
              OriginAccessIdentity: !Sub 'origin-access-identity/cloudfront/${OriginAccessIdentity}'

  OriginAccessIdentity:
    Type: 'AWS::CloudFront::CloudFrontOriginAccessIdentity'
    Properties:
      CloudFrontOriginAccessIdentityConfig:
        Comment: 'Access S3 bucket content only through CloudFront'

One Reply to “S3OriginConfig example”

  1. Thank you! I was struggling for a day trying to figure out how to inject the Cloud Front Origin ID into S3OriginConfig. No where in AWS’ documentation did they suggest using a !Sub function

Leave a Reply

Your email address will not be published. Required fields are marked *