I have a serverless application defined like this
service: hello_world
frameworkVersion: '3'
provider:
name: aws
runtime: python3.8
functions:
hello:
handler: handler.run
world:
handler: handler2.run
url: true
Part of the function hello
is to hand the function url of world
to an external api.
How can I get the function url to hello
, as an environment variable or otherwise?
Have not tested, but according to the following you can use what looks like cloudformation fn + backreferences
https://forum.serverless.com/t/how-do-i-get-the-url-for-a-function-in-my-serverless-yml-file/1386/4
custom:
stage: ${opt:stage, self:provider.stage}
region: ${opt:region, self:provider.region}
environment:
URL: { "Fn::Join" : ["", [" https://", { "Ref" : "ApiGatewayRestApi" }, ".execute-api.${self:custom.region}.amazonaws.com/${self:custom.stage}/path/to/resource" ] ] }
You need to know how Serverless is internally referencing the function URLs, which should be accessable in this format. You can check this by viewing the resource names in AWS.
service: hello_world
frameworkVersion: '3'
provider:
name: aws
runtime: python3.8
functions:
fn1:
handler: handler.run
url: true
fn2:
handler: handler2.run
environment:
GRANT_URL_ENDPOINT: !Ref Fn1LambdaFunctionUrl
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.