title: 502 gateway error when utilizing AWS amplify, cloudwatch gives error on random line?
body: <p>I'm trying to create a webapp using react with a python back end using Lambda and AWS servers. The program should take the file I input on the website, upload it to my s3 bucket, translate that file, and upload the new file to that same s3 bucket.</p>
  <p>I am very confused, as I have the actual python program working &quot;in theory&quot; on cloud9. If I run the application with a test case of what I'm bringing in (the file name), it will take that file of the same name from the s3 bucket, analyze it and export data as necessary. The only issue is, when I try to do this on my react website where I upload the file, when I click submit, the original file is uploaded to the s3 bucket, but the translated data is not uploaded.</p>
  <p>What is more confusing, is that I am getting the error &quot;Failed to load resource: the server responded with a status of 502 (Bad Gateway)&quot;
  I've utilized a web proxy before by adding my site after &quot;const proxyurl = &quot;https://cors-anywhere.herokuapp.com/&quot;;&quot; to get past an issue with CORS before, but it seems this isn't the issue anymore. The error doesn't read anything about cors itself and the line in which I'm getting the issue is more about getting a response from the site. It seems it pulls a 502 status on the fetch provided below. Why is this where the error is being provided?</p>
  <pre><code>const response=await fetch(
      proxyurl + url,
      {
      method: &quot;POST&quot;,
      headers: {
          Accept : &quot;application/json&quot;,
          &quot;Content-Type&quot;: &quot;application.json&quot;
      },
      body : JSON.stringify(targetImage)    
      }
  );
  this.setState({confirmation : &quot;&quot;})
  </code></pre>
  <p>At first I thought it was due to the API gateway I have set up, so I went to the AWS API gateway, and created a POST method for my lambda function I utilize. I also made sure to click &quot;enable CORS&quot; and re-deployed the API to no avail. What's the source of this error?</p>
  <p>Below is the code for my python area in which the &quot;syntax error&quot; appears.</p>
  <pre><code>def get_kv_map(event): 
      filePath = event
      fileExt = filePath.get('body')
      s3 = boto3.resource('s3')
      bucket = s3.Bucket('myBucket')
      obj = bucket.Object(bucket)
      client = boto3.client('textract') #We utilize boto3's textract
      response = client.analyze_document(Document={'S3Object': {'Bucket': 'myBucket', 'Name': fileExt}}, FeatureTypes=['FORMS'])
  
      blocks=response['Blocks']     #We make a blocks variable that will be the blocks we find in the document
  
      key_map = {}
      value_map = {}
      block_map = {}
      for block in blocks:        #Traverse the blocks found in the document
          block_id = block['Id']          #Set variable for blockId to the Id's found on that block location
          block_map[block_id] = block                 #Make the block map at that ID be the block variable
          if block['BlockType'] == &quot;KEY_VALUE_SET&quot;:       #if we see that the type of block we're on is a key and value set pair, we check if it's a key or not. If it's not a key, we know it's a value. We send it to the respective map. 
              if 'KEY' in block['EntityTypes']:
                  key_map[block_id] = block
              else:
                  value_map[block_id] = block
      return key_map, value_map, block_map                    #######LINE WITH ERROR ######
  </code></pre>
  <p>After some trial and error, this is the error I get when submitting a test case of the typical &quot;event&quot; code. So this is what should in theory be submitted. My test cases with &quot;body&quot;:&quot;Sampleimg.jpg&quot; have all worked, but once I try and grab from the s3 bucket this happens...</p>
  <pre><code>&quot;errorType&quot;: &quot;InvalidS3ObjectException&quot;,
  &quot;errorMessage&quot;: &quot;An error occurred (InvalidS3ObjectException) when calling the AnalyzeDocument operation: Unable to get object metadata from S3. Check object key, region and/or access permissions.&quot;,
  &quot;stackTrace&quot;: [
      &quot;  File \&quot;/var/task/scrapeShow/lambda_function.py\&quot;, line 133, in main\n    key_map, value_map, block_map = get_kv_map(event)   #Take map variables in to get the key and value map we need.\n&quot;,
      &quot;  File \&quot;/var/task/scrapeShow/lambda_function.py\&quot;, line 39, in get_kv_map\n    response = client.analyze_document(Document={'S3Object': {'Bucket': 'myBucket', 'Name': fileExt}}, FeatureTypes=['FORMS'])\n&quot;,
      &quot;  File \&quot;/var/runtime/botocore/client.py\&quot;, line 316, in _api_call\n    return self._make_api_call(operation_name, kwargs)\n&quot;,
      &quot;  File \&quot;/var/runtime/botocore/client.py\&quot;, line 626, in _make_api_call\n    raise error_class(parsed_response, operation_name)\n&quot;
  ]
  </code></pre>
  <p>}</p>