title: Filtering instanceId by sourceIP
body: <p>I'm building a Python Lambda where, every time a EC2 instance calls it, it should include this instance in an ELB target group. So my &quot;logic&quot; is, I have the IP from this instance because of the headers. If this IP, I can identify the InstanceID. With the InstanceID, I can add it to the target group.</p>
  <pre><code>import json
  import boto3
  
  client = boto3.client('elbv2')
  ec2 = boto3.client('ec2')
  
  def lambda_handler(event, context):
          
      internal_IP = {
          'body': event['requestContext']['identity']['sourceIp']
      }
  
      filters = [{
          'Name': 'private_ip_address', 
          'Values': [internal_IP],
      }]
      result_list = ec2.describe_instances(Filters=filters)
      instid=result_list['Reservations'][0]['Instances'][0]['InstanceId']
  
  
      response = client.register_targets(
          TargetGroupArn='arn:aws:elasticloadbalancing:us-west-1:XXXXXXXXXXX',
          Targets=[
              {
                  'Id': instid
              },
          ]
      )
  </code></pre>
  <p>The problem is that I'm not able to use the &quot;internal_IP&quot; as a value in the filters. I get the error: &quot;'int' object is not subscriptable&quot;. I made a lot of changes in the code to fix it, but no success...</p>
  <p>The IP is returned when I run the code:</p>
  <pre><code>def lambda_handler(event, context):
     
      response = {
          'body': event['requestContext']['identity']['sourceIp']
      }
      return response
  </code></pre>
  <p>How can I solve this?</p>