本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用中其他支持的属性来定义资源 Amazon SAM
对于源资源和目标资源,如果在同一个模板中定义,则使用 Id
属性。或者,可以添加 Qualifier
以缩小您定义的资源范围。当资源不在同一个模板中时,请使用受支持属性的组合。
-
有关源资源和目标资源支持的属性组合列表,请参阅 连接器支持的源资源和目的地资源类型。
-
有关可用于连接器的属性的说明,请参见 AWS::Serverless::Connector。
在定义具有 Id
之外属性的源资源时,请使用 SourceReference
属性。
AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 ... Resources:
<source-resource-logical-id>
: Type:<resource-type>
... Connectors:<connector-name>
: Properties: SourceReference: Qualifier:<optional-qualifier>
<other-supported-properties>
Destination:<properties-that-identify-destination-resource>
Permissions:<permission-types-to-provision>
以下是使用缩小 Amazon API Gateway 资源的范围的示例:Qualifier
AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 ... Resources: MyApi: Type: AWS::Serverless::Api Connectors: ApiToLambdaConn: Properties: SourceReference: Qualifier: Prod/GET/foobar Destination: Id: MyFunction Permissions: - Write ...
以下示例使用支持的 Arn
和 Type
组合定义来自另一个模板的目标资源:
AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 ... Resources: MyFunction: Type: AWS::Serverless::Function Connectors: TableConn: Properties: Destination: Type: AWS::DynamoDB::Table Arn: !GetAtt MyTable.Arn ...
有关使用连接器的更多信息,请参阅 Amazon SAM 连接器参考。