environment_variables

Type map(string)
Default null

Environment variables passed to the function

Example

environment_variables = {}

Environment Variable Limits

  • Maximum size: 4 KB total for all environment variables
  • Reserved prefixes: AWS_, LAMBDA_ are reserved by AWS

Common Use Cases

VariablePurpose
LOG_LEVELControl logging verbosity
STAGEEnvironment identifier
API_ENDPOINTExternal API URLs
TABLE_NAMEDynamoDB table name

Best Practices

  • Store secrets in AWS Secrets Manager or SSM Parameter Store
  • Use environment variables for non-sensitive configuration
  • Keep values short to stay within the 4 KB limit
  • Document all environment variables used by your function

Full Module Example

module "lambda_function" {
  source  = "registry.patterneddesigns.ca/patterneddesigns/lambda-function/aws"
  version = "0.1.0"

  # environment_variables
  environment_variables = {}

  # Other required inputs
  function_name = my-resource
  runtime = python3.9
  handler = example-value
  source_path = /path/to/resource
}