npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aws-web-pub

v1.5.0

Published

Publish a static website to AWS with one simple command.

Downloads

16

Readme

aws-web-pub

Publish a static website to AWS with one simple command.

With one simple command this tool provisions all of the AWS resources required to host your static website with a custom domain. The initial deployment takes about 10 minutes but site updates usually complete in just a few minutes.

Noteworthy Features

  • Automatically generates an SSL/TLS certificate for your domain
  • Supports traditional websites and single-page applications
  • Supports redirecting to or from the APEX (naked) domain (e.g. have https://example.com redirect to https://www.example.com or vice versa)
  • Redirects all http requests to https
  • Tear down your website and delete all AWS resources with one command

Prerequisites

  • Your domain(s) is managed by AWS Route 53

  • Your AWS credentials are configured with the AWS CLI OR you have following environment variables set to appropriate values:

    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY

Quick Start

  • Install npm install aws-web-pub

  • Add a config file to the root of your project named .aws-web-pub.json

{
  "projectName": "example-site",
  "publishDir": "dist",
  "notFoundPath": "/404.html",
  "domains": [
    {
      "name": "www.example.com"
    }
  ]
}
  • Add convenience scripts to package.json like
{
  "scripts": {
    "deploy": "aws-web-pub deploy",
    "destroy": "awe-web-pub destroy"
  }
}
  • Deploy your site with npm run deploy

  • Tear down your site (and delete the AWS resources) with npm run destroy

Configuration File Options

{
  "projectName": "example-site",
  "publishDir": "dist",
  "deleteOldFiles": true,
  "notFoundPath": "/404.html",
  "isSinglePageApp": false,
  "domains": [
    {
      "name": "www.example.com"
    },
    {
      "name": "example.com",
      "dnsZoneName": "example.com"
    }
  ],
  "certificateArn": "arn:aws:acm:region:account:certificate/123456789012-1234-1234-1234-12345678"
}
  • projectName uniquely identifies a project within an AWS account. It must start with an alphabetic character (ASCII) and can't be longer than 128 characters. If you try to deploy more than one site with the same projectName they will overwrite each other. Note that internally all non-alphanumeric characters are converted to hyphens so projects with names my project and my-project are considered identical and would overwrite each other.

  • publishDir is a path to the directory of web assets to publish. This should be relative to the configuration file.

  • deleteOldFiles is optional and indicates whether old files (files that are in the S3 bucket but not in publishDir) should be deleted. This defaults to true.

  • notFoundPath is optional and identifies an html file to use for the content of 404 responses. This should be relative to publishDir and prefixed with a /. This property is ignored when isSinglePageApp is set to true.

  • isSinglePageApp is optional and when set to true it optimizes the configuration for single page applications. In this mode 404 errors are converted to 200 and return the root document. When this is enabled the notFoundPath property is ignored.

  • domains is an optional array and describes custom domains to use. The first entry will be the primary domain and any subsequent entries will be configured to redirect to the primary. If this property is not set you can still access the site via a CloudFront URL.

    • name is the domain name
    • dnsZoneName is optional and identifies the Route 53 HostedZone that manages this domain. When dnsZoneName is not provided it defaults to the parent domain (e.g. the domain name www.example.com defaults to using example.com as the dnsZoneName). This is typically used to support the APEX / naked domain by setting name and dnsZoneName to the same value. In the example configuration above the APEX domain https://example.com would redirect to the primary domain https://www.example.com
  • certificateArn is optional and specifies the ARN of an AWS ACM certificate to use. This certificate must be valid for every domain in the domains setting. If present we use this certificate instead of generating a new one (See Additional Notes below regarding AWS certificate limits).

Additional Notes

  • This tool generates temporary files in a directory called aws-web-pub.out. You should add this to .gitignore
  • Due to CloudFront limitations the website will always be hosted in the us-east-1 AWS region.
  • If you are using AWS named profiles you can pass a --profile option
  • By default most AWS Accounts can generate just 20 ACM certficates per year. If you plan on destroying sites frequently you should manually generate a certificate and use the certificateArn to prevent hitting this limit. Alternatively you can also ask AWS support to increase your ACM "Imported certificates in last 365 days" quota limit.