AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Serverless patterns - Step Functions to S3 Resources: ## S3 bucket DestinationBucket: Type: AWS::S3::Bucket Properties: VersioningConfiguration: Status: Enabled BucketName: 'my-sfn-bucket-destination' MyStateMachine: Type: AWS::Serverless::StateMachine Properties: Role: !GetAtt WorkflowExecutionRole.Arn Definition: StartAt: SendCustomEvent States: SendCustomEvent: Type: Task Resource: 'arn:aws:states:::aws-sdk:s3:putObject' Parameters: Body: 'Hello World' Bucket: !Ref DestinationBucket Key: 'filename.txt' End: True WorkflowExecutionRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: states.amazonaws.com Action: sts:AssumeRole Policies: - PolicyName: S3Write PolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Action: - "s3:PutObject" Resource: !Sub "${DestinationBucket.Arn}/*" Outputs: MyStateMachineArn: Value: !Ref MyStateMachine S3: Value: !GetAtt DestinationBucket.Arn Description: DestinationBucket Arn