1 | <p align="center">
|
2 | <a href="https://npmjs.com/package/serverless-random-gateway-deployment-id">
|
3 | <img src="https://flat.badgen.net/npm/v/serverless-random-gateway-deployment-id?icon=npm&label=npm@latest"></a>
|
4 | <a href="https://www.npmjs.com/package/serverless-random-gateway-deployment-id">
|
5 | <img src="https://flat.badgen.net/npm/dt/serverless-random-gateway-deployment-id?icon=npm"></a>
|
6 | <a href="https://packagephobia.now.sh/result?p=serverless-random-gateway-deployment-id">
|
7 | <img src="https://flat.badgen.net/packagephobia/install/serverless-random-gateway-deployment-id"></a>
|
8 | <a href="https://www.npmjs.com/package/serverless-random-gateway-deployment-id">
|
9 | <img src="https://flat.badgen.net/npm/license/serverless-random-gateway-deployment-id"></a>
|
10 | <br/>
|
11 | </p>
|
12 |
|
13 | _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._
|
14 |
|
15 | # Serverless Plugin: Random Gateway deploymentId
|
16 |
|
17 | 1. [Overview](#overview)
|
18 | 1. [Installation & Setup](#installation--setup)
|
19 | 1. [Example](#example)
|
20 |
|
21 | # Overview
|
22 | 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.
|
23 | Any deployment to an existing stage will be ignored, since CloudFormation does not redeploy a stage if the DeploymentIdentifier has not changed.
|
24 |
|
25 | The plugin parses the custom Cloudformation resources and adds a random id to the deployment-name and all references to it
|
26 |
|
27 | See the **examples** folder for a full working [example](https://github.com/yndlingsfar/serverless-random-gateway-deployment-id/tree/main/examples)
|
28 |
|
29 | # Installation & Setup
|
30 |
|
31 | Run `npm install` in your Serverless project.
|
32 |
|
33 | `$ npm install --save-dev serverless-random-gateway-deployment-id`
|
34 |
|
35 | Add the plugin to your serverless.yml file
|
36 |
|
37 | ```yml
|
38 | plugins:
|
39 | - serverless-random-gateway-deployment-id
|
40 | ```
|
41 |
|
42 | # Example
|
43 |
|
44 | The following example demonstrates a simple gateway deployment configuration. On every deploy the plugin will attach a random identifier to **ApiGatewayDeployment**
|
45 |
|
46 | ```yml
|
47 | service:
|
48 | name: user-registration
|
49 |
|
50 | provider:
|
51 | name: aws
|
52 | stage: dev
|
53 | region: eu-central-1
|
54 |
|
55 | plugins:
|
56 | - serverless-random-gateway-deployment-id
|
57 |
|
58 | functions:
|
59 |
|
60 | resources:
|
61 | Resources:
|
62 | ApiGatewayRestApi:
|
63 | Type: AWS::ApiGateway::RestApi
|
64 | Properties:
|
65 | ApiKeySourceType: HEADER
|
66 | Body: ${file(api.yml)}
|
67 | Description: "Some Description"
|
68 | FailOnWarnings: false
|
69 | Name: ${opt:stage, self:provider.stage}-some-name
|
70 | EndpointConfiguration:
|
71 | Types:
|
72 | - REGIONAL
|
73 | ApiGatewayDeployment:
|
74 | Type: AWS::ApiGateway::Deployment
|
75 | Properties:
|
76 | Description: ${opt:stage, self:provider.stage}
|
77 | RestApiId: !Ref ApiGatewayRestApi
|
78 | ApiGatewayStage:
|
79 | Type: AWS::ApiGateway::Stage
|
80 | Properties:
|
81 | StageName: ${opt:stage, self:provider.stage}
|
82 | Description: ${opt:stage, self:provider.stage} Stage
|
83 | RestApiId: !Ref ApiGatewayRestApi
|
84 | DeploymentId: !Ref ApiGatewayDeployment
|
85 | MethodSettings:
|
86 | - DataTraceEnabled: true
|
87 | HttpMethod: "*"
|
88 | LoggingLevel: ERROR
|
89 | ResourcePath: "/*"
|
90 | MetricsEnabled: true
|
91 | ApiGatewayBasePath:
|
92 | Type: AWS::ApiGateway::BasePathMapping
|
93 | DependsOn: ApiGatewayStage
|
94 | Properties:
|
95 | BasePath: some-path
|
96 | DomainName: www.test.de
|
97 | RestApiId: !Ref ApiGatewayRestApi
|
98 | Stage: !Ref ApiGatewayStage
|
99 | ```
|