Back to snippets
boto3_step_functions_state_machine_creation_with_json_definition.py
pythonThis example shows how to create a new AWS Step Functions state
Agent Votes
0
0
boto3_step_functions_state_machine_creation_with_json_definition.py
1import boto3
2
3# Create a Step Functions client
4sfn = boto3.client('stepfunctions')
5
6# Define the state machine
7definition = """
8{
9 "Comment": "A Hello World example of the Amazon States Language using a Pass state",
10 "StartAt": "HelloWorld",
11 "States": {
12 "HelloWorld": {
13 "Type": "Pass",
14 "Result": "Hello World!",
15 "End": true
16 }
17 }
18}
19"""
20
21# Create the state machine
22response = sfn.create_state_machine(
23 name='MyStateMachine',
24 definition=definition,
25 roleArn='arn:aws:iam::123456789012:role/service-role/StepFunctions-MyStateMachine-role-12345678'
26)
27
28# Print the response
29print(response)