title: Access AWS S3 from Lambda within VPC
body: <p>Overall, I'm pretty confused by using AWS Lambda within a VPC. The problem is Lambda is timing out while trying to access an S3 bucket. The solution seems to be a VPC Endpoint.</p>
  
  <p>I've added the Lambda function to a VPC so it can access an RDS hosted database (not shown in the code below, but functional). However, now I can't access S3 and any attempt to do so times out.</p>
  
  <p>I tried creating a VPC S3 Endpoint, but nothing has changed.</p>
  
  <p><strong>VPC Configuration</strong></p>
  
  <p>I'm using a simple VPC created by default whenever I first made an EC2 instance. It has four subnets, all created by default.</p>
  
  <p><strong>VPC Route Table</strong></p>
  
  <pre><code>_Destination - Target - Status - Propagated_
  
  172.31.0.0/16 - local - Active - No
  
  pl-63a5400a (com.amazonaws.us-east-1.s3) - vpce-b44c8bdd - Active - No
  
  0.0.0.0/0 - igw-325e6a56 - Active - No
  </code></pre>
  
  <p><strong>Simple S3 Download Lambda:</strong></p>
  
  <pre><code>import boto3
  import pymysql
  from StringIO import StringIO
  
  def lambda_handler(event, context):
      s3Obj = StringIO()
  
      return boto3.resource('s3').Bucket('marineharvester').download_fileobj('Holding - Midsummer/sample', s3Obj)
  </code></pre>