Repository: localstack/localstack

Issue:
cdk: api-gateway with s3 integration does not work
# Type of request: This is a ...

[X] bug report
[ ] feature request

cdk / cloudformation configured api-gateway with s3 integration does not work ( the same stack works in aws ).
other services works with the same cdk code, e.g. sqs.

## Expected behavior

the stack works as in aws
 
## Actual behavior

localstack  | 2021-05-23T04:14:16:DEBUG:localstack.utils.cloudformation.template_deployer: Running action "create" for resource type "ApiGateway::Method" id "DevCustomerApiGET55FE239F"
localstack  | 2021-05-23T04:14:16:DEBUG:localstack.utils.cloudformation.template_deployer: Request for resource type "ApiGateway::Method" in region us-east-1: put_method {'restApiId': 'mkj4ahf978', 'resourceId': 'umswnavo5j', 'httpMethod': 'GET', 'authorizationType': 'NONE'}
localstack  | 2021-05-23 04:14:16,380:API: Error on request:
localstack  | Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
localstack  |     execute(self.server.app)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 308, in execute
localstack  |     application_iter = app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 178, in __call__
localstack  |     return backend_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2069, in __call__
localstack  |     return self.wsgi_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2054, in wsgi_app
localstack  |     response = self.handle_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2051, in wsgi_app
localstack  |     response = self.full_dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1501, in full_dispatch_request
localstack  |     rv = self.handle_user_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1499, in full_dispatch_request
localstack  |     rv = self.dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1485, in dispatch_request
localstack  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/utils.py", line 156, in __call__
localstack  |     result = self.callback(request, request.url, {})
localstack  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_starter.py", line 205, in apigateway_response_integrations
localstack  |     integration_response['timeoutInMillis'] = timeout_milliseconds
localstack  | TypeError: 'NoneType' object does not support item assignment
localstack  | 2021-05-23 04:14:17,089:API: Error on request:
localstack  | Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
localstack  |     execute(self.server.app)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 308, in execute
localstack  |     application_iter = app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 178, in __call__
localstack  |     return backend_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2069, in __call__
localstack  |     return self.wsgi_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2054, in wsgi_app
localstack  |     response = self.handle_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2051, in wsgi_app
localstack  |     response = self.full_dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1501, in full_dispatch_request
localstack  |     rv = self.handle_user_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1499, in full_dispatch_request
localstack  |     rv = self.dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1485, in dispatch_request
localstack  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/utils.py", line 156, in __call__
localstack  |     result = self.callback(request, request.url, {})
localstack  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_starter.py", line 205, in apigateway_response_integrations
localstack  |     integration_response['timeoutInMillis'] = timeout_milliseconds
localstack  | TypeError: 'NoneType' object does not support item assignment
localstack  | 2021-05-23T04:14:18:DEBUG:localstack.utils.cloudformation.template_deployer: Extract resource attribute: ApiGateway::Deployment Ref
localstack  | 2021-05-23T04:14:18:DEBUG:localstack.services.cloudformation.cloudformation_api: Unable to resolve references in stack outputs: {'Value': {'Fn::Join': ['', ['https://', {'Ref': 'DevCustomerApiA279E14E'}, '.execute-api.', {'Ref': 'AWS::Region'}, '.', {'Ref': 'AWS::URLSuffix'}, '/', {'Ref': 'DevCustomerApiDeploymentStageprodE70041CA'}, '/']]}} - Unable to fetch details for resource "DevCustomerApiDeployment2663BF7C9972510c02f7f7a1a55860bb1c9e641c" (attribute "Ref")
localstack  | 2021-05-23 04:14:18,785:API: Error on request:
localstack  | Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
localstack  |     execute(self.server.app)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 308, in execute
localstack  |     application_iter = app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 178, in __call__
localstack  |     return backend_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2069, in __call__
localstack  |     return self.wsgi_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2054, in wsgi_app
localstack  |     response = self.handle_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2051, in wsgi_app
localstack  |     response = self.full_dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1501, in full_dispatch_request
localstack  |     rv = self.handle_user_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1499, in full_dispatch_request
localstack  |     rv = self.dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1485, in dispatch_request
localstack  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/utils.py", line 156, in __call__
localstack  |     result = self.callback(request, request.url, {})
localstack  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_starter.py", line 205, in apigateway_response_integrations
localstack  |     integration_response['timeoutInMillis'] = timeout_milliseconds
localstack  | TypeError: 'NoneType' object does not support item assignment
localstack  | 2021-05-23 04:14:22,219:API: Error on request:
localstack  | Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
localstack  |     execute(self.server.app)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 308, in execute
localstack  |     application_iter = app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 178, in __call__
localstack  |     return backend_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2069, in __call__
localstack  |     return self.wsgi_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2054, in wsgi_app
localstack  |     response = self.handle_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2051, in wsgi_app
localstack  |     response = self.full_dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1501, in full_dispatch_request
localstack  |     rv = self.handle_user_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1499, in full_dispatch_request
localstack  |     rv = self.dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1485, in dispatch_request
localstack  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/utils.py", line 156, in __call__
localstack  |     result = self.callback(request, request.url, {})
localstack  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_starter.py", line 205, in apigateway_response_integrations
localstack  |     integration_response['timeoutInMillis'] = timeout_milliseconds
localstack  | TypeError: 'NoneType' object does not support item assignment
localstack  | 2021-05-23T04:14:23:DEBUG:localstack.utils.cloudformation.template_deployer: Extract resource attribute: ApiGateway::Deployment Ref
localstack  | 2021-05-23T04:14:23:DEBUG:localstack.services.cloudformation.cloudformation_api: Unable to resolve references in stack outputs: {'Value': {'Fn::Join': ['', ['https://', {'Ref': 'DevCustomerApiA279E14E'}, '.execute-api.', {'Ref': 'AWS::Region'}, '.', {'Ref': 'AWS::URLSuffix'}, '/', {'Ref': 'DevCustomerApiDeploymentStageprodE70041CA'}, '/']]}} - Unable to fetch details for resource "DevCustomerApiDeployment2663BF7C9972510c02f7f7a1a55860bb1c9e641c" (attribute "Ref")
localstack  | 2021-05-23T04:14:24:DEBUG:localstack.utils.cloudformation.template_deployer: Error applying changes for CloudFormation stack "CustomerApiStack": An error occurred (500) when calling the PutIntegration operation (reached max retries: 4): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
localstack  | <title>500 Internal Server Error</title>
localstack  | <h1>Internal Server Error</h1>
localstack  | <p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
localstack  |  Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1825, in _run
localstack  |     self.do_apply_changes_in_loop(changes, stack, stack_name)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1876, in do_apply_changes_in_loop
localstack  |     self.apply_change(change, stack, new_resources, stack_name=stack_name)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1929, in apply_change
localstack  |     result = deploy_resource(resource_id, new_resources, stack_name)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 937, in deploy_resource
localstack  |     return execute_resource_action(resource_id, resources, stack_name, ACTION_CREATE)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1041, in execute_resource_action
localstack  |     result = configure_resource_via_sdk(resource_id, resources, resource_type, func, stack_name, action_name)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1167, in configure_resource_via_sdk
localstack  |     run_post_create_actions(action_name, resource_id, resources, resource_type, stack_name, result)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1232, in run_post_create_actions
localstack  |     apigateway.put_integration(
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 386, in _api_call
localstack  |     return self._make_api_call(operation_name, kwargs)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 705, in _make_api_call
localstack  |     raise error_class(parsed_response, operation_name)
localstack  | botocore.exceptions.ClientError: An error occurred (500) when calling the PutIntegration operation (reached max retries: 4): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
localstack  | <title>500 Internal Server Error</title>
localstack  | <h1>Internal Server Error</h1>
localstack  | <p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
localstack  |
localstack  |
localstack  | 2021-05-23 04:14:24,721:API: Error on request:
localstack  | Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
localstack  |     execute(self.server.app)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 308, in execute
localstack  |     application_iter = app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 178, in __call__
localstack  |     return backend_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2069, in __call__
localstack  |     return self.wsgi_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2054, in wsgi_app
localstack  |     response = self.handle_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2051, in wsgi_app
localstack  |     response = self.full_dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1501, in full_dispatch_request
localstack  |     rv = self.handle_user_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1499, in full_dispatch_request
localstack  |     rv = self.dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1485, in dispatch_request
localstack  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/utils.py", line 156, in __call__
localstack  |     result = self.callback(request, request.url, {})
localstack  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_starter.py", line 205, in apigateway_response_integrations
localstack  |     integration_response['timeoutInMillis'] = timeout_milliseconds
localstack  | TypeError: 'NoneType' object does not support item assignment
localstack  | 2021-05-23T04:14:28:DEBUG:localstack.utils.cloudformation.template_deployer: Extract resource attribute: ApiGateway::Deployment Ref
localstack  | 2021-05-23T04:14:28:DEBUG:localstack.services.cloudformation.cloudformation_api: Unable to resolve references in stack outputs: {'Value': {'Fn::Join': ['', ['https://', {'Ref': 'DevCustomerApiA279E14E'}, '.execute-api.', {'Ref': 'AWS::Region'}, '.', {'Ref': 'AWS::URLSuffix'}, '/', {'Ref': 'DevCustomerApiDeploymentStageprodE70041CA'}, '/']]}} - Unable to fetch details for resource "DevCustomerApiDeployment2663BF7C9972510c02f7f7a1a55860bb1c9e641c" (attribute "Ref")

# Steps to reproduce

## Command used to start LocalStack

version: '3'
services:
  localstack:
    image: localstack/localstack
    container_name: localstack
    network_mode: bridge
    ports:
      - "4566:4566"
      - "4571:4571"
      - '8055:8080'
    environment:
      - SERVICES=s3,dynamodb,lambda,apigateway,cloudformation,iam,sqs,sts
      - DEBUG=1
      - DATA_DIR=/tmp/localstack/data
    volumes:
      - './.localstack:/tmp/localstack'
      - '/var/run/docker.sock:/var/run/docker.sock'

## Client code (AWS SDK code snippet, or sequence of "awslocal" commands)

    const api = new apigw.RestApi(this, 'MyApi', {
          endpointTypes: [EndpointType.REGIONAL]
        });
    
    const bucket = new s3.Bucket(this, 'test-bucket');

    const executeRole = new iam.Role(this, "role", {
      assumedBy: new iam.ServicePrincipal('apigateway.amazonaws.com'),
      path: "/service-role/"
    });

    bucket.grantReadWrite(executeRole);

    const s3Integration = new apigw.AwsIntegration({
      service: 's3',
      integrationHttpMethod: "GET",
      path:  bucket.bucketName + "/test.json",
      options : {
        credentialsRole: executeRole,
        integrationResponses: [{statusCode: '200'}]
      },
    })

    api.root.addMethod("GET",
        s3Integration, {
      methodResponses: [
        {
          statusCode: "200"
        }
      ]});



cdk: api-gateway with s3 integration does not work
# Type of request: This is a ...

[X] bug report
[ ] feature request

cdk / cloudformation configured api-gateway with s3 integration does not work ( the same stack works in aws ).
other services works with the same cdk code, e.g. sqs.

## Expected behavior

the stack works as in aws
 
## Actual behavior

localstack  | 2021-05-23T04:14:16:DEBUG:localstack.utils.cloudformation.template_deployer: Running action "create" for resource type "ApiGateway::Method" id "DevCustomerApiGET55FE239F"
localstack  | 2021-05-23T04:14:16:DEBUG:localstack.utils.cloudformation.template_deployer: Request for resource type "ApiGateway::Method" in region us-east-1: put_method {'restApiId': 'mkj4ahf978', 'resourceId': 'umswnavo5j', 'httpMethod': 'GET', 'authorizationType': 'NONE'}
localstack  | 2021-05-23 04:14:16,380:API: Error on request:
localstack  | Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
localstack  |     execute(self.server.app)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 308, in execute
localstack  |     application_iter = app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 178, in __call__
localstack  |     return backend_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2069, in __call__
localstack  |     return self.wsgi_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2054, in wsgi_app
localstack  |     response = self.handle_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2051, in wsgi_app
localstack  |     response = self.full_dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1501, in full_dispatch_request
localstack  |     rv = self.handle_user_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1499, in full_dispatch_request
localstack  |     rv = self.dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1485, in dispatch_request
localstack  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/utils.py", line 156, in __call__
localstack  |     result = self.callback(request, request.url, {})
localstack  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_starter.py", line 205, in apigateway_response_integrations
localstack  |     integration_response['timeoutInMillis'] = timeout_milliseconds
localstack  | TypeError: 'NoneType' object does not support item assignment
localstack  | 2021-05-23 04:14:17,089:API: Error on request:
localstack  | Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
localstack  |     execute(self.server.app)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 308, in execute
localstack  |     application_iter = app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 178, in __call__
localstack  |     return backend_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2069, in __call__
localstack  |     return self.wsgi_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2054, in wsgi_app
localstack  |     response = self.handle_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2051, in wsgi_app
localstack  |     response = self.full_dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1501, in full_dispatch_request
localstack  |     rv = self.handle_user_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1499, in full_dispatch_request
localstack  |     rv = self.dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1485, in dispatch_request
localstack  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/utils.py", line 156, in __call__
localstack  |     result = self.callback(request, request.url, {})
localstack  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_starter.py", line 205, in apigateway_response_integrations
localstack  |     integration_response['timeoutInMillis'] = timeout_milliseconds
localstack  | TypeError: 'NoneType' object does not support item assignment
localstack  | 2021-05-23T04:14:18:DEBUG:localstack.utils.cloudformation.template_deployer: Extract resource attribute: ApiGateway::Deployment Ref
localstack  | 2021-05-23T04:14:18:DEBUG:localstack.services.cloudformation.cloudformation_api: Unable to resolve references in stack outputs: {'Value': {'Fn::Join': ['', ['https://', {'Ref': 'DevCustomerApiA279E14E'}, '.execute-api.', {'Ref': 'AWS::Region'}, '.', {'Ref': 'AWS::URLSuffix'}, '/', {'Ref': 'DevCustomerApiDeploymentStageprodE70041CA'}, '/']]}} - Unable to fetch details for resource "DevCustomerApiDeployment2663BF7C9972510c02f7f7a1a55860bb1c9e641c" (attribute "Ref")
localstack  | 2021-05-23 04:14:18,785:API: Error on request:
localstack  | Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
localstack  |     execute(self.server.app)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 308, in execute
localstack  |     application_iter = app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 178, in __call__
localstack  |     return backend_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2069, in __call__
localstack  |     return self.wsgi_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2054, in wsgi_app
localstack  |     response = self.handle_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2051, in wsgi_app
localstack  |     response = self.full_dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1501, in full_dispatch_request
localstack  |     rv = self.handle_user_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1499, in full_dispatch_request
localstack  |     rv = self.dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1485, in dispatch_request
localstack  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/utils.py", line 156, in __call__
localstack  |     result = self.callback(request, request.url, {})
localstack  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_starter.py", line 205, in apigateway_response_integrations
localstack  |     integration_response['timeoutInMillis'] = timeout_milliseconds
localstack  | TypeError: 'NoneType' object does not support item assignment
localstack  | 2021-05-23 04:14:22,219:API: Error on request:
localstack  | Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
localstack  |     execute(self.server.app)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 308, in execute
localstack  |     application_iter = app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 178, in __call__
localstack  |     return backend_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2069, in __call__
localstack  |     return self.wsgi_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2054, in wsgi_app
localstack  |     response = self.handle_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2051, in wsgi_app
localstack  |     response = self.full_dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1501, in full_dispatch_request
localstack  |     rv = self.handle_user_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1499, in full_dispatch_request
localstack  |     rv = self.dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1485, in dispatch_request
localstack  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/utils.py", line 156, in __call__
localstack  |     result = self.callback(request, request.url, {})
localstack  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_starter.py", line 205, in apigateway_response_integrations
localstack  |     integration_response['timeoutInMillis'] = timeout_milliseconds
localstack  | TypeError: 'NoneType' object does not support item assignment
localstack  | 2021-05-23T04:14:23:DEBUG:localstack.utils.cloudformation.template_deployer: Extract resource attribute: ApiGateway::Deployment Ref
localstack  | 2021-05-23T04:14:23:DEBUG:localstack.services.cloudformation.cloudformation_api: Unable to resolve references in stack outputs: {'Value': {'Fn::Join': ['', ['https://', {'Ref': 'DevCustomerApiA279E14E'}, '.execute-api.', {'Ref': 'AWS::Region'}, '.', {'Ref': 'AWS::URLSuffix'}, '/', {'Ref': 'DevCustomerApiDeploymentStageprodE70041CA'}, '/']]}} - Unable to fetch details for resource "DevCustomerApiDeployment2663BF7C9972510c02f7f7a1a55860bb1c9e641c" (attribute "Ref")
localstack  | 2021-05-23T04:14:24:DEBUG:localstack.utils.cloudformation.template_deployer: Error applying changes for CloudFormation stack "CustomerApiStack": An error occurred (500) when calling the PutIntegration operation (reached max retries: 4): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
localstack  | <title>500 Internal Server Error</title>
localstack  | <h1>Internal Server Error</h1>
localstack  | <p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
localstack  |  Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1825, in _run
localstack  |     self.do_apply_changes_in_loop(changes, stack, stack_name)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1876, in do_apply_changes_in_loop
localstack  |     self.apply_change(change, stack, new_resources, stack_name=stack_name)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1929, in apply_change
localstack  |     result = deploy_resource(resource_id, new_resources, stack_name)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 937, in deploy_resource
localstack  |     return execute_resource_action(resource_id, resources, stack_name, ACTION_CREATE)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1041, in execute_resource_action
localstack  |     result = configure_resource_via_sdk(resource_id, resources, resource_type, func, stack_name, action_name)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1167, in configure_resource_via_sdk
localstack  |     run_post_create_actions(action_name, resource_id, resources, resource_type, stack_name, result)
localstack  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1232, in run_post_create_actions
localstack  |     apigateway.put_integration(
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 386, in _api_call
localstack  |     return self._make_api_call(operation_name, kwargs)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 705, in _make_api_call
localstack  |     raise error_class(parsed_response, operation_name)
localstack  | botocore.exceptions.ClientError: An error occurred (500) when calling the PutIntegration operation (reached max retries: 4): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
localstack  | <title>500 Internal Server Error</title>
localstack  | <h1>Internal Server Error</h1>
localstack  | <p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
localstack  |
localstack  |
localstack  | 2021-05-23 04:14:24,721:API: Error on request:
localstack  | Traceback (most recent call last):
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
localstack  |     execute(self.server.app)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 308, in execute
localstack  |     application_iter = app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 178, in __call__
localstack  |     return backend_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2069, in __call__
localstack  |     return self.wsgi_app(environ, start_response)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2054, in wsgi_app
localstack  |     response = self.handle_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2051, in wsgi_app
localstack  |     response = self.full_dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1501, in full_dispatch_request
localstack  |     rv = self.handle_user_exception(e)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
localstack  |     return cors_after_request(app.make_response(f(*args, **kwargs)))
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1499, in full_dispatch_request
localstack  |     rv = self.dispatch_request()
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1485, in dispatch_request
localstack  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
localstack  |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/utils.py", line 156, in __call__
localstack  |     result = self.callback(request, request.url, {})
localstack  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_starter.py", line 205, in apigateway_response_integrations
localstack  |     integration_response['timeoutInMillis'] = timeout_milliseconds
localstack  | TypeError: 'NoneType' object does not support item assignment
localstack  | 2021-05-23T04:14:28:DEBUG:localstack.utils.cloudformation.template_deployer: Extract resource attribute: ApiGateway::Deployment Ref
localstack  | 2021-05-23T04:14:28:DEBUG:localstack.services.cloudformation.cloudformation_api: Unable to resolve references in stack outputs: {'Value': {'Fn::Join': ['', ['https://', {'Ref': 'DevCustomerApiA279E14E'}, '.execute-api.', {'Ref': 'AWS::Region'}, '.', {'Ref': 'AWS::URLSuffix'}, '/', {'Ref': 'DevCustomerApiDeploymentStageprodE70041CA'}, '/']]}} - Unable to fetch details for resource "DevCustomerApiDeployment2663BF7C9972510c02f7f7a1a55860bb1c9e641c" (attribute "Ref")

# Steps to reproduce

## Command used to start LocalStack

version: '3'
services:
  localstack:
    image: localstack/localstack
    container_name: localstack
    network_mode: bridge
    ports:
      - "4566:4566"
      - "4571:4571"
      - '8055:8080'
    environment:
      - SERVICES=s3,dynamodb,lambda,apigateway,cloudformation,iam,sqs,sts
      - DEBUG=1
      - DATA_DIR=/tmp/localstack/data
    volumes:
      - './.localstack:/tmp/localstack'
      - '/var/run/docker.sock:/var/run/docker.sock'

## Client code (AWS SDK code snippet, or sequence of "awslocal" commands)

    const api = new apigw.RestApi(this, 'MyApi', {
          endpointTypes: [EndpointType.REGIONAL]
        });
    
    const bucket = new s3.Bucket(this, 'test-bucket');

    const executeRole = new iam.Role(this, "role", {
      assumedBy: new iam.ServicePrincipal('apigateway.amazonaws.com'),
      path: "/service-role/"
    });

    bucket.grantReadWrite(executeRole);

    const s3Integration = new apigw.AwsIntegration({
      service: 's3',
      integrationHttpMethod: "GET",
      path:  bucket.bucketName + "/test.json",
      options : {
        credentialsRole: executeRole,
        integrationResponses: [{statusCode: '200'}]
      },
    })

    api.root.addMethod("GET",
        s3Integration, {
      methodResponses: [
        {
          statusCode: "200"
        }
      ]});





Discussion:

Resolving patch:
diff --git a/localstack/services/apigateway/apigateway_listener.py b/localstack/services/apigateway/apigateway_listener.py
--- a/localstack/services/apigateway/apigateway_listener.py
+++ b/localstack/services/apigateway/apigateway_listener.py
@@ -18,7 +18,8 @@
 from localstack.services.awslambda import lambda_api
 from localstack.services.apigateway import helpers
 from localstack.services.generic_proxy import ProxyListener
-from localstack.utils.aws.aws_responses import flask_to_requests_response, requests_response, LambdaResponse
+from localstack.utils.aws.aws_responses import (flask_to_requests_response, requests_response, LambdaResponse,
+    request_response_stream)
 from localstack.services.apigateway.helpers import (get_resource_for_path, handle_authorizers, handle_validators,
     handle_accounts, handle_vpc_links, extract_query_string_params, extract_path_params, make_error_response,
     get_cors_response, hande_base_path_mappings)
@@ -33,6 +34,7 @@
 PATH_REGEX_USER_REQUEST = r'^/restapis/([A-Za-z0-9_\-]+)/([A-Za-z0-9_\-]+)/%s/(.*)$' % PATH_USER_REQUEST
 PATH_REGEX_PATH_MAPPINGS = r'/domainnames/([^/]+)/basepathmappings(/.*)?'
 HOST_REGEX_EXECUTE_API = r'(.*://)?([a-zA-Z0-9-]+)\.execute-api\..*'
+TARGET_REGEX_S3_URI = r'^arn:aws:apigateway:[a-zA-Z0-9\-]+:s3:path/(?P<bucket>[^/]+)/(?P<object>.+)$'
 
 # Maps API IDs to list of gateway responses
 GATEWAY_RESPONSES = {}
@@ -425,6 +427,34 @@ def invoke_rest_api_integration(api_id, stage, integration, method, path, invoca
             )
             response.headers['content-type'] = APPLICATION_JSON
             return response
+        elif 's3:path/' in uri and method == 'GET':
+            s3 = aws_stack.connect_to_service('s3')
+            uri_match = re.match(TARGET_REGEX_S3_URI, uri)
+            if uri_match:
+                bucket, object_key = uri_match.group('bucket', 'object')
+                LOGGER.debug('Getting request for bucket %s object %s', bucket, object_key)
+                try:
+                    object = s3.get_object(Bucket=bucket, Key=object_key)
+                except s3.exceptions.NoSuchKey:
+                    msg = 'Object %s not found' % object_key
+                    LOGGER.debug(msg)
+                    return make_error_response(msg, 404)
+
+                headers = aws_stack.mock_aws_request_headers(service='s3')
+
+                if object.get('ContentType'):
+                    headers['Content-Type'] = object['ContentType']
+
+                # stream used so large files do not fill memory
+                response = request_response_stream(
+                    stream=object['Body'],
+                    headers=headers
+                )
+                return response
+            else:
+                msg = 'Request URI does not match s3 specifications'
+                LOGGER.warning(msg)
+                return make_error_response(msg, 400)
 
         if method == 'POST':
             if uri.startswith('arn:aws:apigateway:') and ':sqs:path' in uri:
diff --git a/localstack/utils/aws/aws_responses.py b/localstack/utils/aws/aws_responses.py
--- a/localstack/utils/aws/aws_responses.py
+++ b/localstack/utils/aws/aws_responses.py
@@ -134,6 +134,15 @@ def requests_response(content, status_code=200, headers={}):
     return resp
 
 
+def request_response_stream(stream, status_code=200, headers={}):
+    resp = RequestsResponse()
+    resp.raw = stream
+    resp.status_code = int(status_code)
+    # Note: update headers (instead of assigning directly), to ensure we're using a case-insensitive dict
+    resp.headers.update(headers or {})
+    return resp
+
+
 def flask_to_requests_response(r):
     return requests_response(r.data, status_code=r.status_code, headers=r.headers)
 
diff --git a/localstack/utils/cloudformation/template_deployer.py b/localstack/utils/cloudformation/template_deployer.py
--- a/localstack/utils/cloudformation/template_deployer.py
+++ b/localstack/utils/cloudformation/template_deployer.py
@@ -1244,6 +1244,9 @@ def run_post_create_actions(action_name, resource_id, resources, resource_type,
             if integration.get('RequestTemplates'):
                 kwargs['requestTemplates'] = integration['RequestTemplates']
 
+            if integration.get('Credentials'):
+                kwargs['credentials'] = integration['Credentials']
+
             apigateway.put_integration(
                 restApiId=api_id,
                 resourceId=res_id,


Test patch:
diff --git a/tests/integration/test_api_gateway.py b/tests/integration/test_api_gateway.py
--- a/tests/integration/test_api_gateway.py
+++ b/tests/integration/test_api_gateway.py
@@ -1022,10 +1022,62 @@ def test_api_gateway_http_integration_with_path_request_parmeter(self):
         client.delete_rest_api(restApiId=api_id)
         proxy.stop()
 
+    def test_api_gateway_s3_get_integration(self):
+        apigw_client = aws_stack.connect_to_service('apigateway')
+        s3_client = aws_stack.connect_to_service('s3')
+
+        bucket_name = 'test-bucket'
+        object_name = 'test.json'
+        object_content = '{ "success": "true" }'
+        object_content_type = 'application/json'
+
+        api = apigw_client.create_rest_api(name='test')
+        api_id = api['id']
+
+        s3_client.create_bucket(Bucket=bucket_name)
+        s3_client.put_object(Bucket=bucket_name, Key=object_name, Body=object_content, ContentType=object_content_type)
+
+        self.connect_api_gateway_to_s3(bucket_name, object_name, api_id, 'GET')
+
+        apigw_client.create_deployment(restApiId=api_id, stageName='test')
+        url = gateway_request_url(api_id, 'test', '/')
+        result = requests.get(url)
+        self.assertEqual(result.status_code, 200)
+        self.assertEqual(result.text, object_content)
+        self.assertEqual(result.headers['content-type'], object_content_type)
+        # clean up
+        apigw_client.delete_rest_api(restApiId=api_id)
+        s3_client.delete_object(Bucket=bucket_name, Key=object_name)
+        s3_client.delete_bucket(Bucket=bucket_name)
+
     # =====================================================================
     # Helper methods
     # =====================================================================
 
+    def connect_api_gateway_to_s3(self, bucket_name, file_name, api_id, method):
+        """Connects the root resource of an api gateway to the given object of an s3 bucket.
+
+        """
+        apigw_client = aws_stack.connect_to_service('apigateway')
+        s3_uri = 'arn:aws:apigateway:{}:s3:path/{}/{}'.format(aws_stack.get_region(), bucket_name, file_name)
+
+        test_role = 'test-s3-role'
+        role_arn = aws_stack.role_arn(role_name=test_role)
+        resources = apigw_client.get_resources(restApiId=api_id)
+        # using the root resource '/' directly for this test
+        root_resource_id = resources['items'][0]['id']
+        apigw_client.put_method(
+            restApiId=api_id, resourceId=root_resource_id, httpMethod=method, authorizationType='NONE',
+            apiKeyRequired=False, requestParameters={})
+        apigw_client.put_integration(
+            restApiId=api_id,
+            resourceId=root_resource_id,
+            httpMethod=method,
+            type='AWS',
+            integrationHttpMethod=method,
+            uri=s3_uri,
+            credentials=role_arn)
+
     def connect_api_gateway_to_kinesis(self, gateway_name, kinesis_stream):
         resources = {}
         template = self.APIGATEWAY_DATA_INBOUND_TEMPLATE % kinesis_stream