website
Deploy a static website to AWS S3 in seconds using Serverless Components.
- Install
- Create
- Configure
- Deploy
1. Install
$ npm install -g serverless
2. Create
$ mkdir my-website
$ cd my-website
the directory should look something like this:
|- code
|- index.html
|- serverless.yml
|- .env # your AWS api keys
# .env
AWS_ACCESS_KEY_ID=XXX
AWS_SECRET_ACCESS_KEY=XXX
The code
directory could either be a simple directory of html/css/js assets files, or a full fledged React app.
3. Configure
name: my-website
stage: dev
myWebsite:
component: "@serverless/website"
inputs:
code:
root: ./
src: ./src
hook: npm run build
region: us-east-1
bucketName: myBucket
cloudFront:
waitForCreateDistribution: true
waitForUpdateDistribution: false
customOrigin: true
env:
API_URL: https://api.com
domain: www.example.com
4. Deploy
$ serverless
New to Components?
Checkout the Serverless Components repo for more information.
Publishing new versions
New versions of this fork should be published from the master
branch
using npm publish
. Remember to bump the package version as appropriate before publishing.