@@ -225,11 +225,13 @@ module.exports = function(currentTemplate, aliasStackTemplates, currentAliasStac
225
225
const authorizerType = _ . get ( authorizer , 'Properties.Type' ) ;
226
226
if ( authorizerType === 'TOKEN' || authorizerType === 'REQUEST' ) {
227
227
const uriParts = authorizer . Properties . AuthorizerUri [ 'Fn::Join' ] [ 1 ] ;
228
- const funcIndex = _ . findIndex ( uriParts , part =>
229
- _ . has ( part , 'Fn::GetAtt' ) || _ . startsWith ( part , 'arn:aws:lambda' ) ) ;
228
+ if ( _ . every ( uriParts , part => ! _ . startsWith ( part , 'arn:aws:lambda' ) ) ) {
229
+ const funcIndex = _ . findIndex ( uriParts , part =>
230
+ _ . has ( part , 'Fn::GetAtt' ) || _ . startsWith ( part , 'arn:aws:lambda' ) ) ;
230
231
231
- // Use the SERVERLESS_ALIAS stage variable to determine the called function alias
232
- uriParts . splice ( funcIndex + 1 , 0 , ':${stageVariables.SERVERLESS_ALIAS}' ) ;
232
+ // Use the SERVERLESS_ALIAS stage variable to determine the called function alias
233
+ uriParts . splice ( funcIndex + 1 , 0 , ':${stageVariables.SERVERLESS_ALIAS}' ) ;
234
+ }
233
235
}
234
236
235
237
authorizer . Properties . Name = `${ authorizer . Properties . Name } -${ this . _alias } ` ;
@@ -268,6 +270,7 @@ module.exports = function(currentTemplate, aliasStackTemplates, currentAliasStac
268
270
const aliasName = _ . find ( _ . keys ( aliases ) , alias => _ . startsWith ( alias , functionName ) ) ;
269
271
const isExternalRef = _ . startsWith ( permission . Properties . FunctionName , 'arn:aws:lambda' ) ;
270
272
273
+ console . log ( 'checking permission: ' , name , JSON . stringify ( permission ) , ' isExternalRef: ' + isExternalRef ) ;
271
274
// Adjust references and alias permissions
272
275
if ( ! isExternalRef ) {
273
276
permission . Properties . FunctionName = { Ref : aliasName } ;
0 commit comments