### Step Functions Execution Start Output Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Example output when starting a Step Functions execution. It includes the execution ARN and the start date. ```json { "executionArn": "arn:aws:states:us-east-1:123456789012:execution:LocalTestingStateMachine-asdf1234:2c9e4676-b2f6-4e80-994b-7611c4b4418d", "startDate": "2022-01-13T16:29:47.471000-05:00" } ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/serverless-file-share/README.md Installs all necessary dependencies for the project. Run this from the main project directory. ```bash npm install ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Change directory to the root of the cloned repository to begin local testing setup. ```bash cd app-local-testing-mock-config ``` -------------------------------- ### SAM Deploy Guided Configuration Prompts Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-low-code-you-know-counter/README.md Illustrates the interactive prompts shown during a guided 'sam deploy' command, covering stack name, region, parameters, and confirmation settings. ```bash Configuring SAM deploy ====================== Looking for config file [samconfig.toml] : Not found Setting default arguments for 'sam deploy' ========================================= Stack Name [sam-app]: you-know AWS Region [us-east-1]: Parameter GlueDatabaseYouKnowP [you-know]: Parameter AthenaTableName [manual_glue_table]: Parameter FillerPhrase [you know]: #Shows you resources changes to be deployed and require a 'Y' to initiate deploy Confirm changes before deploy [y/N]: Y #SAM needs permission to be able to create roles to connect to the resources in your template Allow SAM CLI IAM role creation [Y/n]: #Preserves the state of previously provisioned resources when an operation fails Disable rollback [y/N]: Save arguments to configuration file [Y/n]: SAM configuration file [samconfig.toml]: SAM configuration environment [default]: ``` -------------------------------- ### Run UI Project Locally Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/serverless-file-share/README.md Starts the React single-page application for local development and testing. ```bash npm run start ``` -------------------------------- ### Jenkinsfile for Gradual Deployment Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/gradual-deploy/README.md Example Jenkinsfile demonstrating how to include a gradual deployment script execution within a CI/CD pipeline. ```groovy pipeline { agent any stages { stage('Build') { steps { echo 'Building..' } } stage('Test') { steps { echo 'Testing..' } } stage(‘Gradual Deploy') { steps { sh /path/to/gradual-deploy-script.sh } } } } ``` -------------------------------- ### Guided Deployment with AWS SAM CLI Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-low-code-you-know-counter/README.md Initiates a guided deployment process for the serverless application, prompting the user for configuration details. ```bash sam deploy --guided ``` -------------------------------- ### Verify Java Installation Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-business-rules-orchestration/README.md Verify that Java is installed and accessible from your command line. ```bash java --version ``` -------------------------------- ### Build and Deploy Sample Application (Subsequent) Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Builds and deploys the SAM application after the initial guided deployment. This command is used for subsequent updates. ```bash sam build && sam deploy ``` -------------------------------- ### Build and Deploy Sample Application Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-sfn-kms-integration/README.md Use this command to build the application artifacts and deploy the sample using SAM CLI. Follow the guided prompts for configuration. ```bash sam build && sam deploy --guided ``` -------------------------------- ### Run Docker Locally Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Starts the Docker environment for local testing. This is the first step in the local testing process. ```bash make run ``` -------------------------------- ### Verify Docker Installation Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-business-rules-orchestration/README.md Verify that Docker is installed and accessible from your command line. ```bash docker --version ``` -------------------------------- ### Verify Maven Installation Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-business-rules-orchestration/README.md Verify that Maven is installed and accessible from your command line. ```bash mvn --version ``` -------------------------------- ### Verify Python Installation Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-business-rules-orchestration/README.md Verify that Python is installed and accessible from your command line. ```bash python --version ``` -------------------------------- ### All at Once Deployment Strategy Example Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/gradual-deploy/README.md Deploys a new state machine version, immediately routing all traffic to it. Monitors for alarms during a specified interval and rolls back if necessary. Cleans up old versions. ```bash ./sfndeploy.py --state-machine my-state-machine --region us-east-1 --alias=my-alias --file my-dir/sample.asl.json --publish-revision --strategy allatonce --interval=500 --alarms MaxCPU "API Error Breach" --history-max 10 ``` -------------------------------- ### Start Execution with Exception Path Scenario Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Starts a Step Functions execution to test an exception path scenario. This is useful for validating how your state machine catches and handles runtime exceptions when services are mocked. ```bash aws stepfunctions start-execution \ --endpoint http://localhost:8083 \ --name executionWithCatchRuntimeExceptionPathMockedServices \ --state-machine arn:aws:states:us-east-1:123456789012:stateMachine:LocalTesting#ValidationExceptionCatchTest \ --input "$(cat ./events/sfn_valid_input.json)" ``` -------------------------------- ### Setup AWS Profile Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/serverless-file-share/cdk/README.md Optionally set an environment variable to use a specific AWS profile instead of the default. ```bash AWS_PROFILE=myProfile ``` -------------------------------- ### Clone the Project Repository Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/eventbridge-event-tester/README.md Use git to clone the repository containing the AWS Step Functions examples. ```zsh git clone https://github.com/aws-samples/aws-stepfunctions-examples.git ``` -------------------------------- ### Linear Deployment Strategy Example Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/gradual-deploy/README.md Deploys a new state machine version with gradual traffic shifting. Monitors alarms and automatically rolls back if issues are detected. Cleans up old versions. ```bash ./sfndeploy.py --state-machine my-state-machine --region us-east-1 --alias=my-alias --file my-dir/sample.asl.json --publish-revision --strategy linear --increment 20 --interval=600 --alarms MaxCPU "API Error Breach" --history-max 11 ``` -------------------------------- ### Start Happy Path Execution with Mock Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Initiate a state machine execution for the 'HappyPathTest' scenario, providing a valid input file and using mocked services. ```bash aws stepfunctions start-execution \ --endpoint http://localhost:8083 \ --name executionWithHappyPathMockedServices \ --state-machine arn:aws:states:us-east-1:123456789012:stateMachine:LocalTesting#HappyPathTest \ --input file://events/sfn_valid_input.json ``` -------------------------------- ### Run UI Locally Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/serverless-file-share/ui/README.md Starts the React application in development mode. Open http://localhost:3000 to view the UI in your browser. The page automatically reloads on changes. ```bash npm start ``` -------------------------------- ### Build and Deploy Application with SAM CLI Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-dataquality-using-lambda/README.md Use these commands to build the Docker image and deploy the serverless application. The guided deployment prompts for necessary parameters like Stack Name, AWS Region, and ImageUri. ```bash sam build sam deploy --guided ``` -------------------------------- ### Run Step Functions Local Docker Container Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Start the Step Functions Local Docker container, mounting the mock configuration file and setting the environment variable for the mock config. ```bash docker run -p 8083:8083 \ --mount type=bind,readonly,source=$(pwd)/statemachine/test/MockConfigFile.json,destination=/home/StepFunctionsLocal/MockConfigFile.json \ -e SFN_MOCK_CONFIG="/home/StepFunctionsLocal/MockConfigFile.json" \ amazon/aws-stepfunctions-local ``` -------------------------------- ### Build Docker Image for Drools Application Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-business-rules-orchestration/README.md Build the Docker image for the Drools application. Docker must be installed and running. ```bash mvn docker:build ``` -------------------------------- ### Start Step Functions Execution (AWS CLI) Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Initiates a Step Functions execution in your AWS account using the AWS CLI. Replace `` with the actual ARN from deployment output. ```bash aws stepfunctions start-execution \ --state-machine \ --input file://events/sfn_valid_input.json ``` -------------------------------- ### Run All Local Tests Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Executes all required tests, including creating the state machine and running tests. This command should be run after starting Docker. ```bash make all ``` -------------------------------- ### Start Negative Sentiment Execution with Mock Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Initiate a state machine execution for the 'NegativeSentimentTest' scenario, providing a valid input file and using mocked services. ```bash aws stepfunctions start-execution \ --endpoint http://localhost:8083 \ --name executionWithNegativeSentimentMockedServices \ --state-machine arn:aws:states:us-east-1:123456789012:stateMachine:LocalTesting#NegativeSentimentTest \ --input file://events/sfn_valid_input.json ``` -------------------------------- ### Clone the GitHub Repository Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-video-segment-detection-and-edition/README.md Clone the repository containing the Step Functions workflows collection. This is the first step to get the project files. ```bash git clone https://github.com/aws-samples/step-functions-workflows-collection ``` -------------------------------- ### State Machine Input JSON Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-video-segment-detection-and-edition/README.md Provide this JSON as input when starting the Step Functions execution. Replace placeholders with your S3 bucket name. ```json { "Input": { "Bucket": "{S3 BUCKET NAME CREATED VIA SAM}", "Key": "source_video.mp4" }, "Output": { "Bucket": "{S3 BUCKET NAME CREATED VIA SAM}", "Key": "output/" } } ``` -------------------------------- ### Build and Deploy AWS Resources with SAM Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-video-segment-detection-and-edition/README.md Use AWS SAM CLI to build and deploy the workflow's AWS resources. The --guided flag prompts for necessary configuration, and CAPABILITY_NAMED_IAM allows SAM to create IAM roles. ```bash sam build sam deploy --guided --capabilities CAPABILITY_NAMED_IAM ``` -------------------------------- ### Start Step Functions Execution with Retry Test Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Initiate a Step Functions execution locally for a state machine configured to test retry logic. This command requires the Step Functions local endpoint, execution name, state machine ARN, and an input event file. ```bash aws stepfunctions start-execution \ --endpoint http://localhost:8083 \ --name retryTestExecution \ --state-machine arn:aws:states:us-east-1:123456789012:stateMachine:LocalTesting#RetryOnServiceExceptionTest \ --input file://events/sfn_valid_input.json ``` -------------------------------- ### Kubernetes Job for Gradual Deployment Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/gradual-deploy/README.md Example Kubernetes Job manifest to run a Python gradual deployment script within a container. This is useful for Spinnaker's Run Job stage. ```yaml apiVersion: batch/v1 kind: Job metadata: name: gradual-deploy spec: backoffLimit: 0 template: spec: containers: - command: - python - path/to/my/script.py image: 'myrepo/mycontainer:1.2.3' name: my-custom-script restartPolicy: Never ``` -------------------------------- ### Start Execution with Custom Validation Error Scenario Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Initiates a Step Functions execution to test a custom validation error scenario. Use this to verify how your state machine handles specific validation failures when services are mocked. ```bash aws stepfunctions start-execution \ --endpoint http://localhost:8083 \ --name executionWithCatchCustomErrorPathMockedServices \ --state-machine arn:aws:states:us-east-1:123456789012:stateMachine:LocalTesting#CustomValidationFailedCatchTest \ --input file://events/sfn_valid_input.json ``` -------------------------------- ### Get Step Functions Execution History (AWS CLI) Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Retrieves specific events from a Step Functions execution history using the AWS CLI. This example filters for 'TaskStateExited' events for a particular state. ```bash aws stepfunctions get-execution-history \ --execution-arn \ --query 'events[?type==`TaskStateExited` && stateExitedEventDetails.name==`CustomerAddedToFollowup`]' ``` -------------------------------- ### Build UI Project Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/serverless-file-share/cdk/README.md Build the React UI project to prepare it for deployment. ```bash npm run build:ui ``` -------------------------------- ### TrustingAccountRl Role Policy for Starting Step Functions Execution Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/cross-account-access/README.md This policy grants the TrustingAccountRl role permission to start Step Functions Express Workflows synchronously. Replace , , and with your specific values. ```json { "RoleName": "", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Action": "states:StartSyncExecution", "Resource": "arn:aws:states:::stateMachine:", "Effect": "Allow" } ] } } ``` -------------------------------- ### Display CLI Help for sfndeploy.py Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/gradual-deploy/README.md To view all available command-line arguments and their descriptions for the sfndeploy.py script, pass the --help flag. ```bash ./sfndeploy.py --help ``` -------------------------------- ### Build UI Project Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/serverless-file-share/README.md Builds the React single-page application. Run this from the main project directory. ```bash npm run build ``` -------------------------------- ### Get Stack Name Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/eventbridge-event-tester/README.md Retrieve the stack name using the 'cdk list' command and store it in a variable. ```zsh STACK_NAME=$(cdk list) ``` -------------------------------- ### Successful API Response Example Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/eventbridge-event-tester/README.md A successful response from the event testing API, indicating that the event was processed without errors. ```json { "eventId": "89fd3266-5b43-cac4-7145-11c694bc6b28", "payload": "", "errorMessage": "", "errorCode": "", "status": "SUCCESS" } ``` -------------------------------- ### Event Transformer Method Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/eventbridge-event-tester/README.md Defines how the event payload should be transformed before being sent to the target. This example includes the eventId in the transformed output. ```typescript transformer(): RuleTargetInput { return RuleTargetInput.fromObject({ // event id is required eventId: EventField.eventId, ... }); } ``` -------------------------------- ### sfndeploy.py Command-Line Arguments Summary Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/gradual-deploy/README.md This is a detailed breakdown of the arguments accepted by the sfndeploy.py script, including required parameters like state machine name, alias, and region, as well as optional parameters for deployment strategy, alarms, file paths, and version management. ```bash #!/bin/bash # Example usage: # ./sfndeploy.py \ # --state-machine my-state-machine \ # --alias my-alias \ # --region us-east-1 \ # --strategy canary \ # --alarms MyAlarm1 MyAlarm2 \ # --file ./statemachine.asl.json \ # --increment 20 \ # --interval 300 \ # --history-max 5 \ # --force # Help message: # usage: sfndeploy [-h] --state-machine STATE_MACHINE --alias ALIAS --region REGION # [--strategy {allatonce,canary,linear}] [--alarms [ALARMS ...]] # [--file SM_FILE] [--publish-revision | --no-publish-revision] # [--increment INCREMENT] [--interval INTERVAL] # [--alarm-polling ALARM_POLLING] [--history-max HISTORY_MAX] # [--force | --no-force] # # Gradually deploy AWS Step Functions state machines. # # options: # -h, --help show this help message and exit # --state-machine STATE_MACHINE # Name of the state machine (not ARN). # --alias ALIAS Name of alias. # --region REGION Region name. e.g 'us-east-1' # --strategy {allatonce,canary,linear} # The type of deployment to do. By default will deploy AllAtOnce. # --alarms [ALARMS ...] # Optional list of CloudWatch alarm names to monitor during # deployment. # --file SM_FILE Optional path to state machine definition file to deploy. Will # upload this file as the latest revision of the state machine. If # you don't set this, will use the current latest revision. # --publish-revision, --no-publish-revision # Publish the current revision to the next version. # --increment INCREMENT # The increment for weight increase during deploy strategy, from # 0-100%. Just input the number, not the % sign. # --interval INTERVAL The interval in seconds at which to increase weight during the # deploy strategy. # --alarm-polling ALARM_POLLING # Poll alarms at this interval in seconds. Default 60s. # --history-max HISTORY_MAX # Maximum number of versions to keep in history. Will delete # versions older than this. Set to 0 to disable (this is the # default). There is a 1000 version limit in Step Functions. # --force, --no-force Force the deploy to start, even if the alias is not currently # pointing 100% at the old version. This may be required to recover # from a previous deploy that failed and didn't roll back correctly. # This means you might be overwriting an in-progress deploy, or that # something went wrong in a previous deploy. Be careful when # combining with publish_revision - if you just rerun the script you # might force publish a previously uploaded revision without # testing. ``` -------------------------------- ### Workflow Execution Result Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/cross-account-access/README.md Example of the expected JSON output from the SecretCacheConsumerWfw workflow execution. Note that 'null' may require re-execution. ```json { "Secret": { "secretValue": "1234567890ABCDEFGHIJKLMOPQRSTUVWXYZ" } } ``` -------------------------------- ### Deploy CDK Stack Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/jcl2stepfunctionsblog/Stepfunctions/README.md Navigate to the infra directory and deploy all CDK stacks. ```bash cd cdk/jcl2stepfunctionsblog/Stepfunctions/infra cdk deploy --all ``` -------------------------------- ### Enable Execute Permissions for Deployment Script Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/demo-forecast-service-integration/README.md Make the bootstrap deployment script executable before running it. ```bash chmod 700 ./bootstrap_deployment_script.sh ``` -------------------------------- ### Step Functions Task State Exited Event Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Example output from 'get-execution-history' showing a 'TaskStateExited' event, including state name and output. ```json [ { "timestamp": "2022-01-13T16:29:48.521000-05:00", "type": "TaskStateExited", "id": 32, "previousEventId": 31, "stateExitedEventDetails": { "name": "CustomerAddedToFollowup", "output": "{\"Entries\":[{\"EventId\":\"6e9bf7b4-13e2-097d-7555-f38cb7af12se\"}],\"FailedEntryCount\":0}", "outputDetails": { "truncated": false } } } ] ``` -------------------------------- ### Production Build and Deployment Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/serverless-file-share/cdk/README.md Use environment variables from \`.env.prod\` for production builds and deployments. ```bash yarn build:prod yarn deploy:prod ``` -------------------------------- ### Run All Tests with Gradle Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/demo-local-testing-using-java/README.md Execute all tests for Step Functions local testing using the gradlew command. Ensure Docker is running before execution. ```bash ./gradlew test ``` -------------------------------- ### Event Pattern Method Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/eventbridge-event-tester/README.md Defines the EventBridge event pattern to match incoming events. This example filters events based on a specific source. ```typescript pattern(): EventPattern { return { // we are interested in a particular data source source: [this._config.eventSource], ... } } ``` -------------------------------- ### Happy Path TaskStateExited Event Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Example JSON output confirming a successful 'TaskStateExited' event for the 'CustomerAddedToFollowup' task during a happy path scenario. ```json [ { "timestamp": "2022-01-13T09:22:06.422000-05:00", "type": "TaskStateExited", "id": 32, "previousEventId": 31, "stateExitedEventDetails": { "name": "CustomerAddedToFollowup", "output": "{\"statusCode\":200,\"Payload\":{\"statusCode\":200}}", "outputDetails": { "truncated": false } } } ] ``` -------------------------------- ### Build Source and CDK Files Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/eventbridge-event-tester/README.md Execute build scripts to compile source files and prepare the CDK application. ```zsh ./build-src.sh ./build-cdk.sh ``` -------------------------------- ### Authorize Security Group Ingress Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/eventbridge-event-tester/cdk-app/README.md This command authorizes ingress traffic to a security group. Ensure you have the AWS CLI installed and configured with the necessary profile and region. ```zsh aws ec2 authorize-security-group-ingress \ --cidr 203.0.113.0/24 \ --port 80 \ --protocol tcp \ --profile $AWS_PROFILE \ --region $REGION \ --group-id sg-0a9674ee4937757ab ``` -------------------------------- ### Clean Up Sample Application Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-sfn-kms-integration/README.md Run this command to delete the AWS resources created by the sample application. Ensure you provide the correct stack name. ```bash sam delete --stack-name app-sfn-kms-integration ``` -------------------------------- ### Change Directory to Cloned Repo Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/demo-forecast-service-integration/README.md Navigate into the cloned repository directory to prepare for deployment. ```bash cd demo-forecast-service-integration ``` -------------------------------- ### Example Event Pattern in EventBridge Console Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/eventbridge-event-tester/README.md This JSON structure represents an EventBridge event pattern, likely configured in the AWS console, to match events with a specific source and state. ```json { // if the specified is 'octank` "source": ["com.octank.www"], "detail": { "resourceName": [{ "exists": true }], "state": { "reason": [{ "exists": true }], "value": ["ALARM"] }, "previousState": { "value": ["OK"] } } } ``` -------------------------------- ### Python: Canary Deploy with Defaults Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/gradual-deploy/README.md Executes a Canary deployment strategy using default increment (5%) and interval (120s). Uploads a state machine definition, publishes it as a new version, and routes a small percentage of traffic to it. ```bash ./sfndeploy.py --state-machine my-state-machine --region us-east-1 --alias=my-alias --file my-dir/sample.asl.json --publish-revision --strategy canary ``` -------------------------------- ### Deploy Project to AWS Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/serverless-file-share/README.md Deploys the project infrastructure and backend to AWS using the CDK. After deployment, find the WebsiteUrl output to access the application. ```bash npm run deploy ``` -------------------------------- ### Build Source and CDK Files Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/cross-account-access/README.md Execute build scripts for source and CDK files. Ensure these scripts are available in the parent directory. ```zsh ../scripts/build-src.sh ``` ```zsh ../scripts/build-cdk.sh ``` -------------------------------- ### Deploy Application Components with SAM Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-business-rules-orchestration/README.md Build and deploy the remaining application components using AWS SAM. Navigate to the project root directory before running these commands. ```bash cd .. sam build sam deploy --guided ``` -------------------------------- ### Bootstrap Trusting AWS Account Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/cross-account-access/README.md Initialize the CDK environment in the trusting AWS account. This command prepares the account for CDK deployments. ```zsh cdk bootstrap aws://$TRUSTING_ACCOUNT_ID/$REGION \ --profile $TRUSTING_ACCOUNT_PROFILE ``` -------------------------------- ### Get Step Functions Execution History Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Retrieves the execution history of a specific Step Functions execution. This command is used to inspect the flow and outcomes of a test execution, particularly after simulating error scenarios. ```bash aws stepfunctions get-execution-history \ --endpoint http://localhost:8083 \ --execution-arn arn:aws:states:us-east-1:123456789012:execution:LocalTesting:executionWithCatchRuntimeExceptionPathMockedServices ``` -------------------------------- ### Initiate File Download Workflow Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/serverless-file-share/cdk/README.md Initiates the file download workflow using a Step Function. Authorizes the download request and returns a link for the client to download the file. Requires the File ID. ```APIDOC ## GET /download/{fileId} ### Description Initiates the "download" workflow. Authorises the download request and returns a link for the client to download the file. ### Method GET ### Endpoint /download/{fileId} ### Parameters #### Path Parameters - **fileId** (string) - Required - The ID of the file to download. #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - Presigned Download URL. #### Response Example { "example": "{\n \"downloadUrl\": \"https://example-bucket.s3.amazonaws.com/downloads/example.txt?AWSAccessKeyId=...\"\n}" } ``` -------------------------------- ### Run Unit Tests for sfndeploy.py Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/gradual-deploy/README.md Execute the unit tests for the sfndeploy.py script using Python's unittest module. Ensure you are in the correct directory to run this command. ```bash python -m unittest sfndeploy_test.py ``` -------------------------------- ### Get Step Functions Execution History for Retries Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-local-testing-mock-config/README.md Retrieve the execution history of a Step Functions execution to verify retry behavior. This command filters events to show 'TaskFailed' with 'InternalServerException' and 'TaskSucceeded' for the 'comprehend:detectSentiment' resource. ```bash aws stepfunctions get-execution-history \ --endpoint http://localhost:8083 \ --execution-arn arn:aws:states:us-east-1:123456789012:execution:LocalTesting:retryTestExecution \ --query 'events[?(type==`TaskFailed` && taskFailedEventDetails.error==`InternalServerException`) || (type==`TaskSucceeded` && taskSucceededEventDetails.resource==`comprehend:detectSentiment`)]' ``` -------------------------------- ### Execute Deployment Script Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/demo-forecast-service-integration/README.md Run the deployment script, providing a unique stack name for your application. This script builds and deploys the SAM template, creating necessary AWS resources and copying data. ```bash ./bootstrap_deployment_script.sh ``` -------------------------------- ### Deploy the Solution Stack Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/eventbridge-event-tester/README.md Deploy the EventBridge Event Tester solution using AWS CDK, specifying context variables for namespace and workflow timeouts. ```zsh cdk deploy $STACK_NAME \ --context namespace=$NAMESPACE \ --context eventTesterWorkflowTimeout=15 \ --context eventStatusPollerWorkflowTimeout=10 ``` -------------------------------- ### Delete Sample Application Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/demo-forecast-service-integration/README.md Remove the deployed sample application using the SAM CLI. Ensure you replace '' with the actual stack name used during deployment. ```bash sam delete --stack-name ``` -------------------------------- ### Package Lambda Function Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/jcl2stepfunctionsblog/Stepfunctions/README.md Navigate to the Lambda function directory and package it using Maven. ```bash cd software/Lambda mvn clean package ``` -------------------------------- ### Python: Canary Deploy with Custom Increment and Interval Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/gradual-deploy/README.md Performs a Canary deployment, routing 30% of traffic for 300 seconds, monitoring specified alarms. Rolls back if alarms trigger; otherwise, switches 100% traffic. Does not upload a new definition if --file is omitted. ```bash ./sfndeploy.py --state-machine my-state-machine --region us-east-1 --alias=my-alias --publish-revision --strategy canary --increment 30 --interval 300 --alarms MaxCPU "API Error Breach" ``` -------------------------------- ### Navigate to Solution Folder Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/cdk/cross-account-access/README.md Change directory to the specific CDK cross-account access folder within the cloned repository. ```zsh cd aws-stepfunctions-examples/cdk/cross-account-access/cdk/ ``` -------------------------------- ### Deploy CDK Stack Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/usecases/genai-prompt-chaining-hitl/README.md Navigates to the CDK directory and deploys the stack. Ensure you have updated cdk.context.json with the connection ARN and OpenAI model endpoint. ```bash cd stack/cdk cdk deploy --all ``` -------------------------------- ### Deploying with AWS SAM Source: https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/app-low-code-you-know-counter/README.md Command to deploy the application using the Serverless Application Model (SAM). ```bash sam deploy ```