

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# CloudFormation 指定时AWS::Serverless::StateMachine生成的资源
<a name="sam-specification-generated-resources-statemachine"></a>

如果指定了 `AWS::Serverless::StateMachine`， AWS Serverless Application Model (AWS SAM) 会生成 `AWS::StepFunctions::StateMachine` 基本 CloudFormation 资源。

**`AWS::StepFunctions::StateMachine`**  
*`LogicalId`: *`<statemachine‑LogicalId>`  
*可引用的属性：*N/A（必须使用`LogicalId`来引用此 CloudFormation 资源）

除此 CloudFormation 资源外，如果指定了`AWS::Serverless::StateMachine`此资源， AWS SAM 还会生成用于以下场景的 CloudFormation 资源：

**Topics**
+ [未指定 Role 属性](#sam-specification-generated-resources-statemachine-not-role)
+ [指定了 API 事件源](#sam-specification-generated-resources-statemachine-api)
+ [指定了事件桥（或事件总线）事件源](#sam-specification-generated-resources-statemachine-eventbridge)

## 未指定 Role 属性
<a name="sam-specification-generated-resources-statemachine-not-role"></a>

如果*未*指定 a `AWS::Serverless::StateMachine` 的`Role`属性，则 AWS SAM 会生成`AWS::IAM::Role` CloudFormation 资源。

**`AWS::IAM::Role`**  
*`LogicalId`: *`<statemachine‑LogicalId>Role`  
*可引用的属性：*N/A（必须使用`LogicalId`来引用此 CloudFormation 资源）

## 指定了 API 事件源
<a name="sam-specification-generated-resources-statemachine-api"></a>

如果的`Event`属性设置`AWS::Serverless::StateMachine`为`Api`，但*未*指定该`RestApiId`属性，则 AWS SAM 生成`AWS::ApiGateway::RestApi` CloudFormation 资源。

**`AWS::ApiGateway::RestApi`**  
*`LogicalId`: *`ServerlessRestApi`  
*可引用的属性：*N/A（必须使用`LogicalId`来引用此 CloudFormation 资源）

## 指定了事件桥（或事件总线）事件源
<a name="sam-specification-generated-resources-statemachine-eventbridge"></a>

将的`Event`属性设置`AWS::Serverless::StateMachine`为事件桥（或事件总线）类型之一时， AWS SAM 会生成`AWS::Events::Rule` CloudFormation 资源。这适用于以下类型：`EventBridgeRule`、`Schedule` 和 `CloudWatchEvents`。

**`AWS::Events::Rule`**  
*`LogicalId`: *`<statemachine‑LogicalId><event‑LogicalId>`  
*可引用的属性：*N/A（必须使用`LogicalId`来引用此 CloudFormation 资源）