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

@smartstream-tv/pulumi-aws-toolbox

v0.17.2

Published

The Pulumi AWS Toolbox is an opinionated library containing components to build the infrastructure for website projects.

Downloads

314

Readme

Pulumi AWS Toolbox

The Pulumi AWS Toolbox is an opinionated library containing components to build the infrastructure for website projects.

It's mostly useful for projects that follow these design ideas:

  • being as serverless as possible, with pay per request AWS resources while avoiding resources that incur a fixed cost per hour
  • websites that are mostly static using S3 and CloudFront
  • backends implemented with AWS Lambda

Install with

npm i @smartstream-tv/pulumi-aws-toolbox

Components

Vpc

The Vpc component is a core component that provides networking functionality. It's needed to run things like EC2 instances, ECS tasks, RDS databases, and AWS Lambda functions. It's an opionionated component focused on the use of IPv6 instead of IPv4 (no NAT gateways provided). It doesn't try to support everything and doesn't provide many configuration options.

Architecture:

Diagram

It sets up subnets for three availability zones (= data centers). This allows to build applications with very high availability.

Resources in a public subnet can be reached and can communicate to the internet via IPv4 and IPv6.

  • For IPv4, resources need to have a public IPv4 address.
  • AWS Lambda does not support public IPv4 address, you would need NAT gateways for this, which we don't want to use do their cost.

Resources in a private subnet can communicate to the internet only via IPv6 and cannot be reached from the internet at all.

  • By default, you should place resources that don't need to be reached from the internet here.

Components:

  • Jumphost: Creates a jumphost EC2 instance.
  • StdSecurityGroup: A simple security group for many standard cases.
  • Vpc: the VPC component itself.

Database

Components:

Lambda

Components:

  • SimpleNodeLambda: Creates a Nodejs AWS Lambda with useful defaults for small & simple tasks.

SES

Components:

  • SesProxyMailer: Creates a AWS Lambda to send email using SES using IPv6 and/or from another account.

Website

Components:

Static website

The StaticWebsite component creates a CloudFront distribution and a number of supporting resources to create a mostly static website. It's an opinionated component that tries to solve the common cases of website hosting - but it may not be suitable for all cases.

Resources can be integrated from these source (see "routes" argument) e.g.

  • S3: for static assets
  • Lambda: to integrate dynamic content using a Lambda function
  • SingleAsset: a useful utility to define a static environment specific configuration file e.g. at /config.json

Moreover, the following things happen under the hood:

  • Automatically handles URL rewrites, so that when the user loads example.com/product, it will internally load product/index.html from S3.
  • HTTPS handled by CloudFront using a free HTTPS certificate from AWS.
  • DNS records are created in Route53.
  • Efficient caching for S3. The cache-control response header is set automatically to force the browser to re-validate resources before it can use them. If you have assets that never change, configure them by setting "immutable" for a given S3 route.
  • HTTP basic auth can be enabled to protect the website, e.g. for dev.
  • Access logs are stored in S3.
  • Automatically sets common HTTP security headers for responses.

Primarily, assets are loaded from S3 (specified by an S3Artifact). The bucket must be provided by you, for example, using the S3ArtifactStore component. The bucket must be provided by you, to care for cases where the bucket should be shared by several dev stacks and must therefore already exist during the CI build phase or additional settings/permissions should be configured for the bucket (like cross-account access from prod).

Example:

import * as pat from "@smartstream-tv/pulumi-aws-toolbox";

const artifactStore = new pat.build.S3ArtifactStore(`my-artifact`, {
    artifactName: "website",
});

new pat.website.StaticWebsite(`my-website`, {
    acmCertificateArn_usEast1: "arn:aws:acm:us-east-1:111111111111:certificate/xxxxxxxxx",
    hostedZoneId: "Z11111111111111111111",
    routes: [{
        type: RouteType.S3,
        pathPattern: "/",
        s3Location: artifactStore.getArtifactVersion("1.0"),
    }],
});

artifactStore.createBucketPolicy();

Afterwards, upload your website assets into s3://my-artifact-xyz/website/1.0 and you're done.

Build

Components:

Scripts

pulumi-aws-login

By convention we're using Pulumi's AWS S3 backend, with a bucket named "pulumi-state-{AWS_REGION}-{AWS_ACCOUNT_ID}". You can configure Pulumi to use this bucket by running

npx pulumi-aws-login

This will configure Pulumi to use the bucket of your current AWS account. The bucket must already exist.