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-plugin-additional-stacks

v1.6.0

Published

Created by Kenneth Falck <<[email protected]>>. Copyright [Nordcloud](https://nordcloud.com) 2017-2021. Released under the MIT license.

Downloads

35,067

Readme

Additional Stacks Plugin for Serverless 1.x

Created by Kenneth Falck <[email protected]>. Copyright Nordcloud 2017-2021. Released under the MIT license.

Overview and purpose

This plugin provides support for managing multiple AWS CloudFormation stacks in your Serverless 1.x service (serverless.yml).

The plugin requires Node.js 12.x or later due to use of Object.fromEntries().

Normally, Serverless creates a single CloudFormation stack which contains all your CloudFormation resources. If you ever delete your service, these resources are also deleted, including data stored in S3 or DynamoDB.

The Additional Stacks Plugin allows you to move your "permanent" resources into a separate CloudFormation stack, which is not tightly coupled with the service. If you delete your Serverless service and deploy it again from scratch, the permanent resources and their stored data remain untouched.

The cost of separation is that Ref: no longer works for directly referencing resources between stacks. If you need such references, you'll need to define exported stack output values and then use Fn::ImportValue to refer to the value in the other stack.

However, you can also use shared Serverless variables in stack definitions. So you can define resource names in serverless.yml and then refer to them using variables like ${self:custom.tableName}.

You can use the plugin to manage as many additional stacks as you like in your serverless.yml, placed under the custom.additionalStacks section.

Installation

To install with npm, run this in your service directory:

npm install --save serverless-plugin-additional-stacks

To install with yarn, run this in your service directory:

yarn add serverless-plugin-additional-stacks

Then add this to your serverless.yml:

plugins:
 - serverless-plugin-additional-stacks

Configuration

To define additional stacks, add an additionalStacks section like this in your serverless.yml:

custom:
  additionalStacks:
    permanent:
      Resources:
        S3BucketData:
          Type: AWS::S3::Bucket
          Properties:
            BucketName: ${self:service}-data

The syntax of the Resources section is identical to the normal resources in serverless.yml, so you can just cut-paste resource definitions around.

The full name of the deployed CloudFormation stack will include the service name. If your service is called my-service and you deploy it to the dev stage, the additional stack would be called my-service-dev-permanent.

Customizing additional stacks

The plugin supports some directives you can use to control how your additional stacks are deployed. They are described below.

custom:
  additionalStacks:
    stackName:
      Deploy: After
      DeployParameters: []
      StackName: CustomName
      Resources: ...

Deploy: Before|After

By default, additional stacks are deployed before the main Serverless CloudFormation resources. This ensures they are immediately available when your Lambda functions start running.

If you need to deploy an additional stack after other CloudFormation resources, you can add Deploy: After to its definition.

DeployParameters: [...]

By default, stacks are deployed with empty parameters ([]). You can use DeployParameters: [...] to specify parameters as an array with the same syntax that the AWS SDK createStack() and updateStack() functions use. It looks like this in YAML:

DeployParameters:
  - ParameterKey: param1
    ParameterValue: value1
  - ParameterKey: param2
    ParameterValue: value2

StackName: CustomName

By default, additional CloudFormation stacks are named by appending the specified stackName to the Serverless stack name. If you want to customize the CloudFormation name of the stack, you can specify StackName: CustomName. This is useful for controlling existing stacks.

Command Line Usage

Your additional stacks will be deployed automatically when you run:

sls deploy

To deploy all additional stacks without deploying the Serverless service, you can use:

sls deploy additionalstacks

To deploy an additional stack individually, you can use:

sls deploy additionalstacks --stack [stackname]

To only deploy the Serverless service without deploying additional stacks, you can use:

sls deploy --skip-additionalstacks

If you want to remove an additional stack, you need to run:

sls remove additionalstacks --stack [stackname]

Or you can remove all additional stacks in the service with:

sls remove additionalstacks

Alternatively, you can remove stacks manually in AWS CloudFormation Console.