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 ); }) );