Context: I would like to know how I can pass a custom variable like roles: ["ROLE_ORDER_READ", "ROLE_ORDER_WRITE"]
from API Gateway OpenAPI to my REQUEST typed Lambda Authorizer. I don’t know if the custom variable needs to be stringified for AWS but it’s OK i can stringify if I have to.
My current OpenAPI definition:
openapi: 3.0.0
paths:
/api/v1/contacts/{id}/orders:
get:
x-amazon-apigateway-integration:
type: aws_proxy
uri: arn:$${AWS::Partition}:apigateway:$${AWS::Region}:lambda:path/2015-03-31/functions/${lambda_get_order_arn}/invocations
httpMethod: POST
security:
- lambda_authorizer: []
What I “want to do” (but this won’t work of course):
openapi: 3.0.0
paths:
/api/v1/contacts/{id}/orders:
get:
x-amazon-apigateway-integration:
type: aws_proxy
uri: arn:$${AWS::Partition}:apigateway:$${AWS::Region}:lambda:path/2015-03-31/functions/${lambda_get_order_arn}/invocations
httpMethod: POST
# SEE HERE:
customVariables:
roles: ["ROLE_ORDER_READ", "ROLE_ORDER_WRITE"]
security:
- lambda_authorizer: []
Questions:
- How can I achieve that with OpenAPI? Is there a specific
x-amazon-apigateway-XXX
to use? - Then how to access this custom
roles
variable from theevent
orcontext
parameters of my Lambda Authorizer?
Notes:
- I use Terraform with OpenAPI definition, I don’t use CloudFormation
- I would like to pass custom variables from the API Gateway to the Lambda Authorizer (not from Lambda Authorizer to business lambda)
- Each routes defined in the OpenAPI will have its own
roles
passed to the Lambda Authorizer