🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🔧 AI Nachrichten ChatGPT automatically logged out [Fix](12.09.2026 um 17:09 Uhr)
⚠️ Malware / Trojaner / VirenWindows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC(10.09.2026 um 20:11 Uhr)
🪟 Windows TippsServertimeout in Outlook über 10 Minuten verlängern(12.09.2026 um 15:10 Uhr)
🔧 AI Nachrichten Stealing AI Reasoning Traces(08.09.2026 um 12:20 Uhr)
🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🔧 AI Nachrichten ChatGPT automatically logged out [Fix](12.09.2026 um 17:09 Uhr)
⚠️ Malware / Trojaner / VirenWindows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC(10.09.2026 um 20:11 Uhr)
🪟 Windows TippsServertimeout in Outlook über 10 Minuten verlängern(12.09.2026 um 15:10 Uhr)
🔧 AI Nachrichten Stealing AI Reasoning Traces(08.09.2026 um 12:20 Uhr)

🔧 Programmierung 🕛 vor 2 Jahren 7 Min Lesezeit
0

Deploy Puppeteer and Chrome on AWS Lambda With Layers and AWS CDK

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht




Introduction




  • In this blog post, we’ll show how to create a Lambda function that generates PDF file from HTML using Puppeteer and uploads PDF to S3.

  • We’ll also explore how to deploy Chromium on AWS Lambda Layer.

  • This blog post uses the (AWS CLI) to simplify the deployment of AWS resources.

  • You can download the code for this blog post from the






    Prerequisites




    • An AWS account with appropriate permissions.

    • AWS CLI - check out globally.

    • Node.js 18+ and NPM -



      In the project structure, there are a few main files to focus on:





      • cdk.json: Contains information that the toolkit will use to run our app. In our case, it will be npx ts-node --prefer-ts-exts bin/cdk-typescript-lambda-chromium.ts.


      • bin/cdk-typescript-lambda-chromium.ts: The entry point of the CDK application. It loads whatever the stack we define in lib/cdk-typescript-lambda-chromium-stack.ts.


      • lib/cdk-typescript-lambda-chromium-stack.ts: This is where the CDK application's main stack is defined. We'll spend most of our time here to create Lambda Function.






      Create S3 bucket



      First, we’ll create a new S3 bucket to store Chromium Layer and generated PDF files with CLI command below:




      CODE
      aws s3 mb s3://YOUR_S3_BUCKET_NAME









      Setting up Puppeteer and Chrome on AWS Lambda



      Next, we’ll need to use puppeteer-core, which includes only a compressed version of Chrome. To incorporate Puppeteer into AWS Lambda function, we'll utilize the chromium package, packages by






      Create a Lambda Function Stack with AWS CDK



      Then, we’ll define our CDK stack, which will contain the AWS resources required for PDF generating function.



      Before that, we’ll install a package called dotenv and create a config.ts file in lib to load environment variables from .env file. Install the package using:




      CODE
      npm install dotenv






      We'll use the AWS CDK to define the infrastructure as code. The :




      CODE
      const bucketArn = config.getS3BucketArn()

      lambdaFunction.addToRolePolicy(
      new iam.PolicyStatement({
      effect: iam.Effect.ALLOW,
      actions: ['s3:GetObject', 's3:PutObject'],
      resources: [bucketArn, `${bucketArn}/*`],
      })
      )






      Finally, we create a Lambda URL endpoint by calling the addFunctionUrl() method on our Lambda Function instance. We pass in two options:





      • authType: The authentication mode required to invoke the Lambda function; we use FunctionUrlAuthType.NONE to make the Lambda publicly accessible, so anyone with the Function URL can invoke it.


      • cors: We set it to ['*'] to allow all domains.




      CODE
      const myFunctionUrl = lambdaFunction.addFunctionUrl({
      authType: lambda.FunctionUrlAuthType.NONE,
      cors: {
      allowedOrigins: ['*'],
      },
      })

      new cdk.CfnOutput(this, 'LambdaNodeUrl', {
      value: myFunctionUrl.url,
      })









      Define the Lambda Function Code



      In the project structure, we’ll create a folder called src/generating-pdf to store all function code with Node.js runtime.



      The entire Lambda function code can be found



      Next, run cdk bootstrap to create a CloudFormation stack that includes the necessary resources.





      After the deployment completes, we'll receive the Lambda function's URL in the output, which you can invoke to generate PDFs.








      Conclusion



      In this blog post, we walked through deploying a Lambda function with Puppeteer and Chromium for PDF generation and explored setting up AWS resources using AWS CDK. This is a scalable solution to generate PDFs in the cloud.



      I hope this post helpful to you and thank you for reading.






      Reference






      Vollständiger Original-Bericht
      Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
      ↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
The Gemini desktop app is now available for Windows
1 Quelle
ChatGPT automatically logged out [Fix]
1 Quelle
Windows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Deploy Puppeteer and Chrome on AWS Lambda With Layers and AWS CDK

Thematisch verwandte Begriffe: Deploy, Puppeteer, Chrome, Lambda · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...