Skip to content

Commit f2ed674

Browse files
committed
Match serverless framework generation of ServiceEndpoint value
1 parent cfc12b1 commit f2ed674

File tree

2 files changed

+42
-30
lines changed

2 files changed

+42
-30
lines changed

lib/deploy/events/apiGateway/deployment.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ module.exports = {
2727
[
2828
'https://',
2929
this.provider.getApiGatewayRestApiId(),
30-
`.execute-api.${this.options.region}.amazonaws.com/${this.options.stage}`,
30+
`.execute-api.${this.options.region}.`,
31+
{ Ref: 'AWS::URLSuffix' },
32+
`/${this.options.stage}`,
3133
],
3234
],
3335
},

lib/deploy/events/apiGateway/deployment.test.js

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,53 @@ describe('#compileDeployment()', () => {
2727
});
2828

2929
it('should create a deployment resource', () => serverlessStepFunctions
30-
.compileDeployment().then(() => {
30+
.compileDeployment()
31+
.then(() => {
3132
const apiGatewayDeploymentLogicalId = Object
3233
.keys(serverlessStepFunctions.serverless.service.provider
3334
.compiledCloudFormationTemplate.Resources)[0];
3435

3536
expect(
3637
serverlessStepFunctions.serverless.service.provider.compiledCloudFormationTemplate
37-
.Resources[apiGatewayDeploymentLogicalId]
38-
).to.deep.equal({
39-
Type: 'AWS::ApiGateway::Deployment',
40-
DependsOn: ['method-dependency1', 'method-dependency2'],
41-
Properties: {
42-
RestApiId: { Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId },
43-
StageName: 'dev',
44-
},
45-
});
46-
})
38+
.Resources[apiGatewayDeploymentLogicalId],
39+
)
40+
.to
41+
.deep
42+
.equal({
43+
Type: 'AWS::ApiGateway::Deployment',
44+
DependsOn: ['method-dependency1', 'method-dependency2'],
45+
Properties: {
46+
RestApiId: { Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId },
47+
StageName: 'dev',
48+
},
49+
});
50+
}),
4751
);
4852

4953
it('should add service endpoint output', () =>
50-
serverlessStepFunctions.compileDeployment().then(() => {
51-
expect(
52-
serverlessStepFunctions.serverless.service.provider.compiledCloudFormationTemplate
53-
.Outputs.ServiceEndpoint
54-
).to.deep.equal({
55-
Description: 'URL of the service endpoint',
56-
Value: {
57-
'Fn::Join': [
58-
'',
59-
[
60-
'https://',
61-
{ Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId },
62-
'.execute-api.us-east-1.amazonaws.com/dev',
63-
],
64-
],
65-
},
66-
});
67-
})
54+
serverlessStepFunctions.compileDeployment()
55+
.then(() => {
56+
expect(
57+
serverlessStepFunctions.serverless.service.provider.compiledCloudFormationTemplate
58+
.Outputs.ServiceEndpoint,
59+
)
60+
.to
61+
.deep
62+
.equal({
63+
Description: 'URL of the service endpoint',
64+
Value: {
65+
'Fn::Join': [
66+
'',
67+
[
68+
'https://',
69+
{ Ref: serverlessStepFunctions.apiGatewayRestApiLogicalId },
70+
'.execute-api.us-east-1.',
71+
{ Ref: 'AWS::URLSuffix' },
72+
'/dev',
73+
],
74+
],
75+
},
76+
});
77+
}),
6878
);
6979
});

0 commit comments

Comments
 (0)