title: Lambda function timeout on external call
body: <p>I have a Lambda function from which I need to make an external API call. I have added the Lambda function to a security group, a VPC, and 2 subnets, and it gives me this text:</p>
  
  <blockquote>
    <p>When you enable VPC, your Lambda function will lose default internet
    access. If you require external internet access for your function,
    ensure that your security group allows outbound connections and that
    your VPC has a NAT gateway.</p>
  </blockquote>
  
  <p>I go into VPC, create a NAT gateway (I let AWS create a EIP), attach it to one of the subnets on my lambda function.</p>
  
  <p>For debugging purposes, my security group outbound functions are set to all traffic/all destinations (<code>0.0.0.0/0</code>). Also my Network ACL for this VPC is set to this (with 5 subnets, including the one with the NAT gateway):</p>
  
  <pre><code>100 | ALL Traffic | ALL | ALL | 0.0.0.0/0 | ALLOW
  </code></pre>
  
  <p>A route table with the same 2 subnets is on the VPC, with the <code>0.0.0.0/0</code> route set to target the NAT gateway.</p>
  
  <p>A different route table with 3 other subnets is also on the VPC, with the <code>0.0.0.0/0</code> route set to target the internet gateway.</p>
  
  <p>Both route tables have the same <code>local</code> destination IP (the IP for the VPC).</p>
  
  <p>The error I get is:</p>
  
  <pre><code>{ Error: connect ETIMEDOUT x.x.x.x:443
  at Object.exports._errnoException (util.js:1018:11)
  at exports._exceptionWithHostPort (util.js:1041:20)
  at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: 'x.x.x.x',
  port: 443 }
  </code></pre>
  
  <p>The node code I am running works on my desktop node environment, and the POST call works in postman, so I am fairly certain this is problem with my AWS config.</p>
  
  <p>I have been using this scenario as a resource: <a href="http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Scenario2.html" rel="noreferrer">http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Scenario2.html</a></p>