title: How to use chrome-aws-lambda on a AWS lambda function created with Amplify
body: <p>I'm trying to create this lambda function in AWS using Amplify however when I try to launch the chromium the lambda function does not return any value and the function end up timing up:</p>
  <p><code> &quot;errorMessage&quot;: &quot;2020-12-09T02:56:56.210Z 57402f8e-9fb2-4341-837d-bdf2ee6e9262 Task timed out after 25.57 seconds&quot;</code>
  I add the Layer as suggested by @James Shapiro, now I'm getting a URL return for the chromium but it still not launching it:</p>
  <p>This is my function:</p>
  <pre><code>const chromium = require('chrome-aws-lambda');
  
  exports.handler = async (event, context) =&gt; {
  
      const pageToScreenshot = &quot;https://www.google.com&quot;
  
      console.log('page:', pageToScreenshot);
  
      if (!pageToScreenshot) return {
          statusCode: 400,
          body: JSON.stringify({ message: 'Page URL not defined' })
      }
  
      console.log('launch:');
      console.log('chromium.args:', chromium.args);
      console.log('chromium.defaultViewport:', chromium.defaultViewport);
      console.log('chromium.headless:', chromium.headless);
  
      const executablePath = await chromium.executablePath;
  
      const browser = await chromium.puppeteer.launch({
          args: chromium.args,
          defaultViewport: chromium.defaultViewport,
          executablePath,
          headless: chromium.headless,
      });
      console.log('page:');
  
      const page = await browser.newPage();
      console.log('goto:');
  
      await page.goto(pageToScreenshot, { waitUntil: 'networkidle2' });
      console.log('screenshot:');
  
      const screenshot = await page.screenshot({ encoding: 'binary' });
      console.log('close:');
  
      await browser.close();
      console.log('response:');
  
      return {
          statusCode: 200,
          body: JSON.stringify({
              message: `Complete screenshot of ${pageToScreenshot}`,
              buffer: screenshot
          })
      }
  
  }
  </code></pre>
  <p>This is the dependencies:</p>
  <pre><code>{
    &quot;name&quot;: &quot;snapshot31baa866&quot;,
    &quot;version&quot;: &quot;2.0.0&quot;,
    &quot;description&quot;: &quot;Lambda function generated by Amplify&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
    &quot;license&quot;: &quot;Apache-2.0&quot;,
    &quot;dependencies&quot;: {
      &quot;chrome-aws-lambda&quot;: &quot;^5.5.0&quot;,
      &quot;puppeteer-core&quot;: &quot;^5.5.0&quot;
    }
  }
  </code></pre>
  <p>The logs:</p>
  <blockquote>
  <p>START RequestId: 6dc39c75-0577-492d-b305-6d5c95778eea Version: $LATEST
  2020-12-09T04:56:34.141Z  6dc39c75-0577-492d-b305-6d5c95778eea    INFO    page:
  <a href="https://www.google.com" rel="nofollow noreferrer">https://www.google.com</a>
  2020-12-09T04:56:34.141Z  6dc39c75-0577-492d-b305-6d5c95778eea    INFO    launch: 2020-12-09T04:56:34.143Z    6dc39c75-0577-492d-b305-6d5c95778eea    INFO    chromium.args:
  [   '--autoplay-policy=user-gesture-required',<br />
  '--disable-background-networking',<br />
  '--disable-background-timer-throttling',<br />
  '--disable-backgrounding-occluded-windows',   '--disable-breakpad',<br />
  '--disable-client-side-phishing-detection',<br />
  '--disable-component-update',   '--disable-default-apps',<br />
  '--disable-dev-shm-usage',   '--disable-domain-reliability',<br />
  '--disable-extensions',<br />
  '--disable-features=AudioServiceOutOfProcess',<br />
  '--disable-hang-monitor',   '--disable-ipc-flooding-protection',<br />
  '--disable-notifications',<br />
  '--disable-offer-store-unmasked-wallet-cards',<br />
  '--disable-popup-blocking',   '--disable-print-preview',<br />
  '--disable-prompt-on-repost',   '--disable-renderer-backgrounding',<br />
  '--disable-setuid-sandbox',   '--disable-speech-api',<br />
  '--disable-sync',   '--disk-cache-size=33554432',<br />
  '--hide-scrollbars',   '--ignore-gpu-blacklist',<br />
  '--metrics-recording-only',   '--mute-audio',<br />
  '--no-default-browser-check',   '--no-first-run',   '--no-pings',<br />
  '--no-sandbox',   '--no-zygote',   '--password-store=basic',<br />
  '--use-gl=swiftshader',   '--use-mock-keychain',   '--single-process'
  ]
  2020-12-09T04:56:34.168Z  6dc39c75-0577-492d-b305-6d5c95778eea    INFO    chromium.defaultViewport:
  {   deviceScaleFactor: 1,   hasTouch: false,   height: 1080,<br />
  isLandscape: true,   isMobile: false,   width: 1920 }
  2020-12-09T04:56:34.168Z  6dc39c75-0577-492d-b305-6d5c95778eea    INFO    chromium.headless:
  true
  2020-12-09T04:56:57.868Z  6dc39c75-0577-492d-b305-6d5c95778eea    INFO    chromium.executablePath:
  /tmp/chromium END RequestId: 6dc39c75-0577-492d-b305-6d5c95778eea
  REPORT RequestId: 6dc39c75-0577-492d-b305-6d5c95778eea    Duration:
  25009.76 ms   Billed Duration: 25000 ms   Memory Size: 128 MB Max Memory Used: 128 MB Init Duration: 168.98 ms     2020-12-09T04:56:59.150Z
  6dc39c75-0577-492d-b305-6d5c95778eea Task timed out after 25.01
  seconds</p>
  </blockquote>