Giovanni Giannichi
03/07/2022, 8:02 PMconst authorizerFunctionArn = ssm.StringParameter.valueFromLookup(
this,
'authorizerFunctionArn'
);
const authorizerFunction = lambda.Function.fromFunctionArn(
this,
'AccountsAuthorizerFunction',
Lazy.string({ produce: () => authorizerFunctionArn })
);
(Yes, I’ve tried without the lazy loading haha)
In this case, the functions are successfully attached to the authorizer, but they never really call the function when I run some endpoint. Always resulting in a instant Internal Server Error
…
Any help about this will be awesome! My last hope was the .fromFunctionName
, but this was added in CDK 2.14 (We are not there yet, I know! hahaha)Derek Kershner
03/07/2022, 8:50 PM.fromFunctionName
wont make a difference, it does the exact same thing as the arn, but makes a couple assumptions.Derek Kershner
03/07/2022, 8:50 PMDerek Kershner
03/07/2022, 8:55 PMhandler
to class HttpLambdaAuthorizer · AWS CDK (amazon.com)Derek Kershner
03/07/2022, 8:55 PMGiovanni Giannichi
03/07/2022, 10:02 PMfromFunctionName
won’t be a solution 😕
Anyway, I’m attaching the authorizer to an HTTP API Gateway imported from another project too, like this:
const mainApiId = ssm.StringParameter.valueFromLookup(this, 'mainApiId');
const httpApi = HttpApi.fromHttpApiAttributes(this, 'AccountsApi', {
httpApiId: Lazy.string({ produce: () => mainApiId }),
});
Giovanni Giannichi
03/07/2022, 10:02 PMGiovanni Giannichi
03/07/2022, 10:03 PMDerek Kershner
03/07/2022, 11:00 PMvalueFromLookup
works? That’s a new one…Derek Kershner
03/07/2022, 11:01 PMDerek Kershner
03/07/2022, 11:01 PMcdk.context.json
matches too?Giovanni Giannichi
03/08/2022, 12:51 PMfunctionName
in the original project and building manually the import path changing only what matters:
const authorizerFunction = lambda.Function.fromFunctionArn(
this,
'ContactAuthorizerFunction',
`arn:aws:lambda:${scope.region}:${scope.account}:function:mainAuthorizerFunction`
);