Skip to content

Instantly share code, notes, and snippets.

@stewartnoll
Created October 21, 2019 18:34
Show Gist options
  • Save stewartnoll/405410b419deb3c5504cb69548a34c62 to your computer and use it in GitHub Desktop.
Save stewartnoll/405410b419deb3c5504cb69548a34c62 to your computer and use it in GitHub Desktop.
service: <your service name here>
plugins:
- serverless-s3-sync
custom:
stage: ${opt:stage, 'dev'}
bucketName: ${self:custom.stage}-${self:service}
s3Sync:
- bucketName: ${self:custom.bucketName}
localDir: dist
provider:
name: aws
runtime: nodejs6.10
tracing: true
stage: ${self:custom.stage}
resources:
Resources:
StaticSite:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
BucketName: ${self:custom.bucketName}
WebsiteConfiguration:
IndexDocument: index.html
StaticSiteS3BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: StaticSite
PolicyDocument:
Statement:
- Sid: PublicReadGetObject
Effect: Allow
Principal: "*"
Action:
- s3:GetObject
Resource:
Fn::Join: [
"", [
"arn:aws:s3:::",
{
"Ref": "StaticSite"
},
"/*"
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment