### Start Docker Image with Specific Mock Config File Path Source: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-test-sm-exec.md An example command to start the Step Functions Local Docker image, demonstrating the mounting of a specific mock configuration file and setting the environment variable. ```bash docker run -p 8083:8083 \ --mount type=bind,readonly,source=/Users/admin/Desktop/workplace/MockConfigFile.json,destination=/home/StepFunctionsLocal/MockConfigFile.json \ -e SFN_MOCK_CONFIG="/home/StepFunctionsLocal/MockConfigFile.json" amazon/aws-stepfunctions-local ``` -------------------------------- ### Example Initial Execution Input Source: https://docs.aws.amazon.com/step-functions/latest/dg/concepts-statemachines.md The JSON input provided when starting a Step Functions execution. This data is passed to the 'StartAt' state of the state machine. ```json { "numbers": [3, 4] } ``` -------------------------------- ### Step Functions Local JAR Startup Log Source: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-lambda.md Example log output when Step Functions Local starts using the JAR file. It shows credential loading and server startup information. ```log 2019-01-29 15:38:06.324: Failed to load credentials from environment because Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)) 2019-01-29 15:38:06.326: Loaded credentials from profile: default 2019-01-29 15:38:06.326: Starting server on port 8083 with account {{account-id}}, region us-east-1 ``` -------------------------------- ### Example StartExecution Response Source: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-test-sm-exec.md This is a sample response from the `StartExecution` API call when using mocked service integrations. It includes the execution ARN and start date, similar to a normal execution. ```json { "startDate":"2022-01-28T15:03:16.981000-05:00", "executionArn":"arn:aws:states:{{region}}:{{account-id}}:execution:LambdaSQSIntegration:executionWithHappyPathMockedServices" } ``` -------------------------------- ### Synchronous StartExecution Output Example Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-stepfunctions.md Example of the output format when using the startExecution.sync resource, which returns the nested state machine's output as a string. ```json { {{}} "Output": " { \"MyKey\": \"MyValue\" } " } ``` -------------------------------- ### Synchronous StartExecution:2 Output Example Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-stepfunctions.md Example of the output format when using the startExecution.sync:2 resource, which returns the nested state machine's output as a JSON object. ```json { {{}} "Output": { "MyKey": "MyValue" } } ``` -------------------------------- ### Example Batch Input Configuration Source: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-itembatcher.md This example shows how to specify a fixed JSON input to be included in each batch passed to child workflow executions. ```json "ItemBatcher": { "BatchInput": { "factCheck": "December 2022" } } ``` -------------------------------- ### Start Step Functions Local Source: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local.md Execute this command in the directory containing the StepFunctionsLocal.jar file to start the local Step Functions service. ```bash java -jar StepFunctionsLocal.jar ``` -------------------------------- ### Sample Input for Parallel State Example Source: https://docs.aws.amazon.com/step-functions/latest/dg/transforming-data.md This is a sample input JSON object for the Parallel state example, providing IDs for order and customer. ```json { "orderId": "12345", "customerId": "C-100" } ``` -------------------------------- ### Start State Machine Execution with Callback Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-stepfunctions.md Use this Task state to start a new execution and implement the callback service integration pattern using a task token. ```json { "Type":"Task", "Resource":"arn:aws:states:::states:startExecution.waitForTaskToken", "Arguments":{ "Input":{ "Comment": "Hello world!", "token": "{% $states.context.Task.Token %}" }, "StateMachineArn":"arn:aws:states:{{region}}:{{account-id}}:stateMachine:HelloWorld", "Name":"ExecutionName" }, "End":true } ``` -------------------------------- ### Example Input for Max Items Per Batch Path Source: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-itembatcher.md This example shows a JSON input that specifies the maximum number of items per batch using a reference path. ```json { "maxBatchItems": 500 } ``` -------------------------------- ### Start Step Functions Local with JAR Source: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-lambda.md Use this command to start Step Functions Local when using the JAR file distribution. It specifies the Lambda endpoint for local integration. ```bash java -jar StepFunctionsLocal.jar --lambda-endpoint http://localhost:3001 ``` -------------------------------- ### Start State Machine Execution with AWS CLI Source: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local.md Command to start an execution of a previously created state machine using the AWS CLI and Step Functions Local endpoint. ```bash aws stepfunctions --endpoint-url http://localhost:8083 start-execution --state-machine-arn arn:aws:states:{{region}}:{{account-id}}:stateMachine:HelloWorld ``` -------------------------------- ### Initialize AWS SAM Application Source: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-state-machine-using-sam.md Use 'sam init' to download a sample application. Follow prompts to select template, language, project name, and a quick start application like 'Multi-step workflow'. ```bash sam init ``` -------------------------------- ### IAM Policy for Starting and Stopping Builds (Static Resources) Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-codebuild.md This policy allows starting, stopping, and getting build information for a specific CodeBuild project. It also includes permissions for related events actions. ```json { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "codebuild:StartBuild", "codebuild:StopBuild", "codebuild:BatchGetBuilds" ], "Resource": [ "arn:aws:codebuild:{{us-east-1}}:{{123456789012}}:project/{{myProjectName}}" ] }, { "Effect": "Allow", "Action": [ "events:PutTargets", "events:PutRule", "events:DescribeRule" ], "Resource": [ "arn:aws:events:{{us-east-1}}:{{123456789012}}:rule/StepFunctionsGetEventForCodeBuildStartBuildRule" ] } ] } ``` -------------------------------- ### Initialize Go AWS CDK Project Source: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-step-functions-rest-api-integration-cdk.md Create a directory and initialize a new AWS CDK project with Go as the language. ```bash mkdir stepfunctions-rest-api cd stepfunctions-rest-api cdk init --language go ``` -------------------------------- ### EMR Serverless StartApplication IAM Policy (Dynamic Resources) Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-emr-serverless.md Use this policy for starting EMR Serverless applications with dynamic resource configurations. It allows starting, getting, and stopping applications, and configuring EventBridge rules for any application. ```json { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "emr-serverless:StartApplication", "emr-serverless:GetApplication", "emr-serverless:StopApplication" ], "Resource": [ "arn:aws:emr-serverless:{{us-east-1}}:{{123456789012}}:/applications/*" ] }, { "Effect": "Allow", "Action": [ "events:PutTargets", "events:PutRule", "events:DescribeRule" ], "Resource": [ "arn:aws:events:{{us-east-1}}:{{123456789012}}:rule/{{StepFunctionsGetEventsForEMRServerlessApplicationRule}}" ] } ] } ``` -------------------------------- ### EMR Serverless StartApplication IAM Policy (Static Resources) Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-emr-serverless.md Use this policy when starting an EMR Serverless application with static resource configurations. It grants permissions for starting, getting, and stopping applications, as well as for EventBridge rules. ```json { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "emr-serverless:StartApplication", "emr-serverless:GetApplication", "emr-serverless:StopApplication" ], "Resource": [ "arn:aws:emr-serverless:{{us-east-1}}:{{123456789012}}:/applications/{{applicationId}}" ] }, { "Effect": "Allow", "Action": [ "events:PutTargets", "events:PutRule", "events:DescribeRule" ], "Resource": [ "arn:aws:events:{{us-east-1}}:{{123456789012}}:rule/{{StepFunctionsGetEventsForEMRServerlessApplicationRule}}" ] } ] } ``` -------------------------------- ### Start Docker Image with Mock Config Mount and Environment Variable Source: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-test-sm-exec.md Use this command to start the Step Functions Local Docker image, mounting a mock configuration file and setting the SFN_MOCK_CONFIG environment variable. ```bash docker run -p 8083:8083 \ --mount type=bind,readonly,source={absolute path to mock config file},destination=/home/StepFunctionsLocal/MockConfigFile.json \ -e SFN_MOCK_CONFIG="/home/StepFunctionsLocal/MockConfigFile.json" amazon/aws-stepfunctions-local ``` -------------------------------- ### IAM Policy for Starting and Stopping Builds (Dynamic Resources) Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-codebuild.md This policy grants permissions to start, stop, and get build information for any CodeBuild project within an account. It also includes permissions for related events actions. ```json { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "codebuild:StartBuild", "codebuild:StopBuild", "codebuild:BatchGetBuilds" ], "Resource": [ "arn:aws:codebuild:{{us-east-1}}:*:project/*" ] }, { "Effect": "Allow", "Action": [ "events:PutTargets", "events:PutRule", "events:DescribeRule" ], "Resource": [ "arn:aws:events:{{us-east-1}}:{{123456789012}}:rule/StepFunctionsGetEventForCodeBuildStartBuildRule" ] } ] } ``` -------------------------------- ### Specify HTTP Method Source: https://docs.aws.amazon.com/step-functions/latest/dg/call-https-apis.md This example shows how to set the HTTP method for the API call using the 'Method' field. The GET method is used here. ```json "Method": "GET" ``` -------------------------------- ### Initialize C# AWS CDK Project Source: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-step-functions-rest-api-integration-cdk.md Create a directory and initialize a new AWS CDK project with C# as the language. ```bash mkdir stepfunctions-rest-api cd stepfunctions-rest-api cdk init --language csharp ``` -------------------------------- ### Example Input for State Machine Execution Source: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-handling-error-conditions.md This JSON input is used when starting a Step Functions state machine execution to simulate a custom function error. ```json { "Cause" : "Custom Function Error" } ``` -------------------------------- ### IAM Policy for Starting EMR Serverless Job Run (.sync) Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-emr-serverless.md This policy allows starting an EMR Serverless job run, getting its status, and canceling it. It also permits necessary actions for AWS Step Functions to integrate with EMR Serverless, such as putting targets and rules on EventBridge. ```json { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "emr-serverless:StartJobRun" ], "Resource": [ "arn:aws:emr-serverless:{{us-east-1}}:{{123456789012}}:/applications/{{applicationId}}" ] }, { "Effect": "Allow", "Action": "iam:PassRole", "Resource": [ "arn:aws:iam::123456789012:role/{{jobExecutionRoleArn}}" ], "Condition": { "StringEquals": { "iam:PassedToService": "emr-serverless.amazonaws.com" } } }, { "Effect": "Allow", "Action": [ "emr-serverless:GetJobRun", "emr-serverless:CancelJobRun" ], "Resource": [ "arn:aws:emr-serverless:{{us-east-1}}:{{123456789012}}:/applications/{{applicationId}}/jobruns/*" ] }, { "Effect": "Allow", "Action": [ "events:PutTargets", "events:PutRule", "events:DescribeRule" ], "Resource": [ "arn:aws:events:{{us-east-1}}:{{123456789012}}:rule/{{StepFunctionsGetEventsForEMRServerlessJobRule}}" ] } ] } ``` -------------------------------- ### Hello World example state machine Source: https://docs.aws.amazon.com/step-functions/latest/dg/statemachine-structure.md A basic 'Hello World' state machine using a Pass state. This example demonstrates the fundamental structure including Comment, StartAt, and States. ```json { "Comment": "A Hello World example of the Amazon States Language using a Pass state", "StartAt": "HelloWorld", "States": { "HelloWorld": { "Type": "Pass", "Result": "Hello World!", "End": true } } } ``` -------------------------------- ### IAM Policy for Starting EMR Serverless Job Run with Dynamic Resources (.sync) Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-emr-serverless.md This policy allows starting, getting, and canceling EMR Serverless job runs across any application within an account. It also includes permissions for AWS Step Functions to interact with EventBridge for job execution. ```json { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "emr-serverless:StartJobRun", "emr-serverless:GetJobRun", "emr-serverless:CancelJobRun" ], "Resource": [ "arn:aws:emr-serverless:{{us-east-1}}:{{123456789012}}:/applications/*" ] }, { "Effect": "Allow", "Action": "iam:PassRole", "Resource": [ "arn:aws:iam::123456789012:role/{{jobExecutionRoleArn}}" ], "Condition": { "StringEquals": { "iam:PassedToService": "emr-serverless.amazonaws.com" } } }, { "Effect": "Allow", "Action": [ "events:PutTargets", "events:PutRule", "events:DescribeRule" ], "Resource": [ "arn:aws:events:{{us-east-1}}:{{123456789012}}:rule/{{StepFunctionsGetEventsForEMRServerlessJobRule}}" ] } ] } ``` -------------------------------- ### State Machine with InputPath, ResultPath, and OutputPath Source: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-example.md This example demonstrates how to configure InputPath to filter task input, ResultPath to insert task results, and OutputPath to filter the final state output. ```json { "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda function", "StartAt": "HelloWorld", "States": { "HelloWorld": { "Type": "Task", "Resource": "{{arn:aws:lambda:{{region}}:123456789012:function:HelloFunction}}", "InputPath": {"$.lambda",} "ResultPath": {"$.data.lambdaresult",} "OutputPath": {"$.data",} "End": true } } } ``` -------------------------------- ### Example Mock Configuration File Source: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-test-sm-exec.md This JSON file defines state machines with test cases and their corresponding mocked responses for service integrations. Use this to configure Step Functions Local for testing. ```json { "StateMachines":{ "LambdaSQSIntegration":{ "TestCases":{ "HappyPath":{ "LambdaState":"MockedLambdaSuccess", "SQSState":"MockedSQSSuccess" }, "RetryPath":{ "LambdaState":"MockedLambdaRetry", "SQSState":"MockedSQSSuccess" }, "HybridPath":{ "LambdaState":"MockedLambdaSuccess" } } } }, "MockedResponses":{ "MockedLambdaSuccess":{ "0":{ "Return":{ "StatusCode":200, "Payload":{ "StatusCode":200, "body":"Hello from Lambda!" } } } }, "LambdaMockedResourceNotReady":{ "0":{ "Throw":{ "Error":"Lambda.ResourceNotReadyException", "Cause":"Lambda resource is not ready." } } }, "MockedSQSSuccess":{ "0":{ "Return":{ "MD5OfMessageBody":"3bcb6e8e-7h85-4375-b0bc-1a59812c6e51", "MessageId":"3bcb6e8e-8b51-4375-b0bc-1a59812c6e51" } } }, "MockedLambdaRetry":{ "0":{ "Throw":{ "Error":"Lambda.ResourceNotReadyException", "Cause":"Lambda resource is not ready." } }, "1-2":{ "Throw":{ "Error":"Lambda.TimeoutException", "Cause":"Lambda timed out." } }, "3":{ "Return":{ "StatusCode":200, "Payload":{ "StatusCode":200, "body":"Hello from Lambda!" } } } } } } ``` -------------------------------- ### Initialize Terraform Project Source: https://docs.aws.amazon.com/step-functions/latest/dg/terraform-sfn.md Bootstrap a new Terraform project. This command initializes the working directory and downloads necessary providers. ```bash terraform init ``` -------------------------------- ### Example Input for State Machine Execution Source: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-creating-lambda-state-machine.md This JSON object represents the input data that can be provided when starting a state machine execution. The 'who' key is used by the Lambda function to retrieve the name for greeting. ```json { "who" : "AWS Step Functions" } ``` -------------------------------- ### ListExecutions API Response Example Source: https://docs.aws.amazon.com/step-functions/latest/dg/execution-alias-version-associate.md This JSON response from the ListExecutions API action shows the 'stateMachineAliasArn' used to start a state machine execution named 'myFirstExecution'. The italicized text represents resource-specific information. ```json { "executions": [ { "executionArn": "arn:aws:states:{{{{region}}}}:{{account-id}}:execution:myStateMachine:{{myFirstExecution}}", "stateMachineArn": "arn:aws:states:{{{{region}}}}:{{account-id}}:stateMachine:{{myStateMachine}}", "stateMachineAliasArn": "arn:aws:states:{{{{region}}}}:{{account-id}}:stateMachine:myStateMachine:{{PROD}}", "name": "{{myFirstExecution}}", "status": "SUCCEEDED", "startDate": "2023-04-20T23:07:09.477000+00:00", "stopDate": "2023-04-20T23:07:09.732000+00:00" } ] } ``` -------------------------------- ### IAM Policy for Running Athena Jobs Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-athena.md This policy grants necessary permissions for Step Functions to start, stop, and get query executions in Athena, along with S3 and Glue access for data management. ```json { "Version":"2012-10-17", "Statement":[ { "Effect": "Allow", "Action": [ "athena:startQueryExecution", "athena:stopQueryExecution", "athena:getQueryExecution", "athena:getDataCatalog", "athena:GetWorkGroup", "athena:BatchGetQueryExecution", "athena:GetQueryResults", "athena:ListQueryExecutions" ], "Resource": [ "arn:aws:athena:{{us-east-1}}:{{123456789012}}:workgroup/myWorkGroup", "arn:aws:athena:{{us-east-1}}:{{123456789012}}:datacatalog/*" ] }, { "Effect": "Allow", "Action": [ "s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:AbortMultipartUpload", "s3:CreateBucket", "s3:PutObject" ], "Resource": [ "arn:aws:s3:::*" ] }, { "Effect": "Allow", "Action": [ "glue:CreateDatabase", "glue:GetDatabase", "glue:GetDatabases", "glue:UpdateDatabase", "glue:DeleteDatabase", "glue:CreateTable", "glue:UpdateTable", "glue:GetTable", "glue:GetTables", "glue:DeleteTable", "glue:BatchDeleteTable", "glue:BatchCreatePartition", "glue:CreatePartition", "glue:UpdatePartition", "glue:GetPartition", "glue:GetPartitions", "glue:BatchGetPartition", "glue:DeletePartition", "glue:BatchDeletePartition" ], "Resource": [ "arn:aws:glue:{{us-east-1}}:{{123456789012}}:catalog", "arn:aws:glue:{{us-east-1}}:{{123456789012}}:database/*", "arn:aws:glue:{{us-east-1}}:{{123456789012}}:table/*", "arn:aws:glue:{{us-east-1}}:{{123456789012}}:userDefinedFunction/*" ] }, { "Effect": "Allow", "Action": [ "lakeformation:GetDataAccess" ], "Resource": [ "*" ] } ] } ``` -------------------------------- ### Initialize Java AWS CDK Project Source: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-step-functions-rest-api-integration-cdk.md Create a directory and initialize a new AWS CDK project with Java as the language. ```bash mkdir stepfunctions-rest-api cd stepfunctions-rest-api cdk init --language java ``` -------------------------------- ### Initialize Python AWS CDK Project Source: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-step-functions-rest-api-integration-cdk.md Create a directory and initialize a new AWS CDK project with Python as the language. ```bash mkdir stepfunctions-rest-api cd stepfunctions-rest-api cdk init --language python ``` -------------------------------- ### IAM Policy for Glue Run a Job (.sync) Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-glue.md This IAM policy grants permissions for Step Functions to start, get, and batch stop AWS Glue job runs when using the .sync integration pattern. ```json { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "glue:StartJobRun", "glue:GetJobRun", "glue:GetJobRuns", "glue:BatchStopJobRun" ], "Resource": "*" } ] } ``` -------------------------------- ### JSON Payload for Step Functions Execution Source: https://docs.aws.amazon.com/step-functions/latest/dg/using-eventbridge-scheduler.md This is an example of a JSON payload required for starting an AWS Step Functions execution via EventBridge Scheduler. Even if your state machine does not require input, a JSON format must still be provided. ```json { "Comment": "sampleJSONData" } ``` -------------------------------- ### IAM Policy for Running Athena Jobs Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-athena.md This policy grants permissions required to start, stop, and get query executions, as well as manage data catalogs and workgroups in Athena. It also includes permissions for S3, Glue, and Lake Formation. ```json { "Version":"2012-10-17", "Statement":[ { "Effect": "Allow", "Action": [ "athena:startQueryExecution", "athena:stopQueryExecution", "athena:getQueryExecution", "athena:getDataCatalog", "athena:GetWorkGroup", "athena:BatchGetQueryExecution", "athena:GetQueryResults", "athena:ListQueryExecutions" ], "Resource": [ "arn:aws:athena:{{us-east-1}}:{{123456789012}}:workgroup/*", "arn:aws:athena:{{us-east-1}}:{{123456789012}}:datacatalog/*" ] }, { "Effect": "Allow", "Action": [ "s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:AbortMultipartUpload", "s3:CreateBucket", "s3:PutObject" ], "Resource": [ "arn:aws:s3:::*" ] }, { "Effect": "Allow", "Action": [ "glue:CreateDatabase", "glue:GetDatabase", "glue:GetDatabases", "glue:UpdateDatabase", "glue:DeleteDatabase", "glue:CreateTable", "glue:UpdateTable", "glue:GetTable", "glue:GetTables", "glue:DeleteTable", "glue:BatchDeleteTable", "glue:BatchCreatePartition", "glue:CreatePartition", "glue:UpdatePartition", "glue:GetPartition", "glue:GetPartitions", "glue:BatchGetPartition", "glue:DeletePartition", "glue:BatchDeletePartition" ], "Resource": [ "arn:aws:glue:{{us-east-1}}:{{123456789012}}:catalog", "arn:aws:glue:{{us-east-1}}:{{123456789012}}:database/*", "arn:aws:glue:{{us-east-1}}:{{123456789012}}:table/*", "arn:aws:glue:{{us-east-1}}:{{123456789012}}:userDefinedFunction/*" ] }, { "Effect": "Allow", "Action": [ "lakeformation:GetDataAccess" ], "Resource": [ "*" ] } ] } ``` -------------------------------- ### Start State Machine Execution with Mocked Services Source: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-test-sm-exec.md Initiate a state machine execution using a specific test case defined in your mock configuration file. This command targets a state machine created with mocked integrations. ```bash aws stepfunctions start-execution \ --endpoint http://localhost:8083 \ --name executionWithHappyPathMockedServices \ --state-machine arn:aws:states:{{region}}:{{account-id}}:stateMachine:LambdaSQSIntegration#HappyPath ``` -------------------------------- ### Allow StartBuildBatch, StopBuildBatch, BatchGetBuildBatches on Dynamic Project Resources Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-codebuild.md This policy allows managing build batches (start, stop, get) for any CodeBuild project within the account using dynamic resource ARNs. It also includes necessary permissions for CloudWatch Events. ```json { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "codebuild:StartBuildBatch", "codebuild:StopBuildBatch", "codebuild:BatchGetBuildBatches" ], "Resource": [ "arn:aws:codebuild:{{us-east-1}}:{{123456789012}}:project/*" ] }, { "Effect": "Allow", "Action": [ "events:PutTargets", "events:PutRule", "events:DescribeRule" ], "Resource": [ "arn:aws:events:{{us-east-1}}:{{123456789012}}:rule/StepFunctionsGetEventForCodeBuildStartBuildBatchRule" ] } ] } ``` -------------------------------- ### IAM Policy for Starting a Build (Static Resources) Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-codebuild.md This policy specifically allows the 'StartBuild' action for a designated CodeBuild project. ```json { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "codebuild:StartBuild" ], "Resource": [ "arn:aws:codebuild:{{us-east-1}}:{{123456789012}}:project/{{myProjectName}}" ] } ] } ``` -------------------------------- ### Start Execution Response Source: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-lambda.md The response after starting a state machine execution locally. It includes the start date and the unique execution ARN. ```json { "startDate": 1548810641.52, "executionArn": "arn:aws:states:{{region}}:{{account-id}}:execution:HelloWorld:test" } ``` -------------------------------- ### Example Input Data for Parameters Source: https://docs.aws.amazon.com/step-functions/latest/dg/workflow-studio-process.md This is the sample JSON data used to demonstrate the Parameters filter for a Parallel state. ```json { "comment": "Example for Parameters", "product": { "details": { "color": "blue", "size": "small", "material": "cotton" }, "availability": "in stock", "sku": "2317", "cost": "$23" } } ``` -------------------------------- ### Step Functions Execution Started Event Source: https://docs.aws.amazon.com/step-functions/latest/dg/eventbridge-integration.md This event indicates that a Step Functions execution has started. It includes details about the execution ARN, state machine ARN, and start time. ```json { "version": "0", "id": "315c1398-40ff-a850-213b-158f73e60175", "detail-type": "Step Functions Execution Status Change", "source": "aws.states", "account": "{{account-id}}", "time": "2019-02-26T19:42:21Z", "region": "us-east-2", "resources": [ "arn:aws:states:us-east-2:{{account-id}}:execution:state-machine-name:execution-name" ], "detail": { "executionArn": "arn:aws:states:us-east-2:{{account-id}}:execution:state-machine-name:execution-name", "stateMachineArn": "arn:aws::states:us-east-2:{{account-id}}:stateMachine:state-machine", "name": "execution-name", "status": "RUNNING", "startDate": 1551225271984, "stopDate": null, "input": "{}", "inputDetails": { "included": true }, "output": null, "outputDetails": null, "stateMachineVersionArn": null, "stateMachineAliasArn": null, "redriveCount": 0, "redriveDate": null, "redriveStatus": "NOT_REDRIVABLE", "redriveStatusReason": "Execution is RUNNING and cannot be redriven", "error": null, "cause": null } } ``` -------------------------------- ### Create State Machine with Mock Configuration Source: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-test-sm-exec.md Use this command to create a Step Functions state machine that is configured to use mocked service integrations. Ensure the mock configuration file is already created. ```bash aws stepfunctions create-state-machine \ --endpoint http://localhost:8083 \ --definition "{\"Comment\":\"Thisstatemachineiscalled:LambdaSQSIntegration\",\"StartAt\":\"LambdaState\",\"States\":{\"LambdaState\":{\"Type\":\"Task\",\"Resource\":\"arn:aws:states:::lambda:invoke\",\"Parameters\":{\"Payload.$\":\"$\",\"FunctionName\":\"arn:aws:lambda:{{region}}:{{account-id}}:function:HelloWorldFunction\"},\"Retry\":[{\"ErrorEquals\":[\"States.ALL\"],\"IntervalSeconds\":2,\"MaxAttempts\":3,\"BackoffRate\":2}],\"Next\":\"SQSState\"},\"SQSState\":{\"Type\":\"Task\",\"Resource\":\"arn:aws:states:::sqs:sendMessage\",\"Parameters\":{\"QueueUrl\":\"https://sqs.us-east-1.amazonaws.com/{{account-id}}/myQueue\",\"MessageBody.$\":\"$\"},\"End\":true}}" \ --name "LambdaSQSIntegration" --role-arn "arn:aws:iam::{{account-id}}:role/service-role/LambdaSQSIntegration" ``` -------------------------------- ### Example Input for State Machine Source: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-example.md This is an example of the input JSON that can be processed by the state machine. ```json { "comment": "An input comment.", "data": { "val1": 23, "val2": 17 }, "extra": "foo", "lambda": { "who": "AWS Step Functions" } } ``` -------------------------------- ### Initialize JavaScript AWS CDK Project Source: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-step-functions-rest-api-integration-cdk.md Create a directory and initialize a new AWS CDK project with JavaScript as the language. ```bash mkdir stepfunctions-rest-api cd stepfunctions-rest-api cdk init --language javascript ``` -------------------------------- ### JSONata TimeoutSeconds Example Source: https://docs.aws.amazon.com/step-functions/latest/dg/transforming-data.md Example demonstrating the use of JSONata for specifying a timeout value, automatically interpreted by ASL. ```json "TimeoutSeconds": "{% $timeout %}" ``` -------------------------------- ### Initialize TypeScript AWS CDK Project Source: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-step-functions-rest-api-integration-cdk.md Create a directory and initialize a new AWS CDK project with TypeScript as the language. ```bash mkdir stepfunctions-rest-api cd stepfunctions-rest-api cdk init --language typescript ``` -------------------------------- ### JSONPath TimeoutSecondsPath Example Source: https://docs.aws.amazon.com/step-functions/latest/dg/transforming-data.md Legacy example showing how to use JSONPath for selecting a timeout value from state data. ```json "TimeoutSecondsPath": "$timeout" ``` -------------------------------- ### Install AWS CDK CLI Source: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-lambda-state-machine-cdk.md Installs the AWS CDK command-line interface globally. This is a prerequisite for using the AWS CDK. ```bash npm install -g aws-cdk ``` -------------------------------- ### Start a New State Machine Execution Source: https://docs.aws.amazon.com/step-functions/latest/dg/concepts-nested-workflows.md Use this Task state configuration to start a new execution of a specified state machine. It passes a JSON comment as input to the new execution. Consider using retries for `StepFunctions.ExecutionLimitExceeded` to ensure reliable execution starts. ```json { "Type":"Task", "Resource":"arn:aws:states:::states:startExecution", "Parameters":{ "StateMachineArn":"arn:aws:states:{{region}}:{{account-id}}:stateMachine:HelloWorld", "Input":{ "Comment":"Hello world!" }, }, "Retry":[ { "ErrorEquals":[ "StepFunctions.ExecutionLimitExceeded" ] } ], "End":true } ``` -------------------------------- ### IAM Policy for Starting a Build (Dynamic Resources) Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-codebuild.md This policy allows the 'StartBuild' action for any CodeBuild project within the specified region. ```json { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "codebuild:StartBuild" ], "Resource": [ "arn:aws:codebuild:{{us-east-1}}:*:project/*" ] } ] } ``` -------------------------------- ### Start EMR Serverless Application Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-emr-serverless.md Use this snippet to start an existing EMR Serverless application. Ensure you provide the correct ApplicationId. ```json "Start_Application": { "Type": "Task", "Resource": "arn:aws:states:::emr-serverless:startApplication.sync", "Arguments": { "ApplicationId": "{{yourApplicationId}}" }, "End": true } ```