How to Run & Deploy IronPDF .NET on AWS Lambda
1. Create AWS Lambda with a container template
Use the Amazon.Lambda.Templates NuGet package to scaffold a container-based Lambda project (dotnet new lambda.image.EmptyFunction), following AWS's current guide: Deploy .NET Lambda functions with container images. AWS currently maintains base images for .NET 8, 9, and 10 - choose the Dockerfile below matching your target framework.
2. Add package dependencies
These dependencies are required for Chrome in this AWS environment.
Please modify the Docker file according to these instructions:
AWS Lambda with .NET 5
AWS Lambda with .NET 7
AWS Lambda with .NET 8
public.ecr.aws/lambda/dotnet:8 base image (Amazon Linux 2023), the Docker build fails with a dnf depsolve conflict because xorg-x11-utils is now obsoleted by xprop. In the dependency install line, replace xorg-x11-utils with xprop to fix it.3. Add the IronPDF (Linux) NuGet package
Install IronPdf.Linux
- In Solution Explorer, right-click References, Manage NuGet Packages.
- Select Browse and search
IronPdf.Linux. - Select the package and install.
4. Modify FunctionHandler code
This example will create a PDF file from a webpage https://ironpdf.com/ and save it to /tmp. To view this PDF, you must upload it to another service such as S3.
It is necessary to configure the temporary folder when using IronPDF on AWS Lambda. Please use the TempFolderPath and CustomDeploymentDirectory properties to do this.
public Casing FunctionHandler(string input, ILambdaContext context)
{
try
{
context.Logger.LogLine($"START FunctionHandler RequestId: {context.AwsRequestId} Input: {input}");
var awsTmpPath = @"/tmp/"; // AWS temporary storage location
// [Optional] Enable logging for debugging
// Uncomment these lines if you encounter issues
// IronPdf.Logging.Logger.EnableDebugging = true;
// IronPdf.Logging.Logger.LogFilePath = awsTmpPath;
// IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "YOUR_LICENSE_KEY";
// Disable GPU for Chrome rendering in headless environments
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Disabled;
// Configure IronPDF to use the AWS temporary directory
IronPdf.Installation.TempFolderPath = awsTmpPath;
IronPdf.Installation.CustomDeploymentDirectory = awsTmpPath;
// Automatically configure Linux and Docker dependencies
IronPdf.Installation.LinuxAndDockerDependenciesAutoConfig = true;
context.Logger.LogLine($"Creating IronPdf.ChromePdfRenderer");
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"; // Save file to /tmp
context.Logger.LogLine($"Saving PDF with name: {fileName}");
pdfDoc.SaveAs(fileName);
// Place for future code to upload the PDF file to a service like AWS S3.
context.Logger.LogLine($"COMPLETE!");
}
catch (Exception e)
{
context.Logger.LogLine($"[ERROR] FunctionHandler : {e.Message}");
}
return new Casing(input?.ToLower(), input?.ToUpper());
}Public Function FunctionHandler(ByVal input As String, ByVal context As ILambdaContext) As Casing
Try
context.Logger.LogLine($"START FunctionHandler RequestId: {context.AwsRequestId} Input: {input}")
Dim awsTmpPath = "/tmp/" ' AWS temporary storage location
' [Optional] Enable logging for debugging
' Uncomment these lines if you encounter issues
' IronPdf.Logging.Logger.EnableDebugging = true;
' IronPdf.Logging.Logger.LogFilePath = awsTmpPath;
' IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;
' Set your IronPDF license key
IronPdf.License.LicenseKey = "YOUR_LICENSE_KEY"
' Disable GPU for Chrome rendering in headless environments
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Disabled
' Configure IronPDF to use the AWS temporary directory
IronPdf.Installation.TempFolderPath = awsTmpPath
IronPdf.Installation.CustomDeploymentDirectory = awsTmpPath
' Automatically configure Linux and Docker dependencies
IronPdf.Installation.LinuxAndDockerDependenciesAutoConfig = True
context.Logger.LogLine($"Creating IronPdf.ChromePdfRenderer")
Dim Renderer = New IronPdf.ChromePdfRenderer()
context.Logger.LogLine($"Rendering PDF")
Dim pdfDoc = Renderer.RenderUrlAsPdf("https://ironpdf.com/")
Dim guid As System.Guid = System.Guid.NewGuid()
Dim fileName = $"/tmp/{input}_{guid}.pdf" ' Save file to /tmp
context.Logger.LogLine($"Saving PDF with name: {fileName}")
pdfDoc.SaveAs(fileName)
' Place for future code to upload the PDF file to a service like AWS S3.
context.Logger.LogLine($"COMPLETE!")
Catch e As Exception
context.Logger.LogLine($"[ERROR] FunctionHandler : {e.Message}")
End Try
Return New Casing(input?.ToLower(), input?.ToUpper())
End Function5. Increase Memory and Timeout
IronPDF requires more time and memory than the default value of Lambda. You can configure it in aws-lambda-tools-defaults.json. Please adjust this to match your function. In this example, we will set it to 512 (MB) and 330 (seconds).
{
"function-memory-size": 512,
"function-timeout": 330
}
You also can update this configuration using the Lambda console. Navigate to the Configuring AWS Lambda functions article for more information.
6. Publish
Use dotnet lambda deploy-function to build the Docker image, push it to Amazon ECR, and deploy the Lambda function. See the "Creating and deploying an image using a base image" section of AWS's Deploy .NET Lambda functions with container images guide for the full publish-and-test workflow, including dotnet lambda invoke-function to test.
7. Try it out!
You can activate the Lambda function using the Lambda console or via Visual Studio by using the AWS Toolkit for Visual Studio.
Frequently Asked Questions
How can I deploy IronPDF on AWS Lambda?
To deploy IronPDF on AWS Lambda, you need to create an AWS Lambda function with a container template using the Amazon.Lambda.Templates NuGet package. After setting up your project, add necessary dependencies, including the IronPDF (Linux) NuGet package, and configure your function to handle PDF generation with IronPDF.
What prerequisites are needed for using IronPDF with AWS Lambda?
Before using IronPDF with AWS Lambda, you need to install dependencies for Chrome in the AWS environment and ensure you have set up the correct .NET framework using AWS-supported base images. Additionally, incorporate the IronPDF (Linux) NuGet package to manage PDF operations.
How do I configure temporary storage for IronPDF on AWS Lambda?
You configure temporary storage for IronPDF on AWS Lambda by setting the TempFolderPath and CustomDeploymentDirectory properties in your code to the AWS temporary storage location, typically ‘/tmp’.
Do I need to make any specific settings for IronPDF to work on AWS?
Yes, you must set IronPdf.Installation.TempFolderPath and IronPdf.Installation.CustomDeploymentDirectory to the AWS temp directory, and disable the GPU for Chrome rendering because Lambda runs in a headless environment.
What are the memory and timeout settings required for IronPDF on AWS Lambda?
IronPDF requires more memory and timeout than the default settings. It is recommended to set the memory to 512 MB and the timeout to 330 seconds. These can be configured in the aws-lambda-tools-defaults.json file or via the AWS Lambda console.
How can I test my IronPDF Lambda function after deployment?
After deploying your IronPDF Lambda function, you can test it using the AWS Lambda console or through Visual Studio using the AWS Toolkit for Visual Studio. Additionally, use the `dotnet lambda invoke-function` command for testing.
Why should I disable GPU mode for IronPDF when using AWS Lambda?
Disabling GPU mode is necessary when using IronPDF on AWS Lambda because the Lambda function environment is headless, and GPU rendering is not available. Utilize the IronPdf.Engines.Chrome.ChromeGpuModes.Disabled setting.
How can I ensure my Docker dependencies are correctly configured for IronPDF?
IronPDF offers an automatic configuration for Linux and Docker dependencies using IronPdf.Installation.LinuxAndDockerDependenciesAutoConfig. Enabling this option helps manage dependencies efficiently in a dockerized AWS Lambda environment.
What are the steps for building and deploying a function with IronPDF on AWS?
To build and deploy a function with IronPDF on AWS, use `dotnet lambda deploy-function` to create a Docker image, push it to Amazon ECR, and deploy your function. Follow AWS’s deployment guide for a complete workflow from building to testing.
Can I use AWS S3 with IronPDF for storing generated PDFs?
Yes, after generating PDFs using IronPDF on AWS Lambda, you can upload them to AWS S3 for storage. This typically involves using AWS SDK or other tools to transfer files from Lambda’s temporary storage to S3.

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.