2.1.5 • Published 4 years ago

aws-webdeploy v2.1.5

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

aws-webdeploy

Tiny utility to allow configuring a web application deployment from your package.json and leverage AWS-CDK.

NPX Usage (Option 1)

Add the webdeploy section to your package.json file. (see below for more options)

  "webdeploy": {
    "distPath": "./dist",
    "resourcePrefix": "test-web-stack"
  }

Then just do this:

npx aws-webdeploy

Integrated as npm-script (Option 2)

TLDR; Install this along with the AWS CDK CLI (installed globally) and you can yarn deploy your static website out of your dist directory.

Full example project

https://github.com/dsandor/aws-webdeploy-example

asciicast

What are the pre-requisites?

package.json webdeploy settings

In its simplest form you only need to add the following section to your package.json file. Here you are specifying the location of your static website files ./dist/ in this case. You are also specifying a prefix to use for your AWS Resources in the CloudFormation stack. This should be a unique prefix to avoid collision with your S3 bucket name. Pick something like www-mywebsite-com which is unique and descriptive.

  "webdeploy": {
    "distPath": "./dist",
    "resourcePrefix": "test-web-stack"
  }

Add the deploy script to your package.json

Add the following to your package.json file:

  "scripts": {
    "deploy": "cdk deploy --app node_modules/aws-webdeploy/deploy.js"
  },

How to deploy?

yarn deploy

-or-

npm run deploy

This kicks off the cdk deploy command and uses a small cdk app that will use the parameters you configured in your package.json file.

Full package.json file settings

propertydescription
websiteDistPathThe HTML files to be deployed. e.g. ./dist
deploymentVersionA version number for your deployment.
resourcePrefixUsed to group resources with a prefix. The S3 bucket is prefixed with this value.
indexDocumentindex document for your website. default: index.html
certificateArnthe ARN for the SSL certificate for your website. (optional)
domainNamesan array of strings representing your website domain name (must match the certificate) e.g. 'mydomain.com', 'www.mydomain.com'

Please note that if you wish to use your own domain names and not just the Cloud Front Distribution URL you will also need a certificate. It is very simple to create a certificate in AWS console and it is free (assuming you are supporting modern browsers only). Once you have the ARN for your certificate use the certificateArn property. You will also need to provide the domain names to the domainNames property. The domain names MUST MATCH the domain names you put on your certificate.

What gets created for me?

  • CloudFront Distribution
  • CloudFront Origin that maps to a versioned folder in an S3 bucket
  • Correct permissions to disallow public access to the S3 bucket.
  • Correct permissions for CloudFront to serve the files from S3
  • S3 Bucket for the website assets (placed into a folder based on deploymentVersion value)
2.1.4

4 years ago

2.1.5

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago