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

serverless-cloudfront-stack

v0.6.7

Published

Serverless Cdn Stack

Downloads

23

Readme

serverless CI npm version npm downloads Donate

Installation

npm i -E serverless-cloudfront-stack

Features

S3
- Bucket for your app assets.
- Bucket access control.
- Bucket encryption support for AES256.
- Bucket versioning for your assets.
- Bucket for cdn access logs.
- Bucket Cors.
- Data rentention for access logs.

Cloud Front Distribution
- SSL support.
- Access Logs.
- Cors support.
- Cname support.

Acm - Https
- Certificate Creation.
- Certificate Validation.

Dns Alias
- Route53 - Record for your CDN.
- ApiGateway - New Path for your CDN

Extras
- Invalidate CloudFront cache on new deploys.
- Sync your local assets folder with s3 on new deploys.
- Extends resources configuration.

Usage

# serverless.yml

plugins:
  - serverless-cloudfront-stack

custom:
  cdnStack:
    disabled: false                               # optional, disabled this plugin
    beforeSpawn: ''                               # optional, run another hook plugin

    cname: ''                                     # optional, cname for cdn.
    createInRoute53: false                        # optional, default false, create cname record
    certificate: ''                               # required, if use cname

    apigateway: ''                                # optional, use apigateway as http_proxy to cloudfront

    bucketName: ''                                # required, app bucket name
    enableCors: false                             # optional, enable cors default false
    blockPublicAccess: true                       # optional, block public acccess to s3
    bucketEncryption: false                       # optional, bucket encryption for AES256
    bucketVersioning: false                       # optional, assets object versioning (backup)

    indexPage: ''                                 # optional, default index.html
    errorPage: ''                                 # optional, default index.html
    bucketWebHosting: true                        # optional, default true

    syncLocalFolder: ''                           # optional, folder path to sync with s3
    priceClass: ''                                # optional, default 'PriceClass_100'

    forwardHeaders:                               # optional, forward http headers
      - Origin
      - Accept-Encoding
      - Your-Custom-Header

    logging:                                      # optional tag
      bucketName: ''                              # required, logs bucket name
      preffix: ''                                 # optional, default 'Access/'
      retentionDays: 7                            # optional, default 21 days

Simple Example For Static Web App with Route53

# serverless.yml

custom:
  cdnStack:
    cname: 'cdn.dev.domain.com'
    createInRoute53: true                         # assumptions: exist hosted zone "dev.domain.com"
    certificate: '*.domain.com'                   # assumptions: exist acm cert "*.domain.com"

    bucketName: 'static-html-web-app'
    blockPublicAccess: true
    bucketWebHosting: true

    syncLocalFolder: './dist'

Simple Example For Static Web App with ApiGateway (multiple front approach)

# serverless.yml
# Your front-app will be accessed through api gateway
# Assumptions: should be exists the apigateway and stage

custom:
  cdnStack:
    apigateway: apigateway-name:stage-dev/new-front-app

    bucketName: 'static-html-web-app'
    blockPublicAccess: true
    bucketWebHosting: true

    syncLocalFolder: './dist'

Simple Example for Front Resources (webfonts, images, ...)

# serverless.yml

custom:
  cdnStack:
    cname: 'cdn.dev.domain.com'
    createInRoute53: true                         # assumptions: exist hosted zone "dev.domain.com"
    certificate: '*.domain.com'                   # assumptions: exist acm cert "*.domain.com"

    bucketName: 'assets-front-resources'
    enableCors: true
    blockPublicAccess: true
    bucketWebHosting: false

    syncLocalFolder: './dist'


# psss. check full example in serverless.example.yml file.

Extends

# serverless.yml

resources:
  Resources:
    StaticWebSiteBucket:
      Properties:
        BucketName: override bucket name
        ...

    DnsRecord:
      Properties:
        Comment: override comment
        ...

    CloudFrontDistribution:
      ...

    AccessLogsBucket:
      ...