From 6a0de8fd39aa0c0dc79b3f57fa780e7a082c50a4 Mon Sep 17 00:00:00 2001 From: "Eslam A. Hefnawy" Date: Fri, 5 Aug 2016 03:54:18 +0900 Subject: [PATCH] added unique token to deployment logical id --- .../aws/deploy/compile/events/apiGateway/lib/deployment.js | 4 +++- .../deploy/compile/events/apiGateway/tests/deployment.js | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/plugins/aws/deploy/compile/events/apiGateway/lib/deployment.js b/lib/plugins/aws/deploy/compile/events/apiGateway/lib/deployment.js index e44d59828..28e65d0f8 100644 --- a/lib/plugins/aws/deploy/compile/events/apiGateway/lib/deployment.js +++ b/lib/plugins/aws/deploy/compile/events/apiGateway/lib/deployment.js @@ -16,8 +16,10 @@ module.exports = { } `; + const deploymentLogicalId = `DeploymentApigEvent${(new Date).getTime().toString()}`; + const newDeploymentObject = { - DeploymentApigEvent: JSON.parse(deploymentTemplate), + [deploymentLogicalId]: JSON.parse(deploymentTemplate), }; _.merge(this.serverless.service.resources.Resources, newDeploymentObject); diff --git a/lib/plugins/aws/deploy/compile/events/apiGateway/tests/deployment.js b/lib/plugins/aws/deploy/compile/events/apiGateway/tests/deployment.js index df79aadb0..7e32626fa 100644 --- a/lib/plugins/aws/deploy/compile/events/apiGateway/tests/deployment.js +++ b/lib/plugins/aws/deploy/compile/events/apiGateway/tests/deployment.js @@ -34,10 +34,12 @@ describe('#compileDeployment()', () => { it('should create a deployment resource', () => awsCompileApigEvents .compileDeployment().then(() => { + const deploymentLogicalId = Object + .keys(awsCompileApigEvents.serverless.service.resources.Resources)[0]; expect( - awsCompileApigEvents.serverless.service.resources.Resources + awsCompileApigEvents.serverless.service.resources.Resources[deploymentLogicalId] ).to.deep.equal( - serviceResourcesAwsResourcesObjectMock.Resources + serviceResourcesAwsResourcesObjectMock.Resources.DeploymentApigEvent ); }) );