PaloAltoNetworks / terraform-aws-vmseries-modules

Terraform Reusable Modules for VM-Series on AWS
https://registry.terraform.io/modules/PaloAltoNetworks/vmseries-modules/aws
MIT License
40 stars 49 forks source link

[Bug Report] ASG Lambda function error: [ERROR] IndexError: list index out of range #407

Closed jschelfh-be closed 1 year ago

jschelfh-be commented 1 year ago

Describe the bug

When triggering the ASG lambda function on EC2 creation or removal, it actually does the required actions but fails with an error and this causes the lambda to get re-triggered 3 times.

ASG scale-out

[DEBUG] 2023-11-14T09:10:14.795Z 30516ab0-6395-403c-b25e-476e437960c3 Successfully created association: eipassoc-00dc23be3d442ed6b 
[ERROR] IndexError: list index out of range Traceback (most recent call last):   File "/var/task/lambda.py", line 582, in lambda_handler     VMSeriesInterfaceScaling(asg_event)   File "/var/task/lambda.py"
--
[ERROR] IndexError: list index out of range
Traceback (most recent call last):
  File "/var/task/lambda.py", line 582, in lambda_handler
    VMSeriesInterfaceScaling(asg_event)
  File "/var/task/lambda.py", line 36, in __init__
    self.main(asg_event)
  File "/var/task/lambda.py", line 63, in main
    untrust_ip = self.ip_network_interface(instance_id, '2')
  File "/var/task/lambda.py", line 371, in ip_network_interface
    return description['NetworkInterfaces'][0]['PrivateIpAddress']

ASG scale-in

[INFO] 2023-11-14T12:38:14.098Z 4508987c-23da-4d2b-aa74-bd4362d7bb37 Successfully release x.x.x.x
[ERROR] IndexError: list index out of range Traceback (most recent call last):   File "/var/task/lambda.py", line 582, in lambda_handler     VMSeriesInterfaceScaling(asg_event)   File "/var/task/lambda.py
--
[ERROR] IndexError: list index out of range
Traceback (most recent call last):
  File "/var/task/lambda.py", line 582, in lambda_handler
    VMSeriesInterfaceScaling(asg_event)
  File "/var/task/lambda.py", line 36, in __init__
    self.main(asg_event)
  File "/var/task/lambda.py", line 77, in main
    untrust_ip = self.ip_network_interface(instance_id, '2')
  File "/var/task/lambda.py", line 371, in ip_network_interface
    return description['NetworkInterfaces'][0]['PrivateIpAddress']

we encountered this in 2 different environments.

Module Version

1.0.9

Terraform version

1.6.2

Expected behavior

To not throw an error

Current behavior

throws an error

Anything else to add?

No response

sebastianczech commented 1 year ago

Fix is merged in PR #409