我有一个需要通过Amazon API Gateway触发的Lambda函数。是否有一种方式可以将已经存在的API(使用AWS控制台创建)包含到AWS SAM模板中?
# You need to export the resource that you want to use in another template first
# This goes at the end of your template.yml file, after the Resources
# template.yml in the first repo
Outputs:
myExportedResource:
Value: !Ref TheResource
Export:
Name: !Sub "{environment}-nice-export-name"
# template.yml in the second repo (This obviously goes in Resources)
MyLambda:
Type: AWS::Serverless::Function
Properties:
FunctionName: awesome-lambda
CodeUri: ./dist
Handler: this-file.handler
Role: !GetAtt LambdaRole.Arn
VpcConfig:
SecurityGroupIds:
- !GetAtt SecurityGroup.GroupId
SubnetIds:
- Fn::ImportValue: !Sub "${environment}-nice-export-name"
!ImportValue
的文档? - Mooncrater!ImportValue
一样使用它。请确保拥有最新的sam cli版本。您可以在shell中输入sam --version
来检查版本。请确保至少使用版本1.24.1。 - Benjamin Filiatrault