Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

serverless-plugin-stage-variables

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-plugin-stage-variables - npm Package Compare versions

Comparing version 1.2.3 to 1.3.4

2

package.json

@@ -18,3 +18,3 @@ {

"name": "serverless-plugin-stage-variables",
"version": "1.2.3"
"version": "1.3.4"
}

@@ -26,7 +26,16 @@ 'use strict';

// create a config for the stage
var config = {
StageName: this._serverless.service.provider.stage,
// console.log(this._serverless);
var stage = this._serverless.service.defaults.stage;
if (this._serverless.variables.options.stage) {
stage = this._serverless.variables.options.stage;
}
// var stage =
// create a config for the deployment, which can be ignored, see:
// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-deployment.html
var deploymentConfig = {
StageName: `${stage}na`,
StageDescription: {
StageName: this._serverless.service.provider.stage,
StageName: `${stage}na`,
Variables: variables,

@@ -36,11 +45,37 @@ }

// create a stage resource, which sets the stage and variables correctly
var stageConfig = {
Type: "AWS::ApiGateway::Stage",
Properties: {
StageName: stage,
Description: stage,
RestApiId: {"Ref": "ApiGatewayRestApi"},
DeploymentId: null,
Variables: variables,
}
}
// find the deployment resource, and add the stage variables
Object.keys(template.Resources).forEach(function(key){
if (template.Resources[key]['Type'] == 'AWS::ApiGateway::Deployment') {
template.Resources[key] = _.merge(template.Resources[key], config);
var DeploymentResource = template.Resources[key];
// set the deployment variables as well, just because we can
DeploymentResource.Properties = _.merge(DeploymentResource.Properties, deploymentConfig);
template.Resources[key] = DeploymentResource;
// add stage config
stageConfig.Properties.DeploymentId = {"Ref":key}
template.Resources.ApiGatewayStage = stageConfig;
}
// we need to make all api keys dependend on the stage, not the deployment
if (template.Resources[key]['Type'] == 'AWS::ApiGateway::ApiKey') {
template.Resources[key]['DependsOn'] = 'ApiGatewayStage';
}
})
this._serverless.cli.log('Merged stage variables into ApiGateway Deployment');
},
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc