Calling the invoke API action failed with this message: Network Failure timeout. Using Lambda

0

I am trying to invoke a lambda to store data in a Dynamodb table. In my own AWS account, it works, but not in the company AWS account I'm working at. Cloudwatch does not show any errors. The timeout occurs at "await dynamodb.describeTable(describeParams).promise();".

Calling the invoke API action failed with this message: Network Failure timeout

My code is as follows:

const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient();
const dynamodb = new AWS.DynamoDB();

exports.handler = async (event) => {
  const valueTostore = event.body || 'default_value';

  const params = {
    TableName: 'my-values',
    Item: {
      id: new Date().toISOString(),
      SessionConfig: valueTostore
    }
  };

  try {
    const describeParams = { TableName: 'my-values' };
    await dynamodb.describeTable(describeParams).promise();
  } catch (error) {
    const response = {
      statusCode: 500,
      body: JSON.stringify({ message: 'Error while accessing table' })
    };
    return response;
  }

  try {
    await docClient.put(params).promise();
  } catch (error) {
    const response = {
      statusCode: 500,
      body: JSON.stringify({ message: 'Error while storing value' })
    };
    return response;
  }

  const response = {
    statusCode: 200,
    body: JSON.stringify({ message: 'Value stored successfully' })
  };
  return response;
};
combii
질문됨 일 년 전1182회 조회
3개 답변
0
수락된 답변

Security group for my lambda wasn't configured for outbound rules, so I opened all ports for outbound and it worked! It was a bad error and too broad if AWS sees it, please narrow it down.

combii
답변함 일 년 전
0

I would check that the Lambda has IAM permission to read and write to the DynamoDB table.

AWS
답변함 일 년 전
0

This error message is very generic in lambda. I am assuming you are attempting cross account access since you mentioned using 2 accounts. Not sure which account is your dynamoDb created, but you can start looking into if you have proper IAM permission to access dynamoDB for lambda execution role from your company account. Next you can look if your lambda is created inside your private subnet VPC, then its quite likely that it may not have proper route configured to access dynamoDB. It can be accessed via Internet as well AWS private network using gateway/interface vpc endpoints.

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠