Write Route 53 Problem

0

Hello,

There is route 53 error on production even we increase lambda terminate time.

We need help about this situation. We can't update route53 dns consistent and the big problem is this error is randomly.

As you can see on my code i am creating new dns record when it created i update my dynmao table. Route53 update returns 200 but actually my dns was not added on route 53 and the interesting part is my dynamo table is updated. This means route 53 returns 200 but actually it should not. Can any one help me about this situation.

Here is my Lambda function code:


  const ec2 = new AWS.EC2({ apiVersion: "2016-11-15" });
  const route53 = new AWS.Route53({apiVersion: '2013-04-01'});
...
  
        const resourceRecordSetParams = {
          ChangeBatch: {
            Changes: [
              {
                Action: "CREATE",
                ResourceRecordSet: {
                  Name: `${instanceInformation.InstanceId}.xxxxxxx.com`,
                  ResourceRecords: [
                    {
                      Value: waitForInstanceInformation.Reservations[0].Instances[0].PublicIpAddress,
                    },
                  ],
                  TTL: 60,
                  Type: "A",
                },
              },
            ],
            Comment: "created from create-openvidu-instance-lambda function",
          },
          HostedZoneId: "xxxxxxxxxxxxxx",
        };
        const [
          resourceRecordSetStatusCode,
          resourceRecordSetBody,
          resourceRecordSetInformation,
        ] = await changeResourceRecordSetsInHostedZone(
          route53,
          resourceRecordSetParams
        );
        if (resourceRecordSetStatusCode === 200){
      //some code
       }
    // }
    const AWSGroupCreateParams = {
      TableName: "AWSGroups",
      Item: {
        },
        isRunning: true,
        attendeeList: awsGroupAttendeeList
      },
    };
    try{
      await documentClient.put(AWSGroupCreateParams).promise();
      console.log("Successfully created the AWS Group and related instance information");
    }catch(err){
      console.log(err);
      console.log("Error creating AWS Group with parameters: ", AWSGroupCreateParams);
    }
    statusCode = 200;
    body =
      "Successfully created the instance and target group. Registered target group to instance.";
  }

  const response = {
    headers: {
      "Access-Control-Allow-Headers": "Content-Type",
      "Content-Type": "application/json",
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Methods": "GET,PUT,POST,DELETE,PATCH",
    },
    statusCode,
    body,
  };
  return response;
};


const changeResourceRecordSetsInHostedZone = async (route53, params) => {
  // Variables
  let statusCode;
  let body;
  let information;
  
  // Logic
  console.log(
    "Changing resource record sets with params: ",
    params
  );
  const changeResourceRecordSetsPromise = route53.changeResourceRecordSets(params).promise();
  await changeResourceRecordSetsPromise.then((data)=>{
    information = data;
    console.log(information);
    statusCode = 200;
    body = `Successfully created resource record set to IP Address: ${params.ChangeBatch.Changes[0].ResourceRecordSet.Name}`
  }).catch(err=>{
    console.log(err);
    statusCode = 400;
    body = err;
  })
  return [statusCode, body, information];

Thanks.

asked 2 years ago256 views
1 Answer
0

Are you having an issues where your Lambda function is timing out? If so, what is the rest of the code in your Lambda function doing? It's not clear from your example what else is happening there. I would trace the rest of the function and see where the variability in the time taken is happening.

Note that allocating more memory to your function increases the amount of CPU available to it and that will help it execute quicker.

profile pictureAWS
EXPERT
answered 2 years ago
  • Lambda function timeout duration is 15 min. I create several instance with this function but the problem is one of ec2 launching 2 sec and other is takes more than 15 min and so i cant update Route 53. As you can see on code route 53 is last part of code. The problem is last part. The main problem is each ec2 machine does not launch same time with same properties. As i said before some of them launching less than 1 min and sometimes this operation takes more than 15 min.

    The other problem is in this code i am waiting to success message from route 53 update and actually i am taking that info corretly so i can update my db table. In that situation my db table was updated on each scenario but route 53 was not updated. I update my question with lambda code.

  • Hello again, I figure out the problem. I split the fucntion 2part for terminate but the problem is not lambda terminate. The route 53 changeResourceRecordSets function turning back success but not create any new dns record and this happens randomly. How can i fix that? CAN ANY ONE HELP ME PLEASE?

  • Given that some of the events you're waiting for can take longer than the Lambda function timeout, can I suggest that you use Step Functions? That way you're not impacted by the 15 minute runtime limit.

  • Hello again. I search more and look lambda logs too so i updated my question. Could you help about my question. It is still happening i dont know why

  • If this is happening randomly then I strongly recommend that you raise a support case on this issue. The support team can interact with the service team and determine why this is happening.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions