Skip to content

Instantly share code, notes, and snippets.

@LuisEnMarroquin
Created September 16, 2021 04:07
Show Gist options
  • Save LuisEnMarroquin/62dd8571f74a895c627da50ca697f61b to your computer and use it in GitHub Desktop.
Save LuisEnMarroquin/62dd8571f74a895c627da50ca697f61b to your computer and use it in GitHub Desktop.
aws cloudformation create-stack --stack-name public-bucket-for-spa --template-body file://./spa-bucket.yml
AWSTemplateFormatVersion: '2010-09-09'
Description: S3 bucket for SPA and public read policy
Parameters:
BucketName:
Type: String
Default: my-unique-bucket-name-123456789
Resources:
MyS3Bucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
BucketName: !Ref BucketName
WebsiteConfiguration:
ErrorDocument: index.html
IndexDocument: index.html
MyS3Policy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref MyS3Bucket
PolicyDocument:
Version: '2012-10-17'
Id: EverythingIsPublic
Statement:
- Sid: PublicReadForGetBucketObjects
Effect: Allow
Principal: "*"
Action: s3:GetObject
Resource: !Join
- ''
- - 'arn:aws:s3:::'
- !Ref BucketName
- /*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment