• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Additional Stacks Plugin for Serverless 1.x

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.

More Repositories

1

serverless-mocha-plugin

Plugin for Serverless Framework which adds support for test-driven development using Mocha
JavaScript
160
star
2

serverless-jest-plugin

Plugin for Serverless Framework which adds support for test-driven development using Jest
JavaScript
120
star
3

serverless-kms-secrets

๐Ÿ”‘๐Ÿ”โ˜๏ธ Serverless plugin to encrypt variables with KMS (DEPRECATED)
JavaScript
113
star
4

cognitocurl

๐Ÿฆ‰๐Ÿค–Easily sign curl calls to API Gateway with Cognito authorization token.
TypeScript
90
star
5

serverless-boilerplate

Serverless project template
JavaScript
82
star
6

pat-frontend-template

React frontend template based on Vite for Nordcloud's Platform & Tools
TypeScript
58
star
7

assume-role-arn

๐Ÿค–๐ŸŽฉassume-role-arn allows you to easily assume an AWS IAM role in your CI/CD pipelines, without worrying about external dependencies.
Go
55
star
8

azure-pipelines-templates

Templates to be reused in our Azure Pipelines projects
31
star
9

lambda-wrapper

Wrapper for running lambda modules locally during development
JavaScript
30
star
10

GNUI

๐Ÿ’… Nordcloud's design system for SaaS products.
TypeScript
30
star
11

cognito-authorizer

Build your AWS API Gateway custom authorizer lambda without the need to handle tokens by yourself. Just implement the logic...
Go
24
star
12

aws-assume-role

GitHub action to assume subsequent AWS roles
Shell
23
star
13

aws-codepipeline-cfn-provider

โ˜๏ธโœจโš™๏ธAWS Codepipeline Lambda to deploy stuff using AWS CloudFormation.
Python
23
star
14

azure-tag-manager

Azure Tag Manager, enforce tags at scale.
Go
21
star
15

codepipeline-datadog-events

Tool for monitoring AWS CodePipeline status and pushing events to Datadog, Slack and Cloudwatch.
TypeScript
20
star
16

cognito-go-auth

Simple library to sign requests using cognito Google federated authentication.
Go
17
star
17

cfn-encrypt

๐Ÿ”‘๐Ÿ”โ˜๏ธ Cloudformation custom resource that enables creation of KMS encrypted strings and SSM secure parameters
Python
13
star
18

cfn-datadog

๐Ÿ•โš™๏ธCloudformation custom resources that integrate with datadog
Python
10
star
19

mfacli

Go
9
star
20

azure-go-example

๐Ÿ––Example app in go Azure SDK
Go
8
star
21

terraform-provider-imagefactory

ImageFactory terraform provider
Go
7
star
22

aws-rds-manager

โ˜๏ธ๐Ÿ› โœจ Provides utilities for the management of RDS snapshots
Python
6
star
23

ncerrors

An error wrapping library with an ability to add arbitrary fields to errors and record stack trace.
Go
4
star
24

mca-cli

CLI to help automating MCA work
TypeScript
4
star
25

mca-monitoring

Separate library for MCA monitoring generated with MCA CLI.
TypeScript
3
star
26

serverless.fi

serverless.fi website
HTML
2
star
27

klarity-scanner-vmware-cli

Klarity self-hosted scanner for your VMware environments
Go
2
star
28

klarity-apps-examples

Klarity apps examples, free to use
1
star
29

cloudtrail-activity-events

1
star
30

serverless-tdd-plugin

serverless-mocha-plugin reborn.
JavaScript
1
star
31

nordcloud-webassembly-lambda-demo

Nordcloud WebAssembly Lambda Demo
TypeScript
1
star
32

eslint-config-pat

Shareable ESLint config for PAT projects
JavaScript
1
star
33

log-forwarder

Golang based application to consume exported Cloud Logging entries via Pub/Sub subscription and log the entries on configured, central GCP Project.
Go
1
star
34

pytanko-bot

โ‰๏ธ Pytanko bot to post questions into a graphQL api (check https://github.com/nordcloud/pytanko-ui)
Go
1
star
35

lambdas-presentation-2018

JavaScript
1
star
36

aksworkshop

1
star
37

supermaestro-manifest-example

1
star
38

azure-cloud-foundation

1
star
39

kubernetes-fast-track-program

The Kubernetes Fast-Track program is an initiative to fast-track Nordcloud engineers onto Kubernetes. This Github project provides the necessary materials and tools to practice using Docker containers and Kubernetes.
Dockerfile
1
star