Skip to content

Commit 7eaf832

Browse files
author
Frank Schmid
committed
APIG methods attached to root resources are relinked correctly
1 parent 65cc22f commit 7eaf832

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/aliasRestructureStack.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ module.exports = {
224224
uriParts[funcIndex] = { Ref: aliasName };
225225
}
226226

227+
// If the method is located on the root resource, set the parent correctly
228+
if (_.has(method, 'Properties.ResourceId.Fn::GetAtt') && method.Properties.ResourceId['Fn::GetAtt'][0] === 'ApiGatewayRestApi') {
229+
method.Properties.ResourceId = { 'Fn::ImportValue': `${stackName}-ApiGatewayRestApiRootResource` };
230+
}
231+
227232
method.Properties.RestApiId = { 'Fn::ImportValue': `${stackName}-ApiGatewayRestApi` };
228233

229234
// Check for user resource overrides

0 commit comments

Comments
 (0)