Skip to content

Instantly share code, notes, and snippets.

Created Nov 21, 2019
What would you like to do?
AWS Lambda Go example - retrieve environment variables
package main
import (
func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
envVarKeys := []string{
m := make(map[string]string)
for _, v := range envVarKeys {
m[v] = os.Getenv(v)
jsonBytes, err := json.Marshal(m)
if err != nil {
log.Fatal("Error in converting map to json")
rstr := fmt.Sprint(string(jsonBytes))
return events.APIGatewayProxyResponse{
Body: rstr,
StatusCode: 200,
}, nil
func main() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment