Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda: How To Remove Environmental Variables from Configuration

I have a lambda function that used to use encrypted environmental variables set in the lambda configuration but I no longer need them. I tried removing the env variable in the UI and it no longer shows up but still seeing in the logs:

"Found credentials in environment variables."

I also tried using the update-function-code command without passing an env variable which doesn't work.

Any way to remove the encrypted env variables from my lambda function configuration? I want to ensure unused/unneeded things are removed.

Thanks!

like image 905
JackieMoon Avatar asked Dec 12 '18 05:12

JackieMoon


People also ask

How do I hide environment variables in AWS Lambda?

To prevent IAM identities from accessing passwords, keys, or other sensitive information in your Lambda environment variables, do the following: Use an AWS Key Management Service (AWS KMS) customer managed key to encrypt the environment variables.

How do you decrypt Lambda environment variables?

Click on "Decrypt" button one by one. Choose the AWS KMS key which you prefer to use for encryption Lambda function environment variable in transit. Python developers building the Lambda function code will get the code block required to decrypt each environment variable.

Does Lambda encrypt environment variables by default?

You can use environment variables to store secrets securely for use with Lambda functions. Lambda always encrypts environment variables at rest. By default, Lambda uses an AWS KMS key that Lambda creates in your account to encrypt your environment variables. This AWS managed key is named aws/lambda .


2 Answers

I believe it is a standard output from the inner workings of python lambdas that use boto. None of my python Lambdas have credentials and yet I have the same message in all logs of python lambdas.

like image 121
Neil Davies Avatar answered Sep 28 '22 02:09

Neil Davies


I know it's a little late to this, but here is my understanding.

The statement "Found credentials in environment variables." does not have anything to do with the environment variables you configured. Apparently, Lambda has a set of reserved environment variables and when your code tries to connect to other AWS services (like S3, SNS etc), Lambda tries to read the credentials from reserved environment variables to make a connection to the other service and in the process logs the statement about where it found the credentials to "stdout"

According to this article, when you have a logger configured with INFO level, then all the .info() statements by your code and the AWS SDK will be logged to "stdout" and thereby ending up in CloudWatch logs. Try setting the logger level to WARNING and observe the logs.

like image 44
Mano Nandu Avatar answered Sep 28 '22 03:09

Mano Nandu