In this step, we will create an S3 bucket with Static web hosting enabled and publicly accessible based on SAM:
FcjBookStore:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
BucketName: fcj-book-store
WebsiteConfiguration:
IndexDocument: index.html
FcjBookStorePolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref FcjBookStore
PolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- 's3:GetObject'
Effect: Allow
Principal: '*'
Resource: !Join
- ''
- - 'arn:aws:s3:::'
- !Ref FcjBookStore
- /*
The above script defines an S3 bucket is fcj-book-store with FcjBookStorePolicy policy - allow public access
sam build
sam validate
sam deploy --guided
fcj-book-store
ap-southeast-1
- should be the same as the default regiongit clone https://github.com/AWS-First-Cloud-Journey/FCJ-Serverless-Workshop.git
cd FCJ-Serverless-Workshop
yarn build
aws s3 cp build s3://fcj-book-store --recursive
Result after uploading: