Skip to content

Instantly share code, notes, and snippets.

@Y4suyuki
Created September 5, 2021 17:25
Show Gist options
  • Save Y4suyuki/6db759371391f4b9bb8c35efca1ec1c9 to your computer and use it in GitHub Desktop.
Save Y4suyuki/6db759371391f4b9bb8c35efca1ec1c9 to your computer and use it in GitHub Desktop.
simple s3 static site hosting cloudformation template
Resources:
S3Bucket:
Type: 'AWS::S3::Bucket'
DeletionPolicy: Retain
Properties:
AccessControl: PublicRead
BucketName: my-static-hosting
WebsiteConfiguration:
IndexDocument: index.html
S3BucketPolicy:
Type: 'AWS::S3::BucketPolicy'
Properties:
Bucket: !Ref S3Bucket
PolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- 's3:GetObject'
Effect: Allow
Resource: !Join
- ''
- - 'arn:aws:s3:::'
- !Ref S3Bucket
- /*
Principal: '*'
Outputs:
WebsiteURL:
Value: !GetAtt
- S3Bucket
- WebsiteURL
Description: URL for website hosted on S3
S3BucketSecureURL:
Value: !Join
- ''
- - 'https://'
- !GetAtt
- S3Bucket
- DomainName
Description: Name of S3 bucket to hold website content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment