serverless-random-gateway-deployment-id

    1.0.1 • Public • Published


    Feedback is appreciated! If you have an idea for how this plugin/library can be improved (or even just a complaint/criticism) then please open an issue.

    Serverless Plugin: Random Gateway deploymentId

    1. Overview
    2. Installation & Setup
    3. Example

    Overview

    When using serverless framework only to deploy your aws resources without having any lambda functions or triggers, the AWS Gateway deploymemt does not behave as expected. Any deployment to an existing stage will be ignored, since CloudFormation does not redeploy a stage if the DeploymentIdentifier has not changed.

    The plugin parses the custom Cloudformation resources and adds a random id to the deployment-name and all references to it

    See the examples folder for a full working example

    Installation & Setup

    Run npm install in your Serverless project.

    $ npm install --save-dev serverless-random-gateway-deployment-id

    Add the plugin to your serverless.yml file

    plugins:
      - serverless-random-gateway-deployment-id

    Example

    The following example demonstrates a simple gateway deployment configuration. On every deploy the plugin will attach a random identifier to ApiGatewayDeployment

    service:
      name: user-registration
    
    provider:
      name: aws
      stage: dev
      region: eu-central-1
    
    plugins:
      - serverless-random-gateway-deployment-id
    
    functions:
    
    resources:
      Resources:
        ApiGatewayRestApi:
          Type: AWS::ApiGateway::RestApi
          Properties:
            ApiKeySourceType: HEADER
            Body: ${file(api.yml)}
            Description: "Some Description"
            FailOnWarnings: false
            Name: ${opt:stage, self:provider.stage}-some-name
            EndpointConfiguration:
              Types:
                - REGIONAL
        ApiGatewayDeployment:
          Type: AWS::ApiGateway::Deployment
          Properties:
            Description: ${opt:stage, self:provider.stage}
            RestApiId: !Ref ApiGatewayRestApi
        ApiGatewayStage:
          Type: AWS::ApiGateway::Stage
          Properties:
            StageName: ${opt:stage, self:provider.stage}
            Description: ${opt:stage, self:provider.stage} Stage
            RestApiId: !Ref ApiGatewayRestApi
            DeploymentId: !Ref ApiGatewayDeployment
            MethodSettings:
              - DataTraceEnabled: true
                HttpMethod: "*"
                LoggingLevel: ERROR
                ResourcePath: "/*"
                MetricsEnabled: true
        ApiGatewayBasePath:
          Type: AWS::ApiGateway::BasePathMapping
          DependsOn: ApiGatewayStage
          Properties:
            BasePath: some-path
            DomainName: www.test.de
            RestApiId: !Ref ApiGatewayRestApi
            Stage: !Ref ApiGatewayStage

    Install

    npm i serverless-random-gateway-deployment-id

    DownloadsWeekly Downloads

    105

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    12.5 kB

    Total Files

    10

    Last publish

    Collaborators

    • yndlingsfar