From f2ed6749d8c1548fa0a1d82d876896a4c5e8699e Mon Sep 17 00:00:00 2001 From: Danny Shisler Date: Tue, 18 Sep 2018 01:45:43 +0100 Subject: [PATCH 1/2] Match serverless framework generation of ServiceEndpoint value --- lib/deploy/events/apiGateway/deployment.js | 4 +- .../events/apiGateway/deployment.test.js | 68 +++++++++++-------- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/lib/deploy/events/apiGateway/deployment.js b/lib/deploy/events/apiGateway/deployment.js index af233bd4..66bde844 100644 --- a/lib/deploy/events/apiGateway/deployment.js +++ b/lib/deploy/events/apiGateway/deployment.js @@ -27,7 +27,9 @@ module.exports = { [ 'https://', this.provider.getApiGatewayRestApiId(), - `.execute-api.${this.options.region}.amazonaws.com/${this.options.stage}`, + `.execute-api.${this.options.region}.`, + { Ref: 'AWS::URLSuffix' }, + `/${this.options.stage}`, ], ], }, diff --git a/lib/deploy/events/apiGateway/deployment.test.js b/lib/deploy/events/apiGateway/deployment.test.js index db90adc4..3ff065a8 100644 --- a/lib/deploy/events/apiGateway/deployment.test.js +++ b/lib/deploy/events/apiGateway/deployment.test.js @@ -27,43 +27,53 @@ describe('#compileDeployment()', () => { }); it('should create a deployment resource', () => serverlessStepFunctions - .compileDeployment().then(() => { + .compileDeployment() + .then(() => { const apiGatewayDeploymentLogicalId = Object .keys(serverlessStepFunctions.serverless.service.provider .compiledCloudFormationTemplate.Resources)[0]; expect( serverlessStepFunctions.serverless.service.provider.compiledCloudFormationTemplate - .Resources[apiGatewayDeploymentLogicalId] - ).to.deep.equal({ - Type: 'AWS::ApiGateway::Deployment', - DependsOn: ['method-dependency1', 'method-dependency2'], - Properties: { - RestApiId: { Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId }, - StageName: 'dev', - }, - }); - }) + .Resources[apiGatewayDeploymentLogicalId], + ) + .to + .deep + .equal({ + Type: 'AWS::ApiGateway::Deployment', + DependsOn: ['method-dependency1', 'method-dependency2'], + Properties: { + RestApiId: { Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId }, + StageName: 'dev', + }, + }); + }), ); it('should add service endpoint output', () => - serverlessStepFunctions.compileDeployment().then(() => { - expect( - serverlessStepFunctions.serverless.service.provider.compiledCloudFormationTemplate - .Outputs.ServiceEndpoint - ).to.deep.equal({ - Description: 'URL of the service endpoint', - Value: { - 'Fn::Join': [ - '', - [ - 'https://', - { Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId }, - '.execute-api.us-east-1.amazonaws.com/dev', - ], - ], - }, - }); - }) + serverlessStepFunctions.compileDeployment() + .then(() => { + expect( + serverlessStepFunctions.serverless.service.provider.compiledCloudFormationTemplate + .Outputs.ServiceEndpoint, + ) + .to + .deep + .equal({ + Description: 'URL of the service endpoint', + Value: { + 'Fn::Join': [ + '', + [ + 'https://', + { Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId }, + '.execute-api.us-east-1.', + { Ref: 'AWS::URLSuffix' }, + '/dev', + ], + ], + }, + }); + }), ); }); From 91720c60366993b52a8a30bf97794b3d52608f1c Mon Sep 17 00:00:00 2001 From: Danny Shisler Date: Tue, 18 Sep 2018 01:52:59 +0100 Subject: [PATCH 2/2] Undo odd IDE code formatting --- .../events/apiGateway/deployment.test.js | 70 ++++++++----------- 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/lib/deploy/events/apiGateway/deployment.test.js b/lib/deploy/events/apiGateway/deployment.test.js index 3ff065a8..7dc7cf31 100644 --- a/lib/deploy/events/apiGateway/deployment.test.js +++ b/lib/deploy/events/apiGateway/deployment.test.js @@ -27,53 +27,45 @@ describe('#compileDeployment()', () => { }); it('should create a deployment resource', () => serverlessStepFunctions - .compileDeployment() - .then(() => { + .compileDeployment().then(() => { const apiGatewayDeploymentLogicalId = Object .keys(serverlessStepFunctions.serverless.service.provider .compiledCloudFormationTemplate.Resources)[0]; expect( serverlessStepFunctions.serverless.service.provider.compiledCloudFormationTemplate - .Resources[apiGatewayDeploymentLogicalId], - ) - .to - .deep - .equal({ - Type: 'AWS::ApiGateway::Deployment', - DependsOn: ['method-dependency1', 'method-dependency2'], - Properties: { - RestApiId: { Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId }, - StageName: 'dev', - }, - }); - }), + .Resources[apiGatewayDeploymentLogicalId] + ).to.deep.equal({ + Type: 'AWS::ApiGateway::Deployment', + DependsOn: ['method-dependency1', 'method-dependency2'], + Properties: { + RestApiId: { Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId }, + StageName: 'dev', + }, + }); + }) ); it('should add service endpoint output', () => - serverlessStepFunctions.compileDeployment() - .then(() => { - expect( - serverlessStepFunctions.serverless.service.provider.compiledCloudFormationTemplate - .Outputs.ServiceEndpoint, - ) - .to - .deep - .equal({ - Description: 'URL of the service endpoint', - Value: { - 'Fn::Join': [ - '', - [ - 'https://', - { Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId }, - '.execute-api.us-east-1.', - { Ref: 'AWS::URLSuffix' }, - '/dev', - ], - ], - }, - }); - }), + serverlessStepFunctions.compileDeployment().then(() => { + expect( + serverlessStepFunctions.serverless.service.provider.compiledCloudFormationTemplate + .Outputs.ServiceEndpoint + ).to.deep.equal({ + Description: 'URL of the service endpoint', + Value: { + 'Fn::Join': [ + '', + [ + 'https://', + { Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId }, + '.execute-api.us-east-1.', + { Ref: 'AWS::URLSuffix' }, + '/dev', + ], + ], + }, + }); + }) ); });