AWS Lambda IronPDF en Amazon Linux 2

Curtis Chau
Curtis Chau
Updated: 24 de abril de 2026

AWS Lambda / Amazon Linux 2 (Instalar como admin/root usando IronPdf.Linux)

Esta información también se muestra en nuestro sitio web - Guía de AWS Lambda IronPDF

Instrucciones de AWS

  1. Consulte Soporte de AWS .NET 5 Lambda con Imágenes de Contenedores
  2. Cree y use el siguiente Dockerfile:
# Use the .NET 5 AWS Lambda runtime as the base image
FROM public.ecr.aws/lambda/dotnet:5.0
WORKDIR /var/task

# Install the necessary dependencies for IronPDF
RUN yum install -y pango.x86_64 \
                   libXcomposite.x86_64 \
                   libXcursor.x86_64 \
                   libXdamage.x86_64 \
                   libXext.x86_64 \
                   libXi.x86_64 \
                   libXtst.x86_64 \
                   cups-libs.x86_64 \
                   libXScrnSaver.x86_64 \
                   libXrandr.x86_64 \
                   GConf2.x86_64 \
                   alsa-lib.x86_64 \
                   atk.x86_64 \
                   gtk3.x86_64 \
                   ipa-gothic-fonts \
                   xorg-x11-fonts-100dpi \
                   xorg-x11-fonts-75dpi \
                   xorg-x11-utils \
                   xorg-x11-fonts-cyrillic \
                   xorg-x11-fonts-Type1 \
                   xorg-x11-fonts-misc \
                   glibc-devel.x86_64 \
                   at-spi2-atk.x86_64 \
                   mesa-libgbm.x86_64

# This COPY command copies the .NET Lambda project's build artifacts from the host machine into the image.
COPY "bin/Release/lambda-publish" .
Dockerfile
  1. Agregue el paquete IronPdf.Linux a su solución.
  2. Modifique el código _FunctionHandler - este ejemplo creará un PDF desde una página web (IronPDF) y lo guardará en /tmp. Para ver este PDF, debe cargarse a otro servicio, como S3. (Ejemplo oficial de AWS disponible aquí - Conceptos Básicos de AWS S3)
// Define the function handler for AWS Lambda
public Casing FunctionHandler(string input, ILambdaContext context)
{
    try
    {
        // Start logging the function process with input details
        context.Logger.LogLine($"START FunctionHandler RequestId: {context.AwsRequestId} Input: {input}");

        var awsTmpPath = @"/tmp/"; // AWS temporary storage path

        // Optional: Enable debugging for IronPdf
        // IronPdf.Logging.Logger.EnableDebugging = true;
        // IronPdf.Logging.Logger.LogFilePath = awsTmpPath;
        // IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;

        // Set your license key for IronPDF
        IronPdf.License.LicenseKey = "YOUR_LICENSE_KEY";

        // Configuration for IronPDF rendering
        IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Disabled;
        IronPdf.Installation.DefaultRenderingEngine = IronPdf.Rendering.PdfRenderingEngine.Chrome;
        Environment.SetEnvironmentVariable("TEMP", awsTmpPath, EnvironmentVariableTarget.Process);
        Environment.SetEnvironmentVariable("TMP", awsTmpPath, EnvironmentVariableTarget.Process);
        IronPdf.Installation.TempFolderPath = awsTmpPath;
        IronPdf.Installation.CustomDeploymentDirectory = awsTmpPath;
        IronPdf.Installation.LinuxAndDockerDependenciesAutoConfig = true;

        context.Logger.LogLine($"Creating IronPdf.ChromePdfRenderer");

        // Create instance of ChromePdfRenderer and render PDF from URL
        var renderer = new IronPdf.ChromePdfRenderer();
        context.Logger.LogLine($"Rendering PDF");
        using var pdfDoc = renderer.RenderUrlAsPdf("https://ironpdf.com/");
        var guid = Guid.NewGuid();
        var fileName = $"/tmp/{input}_{guid}.pdf"; // Name for the PDF file

        // Save the rendered PDF document
        context.Logger.LogLine($"Saving PDF name : {fileName}");
        pdfDoc.SaveAs(fileName);

        // Here you can upload the saved PDF file to anywhere such as AWS S3.
        context.Logger.LogLine($"COMPLETE!");
    }
    catch (Exception e)
    {
        // Log errors if any occur
        context.Logger.LogLine($"[ERROR] FunctionHandler : {e.Message}");
    }

    // Return a new instance of Casing with lower and upper case input strings
    return new Casing(input?.ToLower(), input?.ToUpper());
}

// Casing record to hold lower and upper case strings
public record Casing(string Lower, string Upper);
  1. Aumente la memoria y el tiempo de espera - IronPDF requiere más tiempo y memoria que el valor predeterminado de Lambda. Esto se puede configurar en aws-lambda-tools-defaults.json. Ajuste estos valores para que coincidan con las necesidades de su función.

En este ejemplo, configuramos a 512 (MB) y 330 (segundos):

"function-memory-size": 512,
"function-timeout": 330,
JSON

La configuración también se puede actualizar usando la consola de Lambda - Configuración de Memoria de AWS Lambda. 6. Siga la última parte de la documentación para publicar e intentar una función Lambda Soporte de AWS .NET 5 Lambda con imágenes de contenedor 7. La función Lambda también se puede invocar usando la consola de Lambda, Consola de AWS Lambda o invocada a través de Visual Studio utilizando el AWS Toolkit para Visual Studio.

Si recibe un mensaje "El proceso GPU no es utilizable", la instalación puede no haberse ejecutado con privilegios de administrador. Por favor intente ejecutar el software nuevamente con privilegios de admin/root. Alternativamente, agregue lo siguiente a su Dockerfile:

RUN chmod 755 "runtimes/linux-x64/native/IronCefSubprocess"
Dockerfile

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien estructurados y visualmente atractivos.

Leer más

¿Listo para empezar?

Nuget Downloads 21,916,531Versión:2026.11recién publicada