简体   繁体   English

无服务器框架从单独的 function 获取 AWS“函数 url”

[英]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.

相关问题 AWS Lambda function on Java with Serverless framework and GraalVM - AWS Lambda function on Java with Serverless framework and GraalVM 从无服务器框架添加环境变量 lambda function - Add environment variable in lambda function from serverless framework 来自无服务器框架的日志未显示在 AWS CloudWatch 上 - Logs from Serverless framework is not showing on AWS CloudWatch 如何使用 serverless.io 框架和 serverless.yml 文件将整数作为变量传递给 aws-step-function 中的等待状态类型 - How to Pass integer as variable to Wait Type of State in aws-step-function using serverless.io framework and the serverless.yml file 如何在 AWS 无服务器 Function 上设置 Oauth 范围? - How to setup Oauth scopes at AWS Serverless Function? 是否可以从 AWS 无服务器 API 中的其他 lambda 函数调用 lambda function? - Is it possible to call lambda function from other lambda functions in AWS serverless API? 如何从 AWS Lambda 函数 + 无服务器框架的 URL 中删除阶段? - How to remove stage from URLs for AWS Lambda functions + Serverless framework? 如何使用 AWS 的无服务器框架获取最新的 Layer 版本 Lambda - How to get latest Layer version with serverless framework for AWS Lambda “errorMessage”:在 AWS 无服务器上部署时“server.app.use 不是一个函数” - "errorMessage": "server.app.use is not a function" while deploying on AWS serverless 如何将无服务器客户端与给定的 AWS 连接 Lambda function - how to connect a serverless client with a given AWS Lambda function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM