

# Amazon CloudFormation resources generated when AWS::Serverless::StateMachine is specified
<a name="sam-specification-generated-resources-statemachine"></a>

When an `AWS::Serverless::StateMachine` is specified, Amazon Serverless Application Model (Amazon SAM) generates an `AWS::StepFunctions::StateMachine` base Amazon CloudFormation resource.

**`AWS::StepFunctions::StateMachine`**  
*`LogicalId`: *`{{<statemachine‑LogicalId>}}`  
*Referenceable property: *N/A (you must use the `LogicalId` to reference this Amazon CloudFormation resource)

In addition to this Amazon CloudFormation resource, when `AWS::Serverless::StateMachine` is specified, Amazon SAM also generates Amazon CloudFormation resources for the following scenarios:

**Topics**
+ [Role property is not specified](#sam-specification-generated-resources-statemachine-not-role)
+ [An API event source is specified](#sam-specification-generated-resources-statemachine-api)
+ [An event bridge (or event bus) event source is specified](#sam-specification-generated-resources-statemachine-eventbridge)

## Role property is not specified
<a name="sam-specification-generated-resources-statemachine-not-role"></a>

When the `Role` property of an `AWS::Serverless::StateMachine` is *not* specified, Amazon SAM generates an `AWS::IAM::Role` Amazon CloudFormation resource.

**`AWS::IAM::Role`**  
*`LogicalId`: *`{{<statemachine‑LogicalId>}}Role`  
*Referenceable property: *N/A (you must use the `LogicalId` to reference this Amazon CloudFormation resource)

## An API event source is specified
<a name="sam-specification-generated-resources-statemachine-api"></a>

When the `Event` property of an `AWS::Serverless::StateMachine` is set to `Api`, but the `RestApiId` property is *not* specified, Amazon SAM generates the `AWS::ApiGateway::RestApi` Amazon CloudFormation resource.

**`AWS::ApiGateway::RestApi`**  
*`LogicalId`: *`ServerlessRestApi`  
*Referenceable property: *N/A (you must use the `LogicalId` to reference this Amazon CloudFormation resource)

## An event bridge (or event bus) event source is specified
<a name="sam-specification-generated-resources-statemachine-eventbridge"></a>

When the `Event` property of an `AWS::Serverless::StateMachine` is set to one of the event bridge (or event bus) types, Amazon SAM generates the `AWS::Events::Rule` Amazon CloudFormation resource. This applies to the following types: `EventBridgeRule`, `Schedule`, and `CloudWatchEvents`.

**`AWS::Events::Rule`**  
*`LogicalId`: *`{{<statemachine‑LogicalId><event‑LogicalId>}}`  
*Referenceable property: *N/A (you must use the `LogicalId` to reference this Amazon CloudFormation resource)