meltwater/terraform-aws-asg-dns-handler

IndexError: list index out of range

Chilinot opened this issue · 4 comments

The lambda function is unable to create new Route53 records for launching instances and kills them over and over. I had to remove the lifecycle hooks to get it to stop killing my servers.

This is the error in the log that is printed when it fails to create a Route53 record for a launching instance:

list index out of range: IndexError
Traceback (most recent call last):
  File "/var/task/autoscale.py", line 138, in lambda_handler
    process_record(record)
  File "/var/task/autoscale.py", line 130, in process_record
    process_message(json.loads(record['Sns']['Message']))
  File "/var/task/autoscale.py", line 120, in process_message
    private_ip = fetch_private_ip_from_ec2(instance_id)
  File "/var/task/autoscale.py", line 23, in fetch_private_ip_from_ec2
    ip_address = ec2_response['Reservations'][0]['Instances'][0]['NetworkInterfaces'][0]['PrivateIpAddress']
IndexError: list index out of range

Hello @Chilinot, sorry for the delayed response on this.

We will see if we can reproduce this. If you can provide any more details about your configuration, that might be helpful. Thanks

@Chilinot were you trying to use this module for an autoscaling group that brought up instances with public IPs? I think that would explain the error you saw. Public IP support was added in #26 which is available in version 2.1.0.

If this is true, please give it a try and report back.

Hi, unfortunately we are no longer using this module. I remember i solved the issue somehow, however, chose to go with a different solution in the end. I'm closing this ticket.

Remembering now, i believe i had done some testing before deployments, and there were already some residual Route53 records from my testing. This made things go out of phase and broke the lambda script. I believe removing all clashing records and then setting this up again from the beginning solve the issue.

Hopefully it might help someone else that stumbles upon the issue.