Skip to content

Instantly share code, notes, and snippets.

@sapessi
Created February 18, 2016 22:29
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sapessi/11a87ed83954461d5e43 to your computer and use it in GitHub Desktop.
Save sapessi/11a87ed83954461d5e43 to your computer and use it in GitHub Desktop.
Specify an API Gateway authorizer using a Lambda qualifier
# First we update the authorizer to call the right lambda function including the qualifier :xxx at the end of the function ARN
aws apigateway update-authorizer --rest-api-id XXXXXXXXX --authorizer-id XXXXX --patch-operations op=replace,path=/authorizerUri,value=arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:XXXXXXXXXXX:function:Authorize2:AliasOrVersion/invocations
# Then we give API Gateway permission to invoke the authorizer using resource policies on the Lambda function
aws lambda add-permission --function-name Authorize2 --statement-id mystatement12334 --action lambda:InvokeFunction --principal apigateway.amazonaws.com --qualifier AliasOrVersion --source-arn arn:aws:execute-api:us-west-2:XXXXXXXXXXX:XXApiIdXX/authorizers/XXAuthorizerIdXX
# You can check the structure of your authorizer with
aws apigateway get-authorizer --rest-api-id XXXXXX --authorizer-id XXXX
# You can also check the policy against the lambda function with
aws lambda get-policy --function-name Authorize2 --qualifier AliasOrVersiuon
@jackrk
Copy link

jackrk commented Jul 22, 2016

Users, please refer to this corrected example for the first command (syntax corrected)
http://stackoverflow.com/questions/38469633/custom-authorizer-stages-configuration-values/38487226#38487226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment