我正在开发一个无服务器框架(云形成(,我在同一个AWS区域中创建了两个堆栈,每个serverless.yml(stack1,stack2(都有自己的API。如何在stack-2yml中获取stack-1(yml(API URL。
Stack-1(serverless1.yml)
functions:
tGateWay:
handler: src/handlers/tGateWay.handler
name: ${self:provider.stage}-tGateWay
environment:
first: ${self:provider.stage}-firstlambda
events:
- http:
method: any
path: /tGateway
private: true
Stack-2(serverless2.yml)
functions:
tModule:
handler: src/handlers/tModule.handler
name: ${self:provider.stage}-tModule
environment:
find: ${self:provider.stage}-find
T_GATEWAY: https://xxxxxxxxx.execute-api.xxxxxxx-1.amazonaws.com/dev/tGateway
在该T_GATEWAY中,我想访问堆栈-1 API网关URL
提前感谢!
您可以使用SecretsManager,并可以通过以下方式将其导入到您的函数中:
iamRoleStatements:
- Effect: Allow
Action:
- secretsmanager:GetSecretValue
functions:
handler.js
myHandler:
handler: myHandler
environment:
yourSecretKey: "{{resolve:secretsmanager:secretYouCreated:SecretString:yourSecretKey}}"