AWS Lambda
Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Using Environment Variables

To access AWS Lambda Environment Variables in Go, use the Getenv function.

The following explains how to do this. Note that the function imports the fmt package to format the printed results and the os package, a platform-independent system interface that allows you to access environment variables.

package main import ( "fmt" "os" "github.com/aws/aws-lambda-go/lambda" ) func main() { fmt.Printf("%s is %s. years old\n", os.Getenv("NAME"), os.Getenv("AGE")) }

Lambda configures the following environment variables by default: Environment Variables Available to Lambda Functions.