[英]Serverless framework get AWS "function url" from separate function
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. function
hello
的一部分是把world
的function url交给外部的api。
How can I get the function url to hello
, as an environment variable or otherwise?如何将 function url 作为环境变量或其他方式获取
hello
?
Have not tested, but according to the following you can use what looks like cloudformation fn + backreferences尚未测试,但根据以下内容,您可以使用看起来像 cloudformation fn + backreferences 的内容
https://forum.serverless.com/t/how-do-i-get-the-url-for-a-function-in-my-serverless-yml-file/1386/4 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.您需要知道 Serverless 如何在内部引用 function URL,这些 URL应该可以以这种格式访问。 You can check this by viewing the resource names in AWS.
您可以通过查看 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.