AWS Lambda read contents of file in zip uploaded as source code
<p>I have two files:</p>

<pre><code>MyLambdaFunction.py

config.json
</code></pre>

<p>I zip those two together to create <em>MyLambdaFunction.zip</em>.  I then upload that through the AWS console to my lambda function.  </p>

<p>The contents of <em>config.json</em> are various environmental variables.  I need a way to read the contents of the file each time the lambda function runs, and then use the data inside to set run time variables.</p>

<p>How do I get my Python Lambda function to read the contents of a file, <em>config.json</em>, that was uploaded in the zip file with the source code?</p>

<p>Try this. The file you uploaded can be accessed like:</p>

<pre><code>import os

os.environ['LAMBDA_TASK_ROOT']/config.json
</code></pre>

python amazon-web-services aws-lambda amazon-lambda