Override of reserved variable names in a Lambda function High

Overriding environment variables that are reserved by AWS Lambda might lead to unexpected behavior or failure of the Lambda function.

Detector ID
python/lambda-override-reserved@v1.0
Category

Noncompliant example

1def create_variable_noncompliant():
2    import os
3    # Noncompliant: overrides reserved environment variable names
4    # in a Lambda function.
5    os.environ['_HANDLER'] = "value"

Compliant example

1def create_variable_compliant():
2    import os
3    # Compliant: prevents overriding reserved environment variable names
4    # in a Lambda function.
5    os.environ['SOME_ENV_VAR'] = "value"