diff --git a/lib/ServerlessProject.js b/lib/ServerlessProject.js index 6e2523fa1..3280b9d65 100644 --- a/lib/ServerlessProject.js +++ b/lib/ServerlessProject.js @@ -35,6 +35,7 @@ class ServerlessProject { _this.components = {}; _this.templates = {}; _this.plugins = []; + _this.resourceVars = []; } /** diff --git a/lib/actions/ResourcesDeploy.js b/lib/actions/ResourcesDeploy.js index f78e18f67..9e07b51e1 100644 --- a/lib/actions/ResourcesDeploy.js +++ b/lib/actions/ResourcesDeploy.js @@ -12,6 +12,7 @@ module.exports = function(SPlugin, serverlessPath) { SError = require(path.join(serverlessPath, 'ServerlessError')), SCli = require(path.join(serverlessPath, 'utils/cli')), BbPromise = require('bluebird'), + _ = require('lodash'), SUtils = require(path.join(serverlessPath, 'utils/index')); class ResourcesDeploy extends SPlugin { @@ -155,6 +156,7 @@ usage: serverless resources deploy`, let _this = this; let regionVars = _this.S.state.getMeta().stages[_this.evt.options.stage].regions[_this.evt.options.region].variables; + let resourceVars = [ 'iamRoleArnLambda' ].concat( _this.S.state.getProject().resourceVars); return _this.S.state.getResources({ populate: true, @@ -241,11 +243,12 @@ usage: serverless resources deploy`, // Save stack name regionVars.resourcesStackName = cfStackData.StackName; - // Save IAM Role ARN for Project Lambdas + // Save allowed (exported) CF output variables for Project Lambdas for (let i = 0; i < cfStackData.Outputs.length; i++) { - if (cfStackData.Outputs[i].OutputKey === 'IamRoleArnLambda') { - regionVars.iamRoleArnLambda = cfStackData.Outputs[i].OutputValue; - } + let varName = _.lowerFirst(cfStackData.Outputs[i].OutputKey); + if (resourceVars.indexOf(varName) !== -1) { + regionVars[varName] = cfStackData.Outputs[i].OutputValue; + } } }) .then(() => {