GithubHelp home page GithubHelp logo

benminer / serverless-plugin-bootstrap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dougmoscrop/serverless-plugin-bootstrap

0.0 0.0 0.0 689 KB

Checks that the environment around your Serverless service has been set up and is up-to-date

License: Other

JavaScript 100.00%

serverless-plugin-bootstrap's Introduction

serverless-plugin-bootstrap

This plugin helps with ensuring that CloudFormation stacks that need to exist before your Serverless application are deployed and up-to-date.

Breaking Changes in 2.0

  • The stage name is included in the stack name by default now. You can still use this plugin to bootstrap a stack that is shared between several stacks, by specifying a stack: config that uses a name that does not include the stage.
  • noCheck is now --no-bootstrap

Usage

Within your serverless.yml you can configure bootstrap behavior:

service: foo

custom:
  bootstrap:
    file: "cloudformation/bootstrap.json"
    stackPolicy:
      - Effect: ''
        ...
      - Effect: ''
        ...

During a serverless deploy, this plugin will ensure that the stack foo-bootstrap exists and is up to date. If not, the deploy will fail. Upon failure, a CloudFormation Change Set will be left that you can review in the AWS console and execute. It's also possible your local copy of bootsrap.json is out of date, and you need to git pull/rebase.

This plugin also adds a command, bootstrap, which does the check without a deploy:

serverless bootstrap

The bootstrap command supports an optional --execute option, which will immediately apply the changes. This is most useful for the first time you are deploying, the rest of the time you should probably review the change set!

serverless bootstrap policy

The bootstrap policy sub command will set the stack policy from custom.bootstrap.stackPolicy in your serverless config. Check out AWS example policies for supported policy values.

Options

The bootstrap config block supports the following additional keys as options:

stack: this overrides the stack name, which defaults to ${service}-${fileBaseNameWithoutExtension}

Note: By default the stack name is once-per-service (across stages - e.g. for API Gateway account level stuff). This is likely going to change to per-stage in the next major version, but the stack name override will continue to allow per-service bootstraps.

capabilities: this is an array of capabilities, such as CAPABILITY_IAM or CAPABILITY_NAMED_IAM which may be required depending on the resources in your bootstrap template.

bootstrap.json

The bootstrap.json (yml is also supported) file referenced above is a regular CloudFormation template. It is not parsed via Serverless, so no variable substitution is performed (you can use Parameters to pass info in to the stack, such as the stage or region).

For example, it might look like (as YAML):

---
AWSTemplateFormatVersion: "2010-09-09"

Description: >
  Bootstrap stack

Parameters:

  service:
    Description: Name of the service
    Type: String

  stage:
    Description: Usually one of test, stable or prod
    Type: String

Outputs:

  monitoringTopicARN:
      Description: ARN of the monitoring SNS topic
      Value:
        Ref: MonitoringTopic
      Export:
        Name:
          Fn::Sub: ${service}-${stage}-monitoring-topic-arn

Resources:

  MonitoringTopic:
    Type: AWS::SNS::Topic
    Properties:
      TopicName:
        Fn::Sub: ${service}-${stage}-monitoring

  NestedStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: templates/nested-stack.yml
      Parameters:
        stage:
          Ref: stage

As you can see, NestedStack is an AWS::CloudFormation::Stack, a nested stack that is defined by a local file (relative path to this template file - ./templates/nested-stack)

This plugin will upload that template to S3 and replace the TemplateURL with the S3 URL -- similar to how the AWS CLI supports aws cloudformation package

serverless-plugin-bootstrap's People

Contributors

dependabot[bot] avatar dougmoscrop avatar jasperatd2l avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.