integration/resources/templates/combination/connector_function_to_sfn_read.yaml (56 lines of code) (raw):

Resources: StateMachineFunction: Type: AWS::Serverless::Function Properties: InlineCode: | exports.handler = async (event) => { console.log("Hello world!") }; Handler: index.handler Runtime: nodejs18.x StateMachine: Type: AWS::Serverless::StateMachine Properties: Type: STANDARD Definition: StartAt: MyLambdaState States: MyLambdaState: Type: Task Resource: !GetAtt StateMachineFunction.Arn End: true Policies: - LambdaInvokePolicy: FunctionName: !Ref StateMachineFunction TriggerFunction: Type: AWS::Serverless::Function Properties: Runtime: nodejs18.x Handler: index.handler InlineCode: | const { SFN: StepFunctions } = require("@aws-sdk/client-sfn"); exports.handler = async (event) => { console.log(JSON.stringify(event)); var params = { stateMachineArn: process.env.SFN_ARN, maxResults: 25, }; const stepfunctions = new StepFunctions(); await stepfunctions.listExecutions(params); }; Environment: Variables: SFN_ARN: !Ref StateMachine MyConnector: Type: AWS::Serverless::Connector Properties: Source: Id: TriggerFunction Destination: Id: StateMachine Permissions: - Read Metadata: SamTransformTest: true