我正在使用 SAM 创建 ApiGateway 休息资源。我想要一个 post 方法来调用现有的 lambda 函数。我该怎么做?我尝试使用以下模板,但失败并出现错误
“失败”状态:失败。原因:模板格式错误:模板的资源块中未解析的资源依赖项 [arn:aws:lambda:us-east-1:1111111111:function:LabBytesServer-AddAccountFunction-iasdsaddsdsads]
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
MyApi:
Type: AWS::Serverless::Api
Properties:
StageName: dev
DefinitionBody:
info:
version: '1.0'
paths:
/myendpoint:
post:
responses: { }
x-amazon-apigateway-integration:
uri: !Join
- ""
- - "arn:aws:apigateway:"
- !Ref "AWS::Region"
- ":lambda:path/2015-03-31/functions/"
- !Ref arn:aws:lambda:us-east-1:111111111:function:LabBytesServer-AddAccountFunction-das2efadsdsafasd
- "/invocations"
httpMethod: POST
type: aws_proxy
Tags:
app: "labBytes"
env: "dev"
您可以尝试使用
!Ref
而不是使用 !Sub
并给出 lambda 函数吗?例如下面:
uri: !Join
- ""
- - "arn:aws:apigateway:"
- !Ref "AWS::Region"
- ":lambda:path/2015-03-31/functions/"
- !Sub arn:aws:lambda:us-east-1:111111111:function:LabBytesServer-AddAccountFunction-das2efadsdsafasd
- "/invocations"