Skip to content

Instantly share code, notes, and snippets.

@mjzone
Created April 17, 2024 09:15
Show Gist options
  • Save mjzone/956055b006aec6acc59eef98a8eb2c5d to your computer and use it in GitHub Desktop.
Save mjzone/956055b006aec6acc59eef98a8eb2c5d to your computer and use it in GitHub Desktop.
import { SFNClient, StartSyncExecutionCommand } from "@aws-sdk/client-sfn";
const region = process.env.AWS_REGION;
const stateMachineArn = process.env.STATE_MACHINE_ARN;
const client = new SFNClient({ region });
export const handler = async (event) => {
const params = {
stateMachineArn,
input: JSON.stringify({ key: 'hello' }),
};
const command = new StartSyncExecutionCommand(params);
try {
const data = await client.send(command);
console.log("Success", data);
return {
statusCode: 200,
body: JSON.stringify({ message: 'Success!', data }),
};
} catch (err) {
console.error("Error", err);
return {
statusCode: 500,
body: JSON.stringify({ message: 'Error', error: err.message }),
};
}
};
@vishalims095
Copy link

great sir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment