IRONSOFTWAREHOME

How to Use IronWord on AWS Lambda

Kye Stuart
Kye Stuart
Updated: August 2, 2026

This article provides a comprehensive guide to setting up an AWS Lambda function using IronWord. You will learn how to configure IronWord to create and manipulate Word documents within an AWS Lambda environment.

Installation

Since this example will read/write Word documents to an S3 bucket, the AWSSDK.S3 NuGet package is required.

Using IronWord ZIP Package on AWS Lambda

AWS Lambda's filesystem is read-only except for the /tmp/ folder, so any Word documents your function creates locally before uploading to S3 must be written there:

var awsTmpPath = @"/tmp/";
C#

Integrating IronWord with AWS

Create an AWS Lambda Project

Use Visual Studio to create a containerized AWS Lambda project:

  1. Install the AWS Toolkit for Visual Studio
  2. Select AWS Lambda Project (.NET Core - C#)
  3. Choose the .NET 8 (Container Image) blueprint and finish the setup
  4. Select container image as the deployment type

Add Package Dependencies

Add IronWord and AWSSDK.S3 packages to your project via NuGet. The IronWord library works smoothly on AWS Lambda with the correct setup. Run the following command to install IronWord to your AWS project seamlessly:

PM > Install-Package IronWord

Update your project's Dockerfile to use the .NET 8 Lambda base image and copy your build artifacts:

FROM public.ecr.aws/lambda/dotnet:8

RUN dnf update -y

WORKDIR /var/task

COPY "bin/Release/lambda-publish"  .
Text

Modify the FunctionHandler Code

Below is an example Lambda function that creates a simple Word document, saves it as a .docx file, and uploads it to an S3 bucket.

using Amazon.Lambda.Core;
using Amazon.S3;
using Amazon.S3.Model;
using IronWord;
using IronWord.Models;
using System.Text;

// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]

namespace IronWordAwsLambda;

public class Function
{
    private static readonly IAmazonS3 _s3Client = new AmazonS3Client(Amazon.RegionEndpoint.APSoutheast1);

    public async Task FunctionHandler(ILambdaContext context)
    {
        var awsTmpPath = @"/tmp/";
        License.LicenseKey = "YOUR-LICENSE-KEY"; // Replace if you have one

        string filename = Guid.NewGuid() + ".docx";
        string localPath = Path.Combine(awsTmpPath, filename);
        string bucketName = "your-s3-bucket-name";
        string objectKey = $"IronWordAwsLambda/{filename}";

        try
        {
            // Create Word Document
            var doc = new WordDocument();
            Paragraph paragraph = new Paragraph(new TextContent("Hello from IronWord on AWS Lambda!"));
            doc.AddParagraph(paragraph);
            doc.SaveAs(localPath);

            context.Logger.LogLine("Word document created.");

            // Upload to S3
            byte[] fileBytes = await File.ReadAllBytesAsync(localPath);
            await UploadToS3Async(bucketName, objectKey, fileBytes);

            context.Logger.LogLine($"Document uploaded to S3: {bucketName}/{objectKey}");
        }
        catch (Exception ex)
        {
            context.Logger.LogLine($"[ERROR] {ex.Message}");
        }
    }

    private async Task UploadToS3Async(string bucketName, string objectKey, byte[] fileBytes)
    {
        using var stream = new MemoryStream(fileBytes);
        var request = new PutObjectRequest
        {
            BucketName = bucketName,
            Key = objectKey,
            InputStream = stream,
            ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
        };
        await _s3Client.PutObjectAsync(request);
    }
}

Increase Memory and Timeout

Since document processing can be memory-intensive, increase your Lambda function memory to at least 512 MB and timeout to 300 seconds in aws-lambda-tools-defaults.json:

{
  "function-memory-size": 512,
  "function-timeout": 300
}
JSON

If you encounter errors like Runtime exited with error: signal: killed, increase memory or optimize your code.

Publish

To publish your Lambda function:

  • Right-click your project in Visual Studio
  • Select Publish to AWS Lambda...
  • Follow the wizard and configure settings as needed

Try It Out!

Invoke the Lambda function through the AWS Lambda Console or Visual Studio. After execution, check your S3 bucket for the newly created Word document.

Frequently Asked Questions

How do I set up IronWord on AWS Lambda?

To set up IronWord on AWS Lambda, create an AWS Lambda project using Visual Studio, add the IronWord package via NuGet, modify the FunctionHandler code to generate Word documents, and configure the deployment using a Docker container.

What are the prerequisites for using IronWord with AWS Lambda?

You need to have Visual Studio, the AWS Toolkit for Visual Studio, and the IronWord and AWSSDK.S3 packages installed to use IronWord with AWS Lambda.

How can I ensure my IronWord AWS Lambda function works well with limited file system access?

AWS Lambda's filesystem is read-only except for the /tmp/ folder, so ensure that any Word documents created locally are written to the /tmp/ directory before uploading to S3.

What changes should I make to the FunctionHandler code when using IronWord?

Modify the FunctionHandler code to create Word documents, save them as .docx files, and implement an upload function to transfer them to an S3 bucket.

Can I customize the memory and timeout settings for my Lambda function using IronWord?

Yes, in the aws-lambda-tools-defaults.json file, you can increase your function's memory to at least 512 MB and set the timeout to 300 seconds to accommodate document processing needs.

How do I deploy my IronWord project to AWS Lambda?

Deploy your IronWord project to AWS Lambda using the Publish option in Visual Studio, selecting Publish to AWS Lambda and following the configuration wizard.

Is it necessary to use a Docker container for deploying IronWord on AWS Lambda?

Yes, configuring and deploying the project using a Docker container is recommended for compatibility and optimal deployment on AWS Lambda.

How do I install IronWord for my AWS Lambda project?

Install IronWord using the NuGet package manager in your Visual Studio project by adding it to the containerized AWS Lambda project setup.

What type of Word document tasks can IronWord handle on AWS Lambda?

IronWord can create, modify, and manipulate Word documents programmatically within an AWS Lambda environment, allowing complex document processing tasks.

What should I do if I encounter errors while using IronWord on AWS Lambda?

If you encounter errors like 'Runtime exited with error: signal: killed,' try increasing the memory allocation or optimizing your code for better performance.

Kye Stuart
Technical Writer

Kye Stuart merges coding passion and writing skill at Iron Software. Educated at Yoobee College in software deployment, they now transform complex tech concepts into clear educational content. Kye values lifelong learning and embraces new tech challenges.

...
Read More

Ready to Get Started?

Nuget Downloads 56,401Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronWord
nuget.org/packages/IronWord/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronWord"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronWord to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronWord.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required