Skip to content

Conversation

cnaples79
Copy link

Summary

Add support for RUNTIME_INTERFACE_EMULATOR_ADDRESS environment variable to configure the emulator address without requiring CLI flags, addressing the need for easier configuration in containerized environments.

Motivation

Currently, the runtime interface emulator address can only be configured via the --runtime-interface-emulator-address CLI flag. In containerized environments where the entrypoint script is hardcoded (like in AWS Lambda base images), users must patch the Docker image to customize this address, which is cumbersome.

This change enables configuration via environment variable while maintaining backward compatibility and following the established pattern used by LOG_LEVEL.

Changes Made

  • Environment Variable Support: Added RUNTIME_INTERFACE_EMULATOR_ADDRESS environment variable
  • AWS CLI Precedence Pattern: CLI flag takes precedence over environment variable (consistent with AWS CLI behavior)
  • Documentation Update: Updated help text to document the new environment variable
  • Comprehensive Testing: Added integration tests for both environment variable usage and CLI precedence

Implementation Details

  • Follows the exact same pattern as existing LOG_LEVEL environment variable handling
  • Uses os.LookupEnv() to check for environment variable when CLI flag is at default value
  • Maintains all existing validation and error handling
  • Zero breaking changes - fully backward compatible

Usage Examples

# Set via environment variable
export RUNTIME_INTERFACE_EMULATOR_ADDRESS=127.0.0.1:9000
./aws-lambda-rie /lambda-entrypoint.sh handler

# CLI flag takes precedence (existing behavior)
./aws-lambda-rie --runtime-interface-emulator-address 127.0.0.1:9000 /lambda-entrypoint.sh handler

# Docker usage (addresses the original use case)
docker run -e RUNTIME_INTERFACE_EMULATOR_ADDRESS=0.0.0.0:8081 -p 8081:8081 my-lambda

Test Coverage

  • ✅ Environment variable usage test
  • ✅ CLI flag precedence test
  • ✅ Backward compatibility (all existing tests pass)

Fixes #120


Security Note: This change only affects local development/testing environments where the Lambda Runtime Interface Emulator is used. No production Lambda runtime changes.

… address

Add support for RUNTIME_INTERFACE_EMULATOR_ADDRESS environment variable
to configure the emulator address without requiring CLI flags.

This enables easier configuration in containerized environments where
modifying the entrypoint script is not practical. The implementation
follows the same pattern as LOG_LEVEL handling.

Features:
- Environment variable RUNTIME_INTERFACE_EMULATOR_ADDRESS support
- CLI flag takes precedence over environment variable (AWS CLI pattern)
- Updated help text to document the environment variable
- Added integration tests for environment variable usage
- Added test for CLI flag precedence over environment variable

Fixes aws#120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add environment variable for --runtime-interface-emulator-address
1 participant