This is my first post here, so please excuse the total newb question. I have a serverless project with several lambda functions, and the next step is to create an API Gateway API to invoke them from. In the sample below I’ve got toProcessFunction which is the lambda and then the API, a resource, and a method. The API, resource and method could be total nonsense so far. In the method I need to give it a URI for the lambda, which includes the lambda’s ARN. However I cannot explain to serverless that I want the ARN there. I’ve read the serverless variables doc many times, but there doesn’t seem to be a relevant option, except maybe cf.
So what I’m wondering is whether variable interpolation happens too early in the process for this to be possible? In that case, my guess is that there’s a better way to do it. If so, please point me to the docs.
Thank you.
toProcessFunction:
handler: functions.toProcess
environment:
mysqlHost: ${self:custom.secret.mysqlHost}
mysqlUsername: ${self:custom.secret.mysqlUsername}
mysqlPassword: ${self:custom.secret.mysqlPassword}
mysqlDatabase: ${self:custom.secret.mysqlDatabase}
events:
- http:
path: toProcess
method: post
cors: true
integration: lambda
- http:
path: toProcess
method: get
cors: true
integration: lambda
role:
"doStuffFromInsideVPC"
resources:
Resources:
insideAPI:
Type: "AWS:ApiGateway::RestApi"
Properties:
Name: "inside-vpc"
Description: "API to access services inside the VPC"
EndpointConfiguration:
Types:
- EDGE
toProcessResource:
Type: "AWS::ApiGateway::Resource"
Properties:
PathPart: "toProcess"
RestApiId: insideAPI
ParentId: insideAPI.RootResourceId
toProcessMethodPOST:
Type: "AWS::ApiGateway::Method"
Properties:
HttpMethod: POST
ResourceId: toProcessResource
RestApiId: insideAPI
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: POST
Uri: "arn:aws:apigateway:#{AWS::Region}:lambda:path/2015-03-31/functions/${cf:toProcessFunction.Arn}/invocations"