title: Is there a way to upload large files to Amazon lambda functions using Amazon s3
body: <p>I have written a python file which produces specific sentences that I would like to use as part of an Alexa skill. This then produces an array of these sentences. I am now trying to create a lambda function which implements these sentences in an Alexa based game format. However, the python file contains many imports which are not native to lambda so cannot be used.</p>
  
  <p>After much reading I attempted to install the import packages/dependencies using the following code (one library as an example):</p>
  
  <p>pip3 install spacy -t .</p>
  
  <p>I then zip the contents of my folder using the following code, before uploading the zip file into a Amazon s3 bucket: </p>
  
  <p>zip -r ../zipped_dir.zip *</p>
  
  <p>This worked initially but once I began installing many imports, the zip file quickly exceeded 100mb and so I am required to upload the zip file using 'AWS CLI, AWS SDK, or Amazon S3 REST API'. I have tried several methods of doing this, and the zip file successfully uploads but when I attempt to integrate it in my lambda function using the 'Code entry type':'Upload a file from Amazon s3', and providing the correct URL, the function does not allow me to save it. I click save and it attempts to do so, but remains orange. I believe this is because the file is too large. I am sure the upload method is correct because I re-tested the process using a zip file smaller than 100mb and uploaded to the lambda function with the associated URL, and that saved successfully. </p>
  
  <p>In order to upload the large file I have tried the following methods. I have used a combination of flask and boto3 in this example.</p>
  
  <pre><code>import boto3 
  from flask import Flask, request
  
  app = Flask(__name__)
  
  @app.route('/')
  def index():
      return '''&lt;form method=POST enctype=multipart/form-data                                  `       action="upload"&gt;
      &lt;input type=file name=myfile&gt;
      &lt;input type=submit&gt;
      &lt;/form'''
  
  @app.route('/upload',methods=['POST'])
  def upload():
      s3 = boto3.resource('s3')
  </code></pre>
  
  <p><code>s3.Bucket('bucket').put_object(Key='file.zip',Body=request.files</code>       ['myfile'])</p>
  
  <p>`       return '<h1>File saved to S3</h1>'</p>
  
  <pre><code>if __name__ == '__main__':
      app.run(debug=True)
  </code></pre>
  
  <p>This method also uploads the file successfully into the bucket, but I am unable to save it with the lambda function and URL.</p>
  
  <p>I have also tried to do it from the terminal with this command, which also uploads into the bucket successfully but cannot be saved on the lambda function:</p>
  
  <pre><code>aws s3 cp /foldername s3://bucketname/ --recursive --include          `   "myzip.zip"
  </code></pre>
  
  <p>I am sure manually installing all the files for the associated imports is not the most optimal method and so any suggested other methods would be helpful. If there is also a way to run the python file elsewhere, and pass the array of strings into the lambda function which can run on an Alexa device, that method will also be helpful. I have been stuck on this for almost a week and i'm sure the solution is rather simple, so any help is much appreciated. Thank you.</p>