title: 3rd party api call with aws lambda
body: <p>I am trying to call <code>keepa api</code> within my <code>aws lambda</code> but the api is not getting called. The response is not getting printed.
  But when I am running it on my <code>local machine</code>, its running fine and returning response.</p>
  <p><em>code from local machine :</em></p>
  <pre><code>public class Main 
  {
      public static void main(String[] args) {
  
          KeepaAPI api = new KeepaAPI(&quot;my-api-key&quot;);
          Request r = Request.getProductRequest(AmazonLocale.US, 90, null, &quot;B001GZ6QEC&quot;);
          
          api.sendRequest(r)
                  .done(result -&gt; {
          
                                      System.out.println(result);
                                  })
                  .fail(failure -&gt; System.out.println(failure));
                                  }
  }
  </code></pre>
  <p><em>AWS lambda code</em></p>
  <pre><code>public class App implements RequestHandler&lt;String, Object&gt;
  {
      
      @Override
      public Object handleRequest(String input, Context context) {
          System.out.println(&quot;welcome to lambda&quot;);
          
          KeepaAPI api = new KeepaAPI(&quot;my-api-key&quot;);
          Request r = Request.getProductRequest(AmazonLocale.US, 90, null, &quot;B07W6SP4W1&quot;);
          
          System.out.println(&quot;before send request &quot;);
  
          api.sendRequest(r)
                  .done(result -&gt; {       
                                      System.out.println(result);
                                  })
                  .fail(failure -&gt; System.out.println(failure));
                  
          System.out.println(&quot;after send request&quot;);
  
          return null;
          }
  }
  </code></pre>
  <p><em>Output : On the lambda console, I can only see welcome to lambda</em></p>
  <p>I am not sure whether we can call 3rd party apis from lambda. I researched a lot on this. Some said that may be my lambda is not getting internet connectivity but I tried to call instagram apis and it ran perfectly. Also my lambda is not in a VPC. I am not sure how to check that but in the image it shows &quot;The function isn't connected to VPC&quot;</p>
  <p><a href="https://i.stack.imgur.com/axy2K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/axy2K.png" alt="lambda" /></a></p>
  <p>Do I need an api gateway to call these apis? I am using official keepa java framework. I have assigned basic lambda role to this lambda. Do I need to assign some extra permissions to lambda role to call 3rd party api?</p>
  <p><em>lambda logs</em>
  <a href="https://i.stack.imgur.com/SNxwl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SNxwl.png" alt="enter image description here" /></a></p>