static-content-lambda

command module
v0.0.0-...-0fee4cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Static content lambda

Because sometimes you just want to host static content inside an AWS lambda.

How it works

All this Go program does is wrap http.FileServer inside an AWS lambda handler that can interpret API Gateway requests, and transforms the response into something API Gateway can return to the browser.

It assumes that the static content is served from /var/www/html, however, that path can be changed with the CONTENT_DIR environment variable.

Usage

The Dockerfile in this repo includes an example of how to use this server with the content located in static_demo, however, in production, you could just download the file binary directly without needing to compile it. This would look something like this:

FROM busybox

ADD https://github.com/cds-snc/static-content-lambda/raw/main/release/latest/lambda-static-server /lambda-static-server
RUN chmod 755 /lambda-static-server

WORKDIR /var/www/html
COPY /content ./

ENTRYPOINT ["/lambda-static-server"]

or, if you want to be super slim

FROM busybox as build

ADD https://github.com/cds-snc/static-content-lambda/raw/main/release/latest/lambda-static-server /lambda-static-server
RUN chmod 755 /lambda-static-server

FROM scratch
COPY --from=build /lambda-static-server /lambda-static-server

WORKDIR /var/www/html
COPY /content ./

ENTRYPOINT ["/lambda-static-server"]

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL