Invoking the first Lambda Function via AWS Console or AWS CLI to create a transaction. Once the first Lambda function receives the incoming request, it will validate the request and start the Step Function State Machine. The AWS Step Function State Machine will trigger the second Lambda Function that will send an e-mail using the configured e-mail identity on AWS SES. The e-mail identity must be verified beforehand, and remember that the e-mail address is case-sensitive. The Lambda Function must have permission or is authorized to perform ses:SendEmail
on the SES resource identity.
- Go to Lambda → Lambda Function → Test tab
- Update the Event JSON textarea field (see sample payload)
- Click on the Test button in the upper right corner
- Use the following command and replace the placeholder
lambda_function_name
with the actual Lambda function nameaws lambda invoke \ --function-name lambda_function_name \ --payload '{"transaction_type": "PURCHASE", "customer": {"first_name": "John", "last_name": "Doe", "email": "j.doe@email.com"}}' \ --cli-binary-format raw-in-base64-out \ response.json
{
"transaction_type": "PURCHASE",
"customer": {
"first_name": "John",
"last_name": "Doe",
"email": "j.doe@email.com"
}
}
{
"StartAt": "step-function-task",
"States": {
"step-function-task": {
"End": true,
"Type": "Task",
"InputPath": "$",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": "arn:aws:lambda:us-east-1:123456789101:function:sendEmail",
"Payload.$": "$"
}
}
}
}
- States
- Amazon States Language
- AWS Step Function Guides
- Send an Email with Amazon SES
- Verified identities in Amazon SES
- Moving out of the Amazon SES sandbox
- Input and Output Processing in Step Functions
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
-
Install all the dependencies, bootstrap your project, and synthesized CloudFormation template.
# Without passing "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-ses$ make init # With "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-ses$ make init profile=[profile_name]
-
Deploy the project.
# Without passing "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-ses$ make deploy # With "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-ses$ make deploy profile=[profile_name]