Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
Cómo pasar una variable a la instrucción catch en AWS Step Functions

Desarrollo un flujo de trabajo muy simple en AWS Step Functions como la imagen de abajo.

ingrese la descripción de la imagen aquí

La función CreateNewItem crea un nuevo registro en Dynamo DB, luego, si falla, llama a la función Create NewItemFail .

La función CreateNewItemFail envía un correo electrónico que incluye información sobre los datos que la primera función intentó insertar en Dynamo DB.

Sin embargo, no tengo idea de cómo lanzar una variable en la función fallida.

Este es el código de función del controlador de la función CreateNewItem .

 const AWS = require('aws-sdk') AWS.config.update({ region: "ap-northeast-1", }) const dynamoDb = new AWS.DynamoDB(); const table = "ItemTable"; exports.handler = async(event, context, callback) => { const item = { id: 'xxxxxxxxxx', name: 'hello', } try { // // Insert data(item) into Dynamo DB here. // } catch(e) { const createItemError = new Error('Insert data error'); createItemError.name = "CreateItemError"; // here, I would like to know how to pass the `item` variable. throw createItemError; } const response = { statusCode: 200, body: JSON.stringify('Hello from Lambda!'), }; return response; };

La entrada de la función CreateNewItemFail es esta.

 { "Error": "CreateItemError", "Cause": "{\"errorType\":\"CreateItemError\",\"errorMessage\":\"Insert data error\",\"trace\":[\"CreateItemError: Insert data error\",\" at Runtime.exports.handler (/var/task/index.js:147:28)\",\" at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)\"]}" }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!