Repository: localstack/localstack

Issue:
S3 Error Code: NoSuchBucket. S3 Error Message: The specified bucket does not exist
When deploy the services by using serverless-localstack, an error occurs during the updatestack 

```
localstack_main | 2020-03-17T14:10:42:warning:moto: No Moto CloudFormation support for AWS::S3::BucketPolicy
localstack_main | 2020-03-17T14:10:47:warning:localstack.services.awslambda.lambda_api: Function not found: arn:aws:lambda:us-east-1:000000000000:function:sample1-local-downloadFile
localstack_main | 2020-03-17T14:10:47:warning:localstack.services.cloudformation.cloudformation_starter: Unable to extract id for resource IamRoleLambdaExecution: {'Role': {'Path': '/', 'RoleName': 'sample1-local-us-east-1-lambdaRole', 'RoleId': '4uzole7bkp69kfgntgrq', 'Arn': 'arn:aws:iam::000000000000:role/sample1-local-us-east-1-lambdaRole', 'CreateDate': datetime.datetime(2020, 3, 17, 14, 10, 47, 927000, tzinfo=tzlocal()), 'AssumeRolePolicyDocument': {'Version': '2012-10-17', 'Statement': [{'Effect': 'Allow', 'Principal': {'Service': ['lambda.amazonaws.com']}, 'Action': ['sts:AssumeRole']}]}, 'MaxSessionDuration': 3600}, 'ResponseMetadata': {'RequestId': '4a93ceee-9966-11e1-b624-b1aEXAMPLE7c', 'HTTPStatusCode': 200, 'HTTPHeaders': {'server': 'BaseHTTP/0.6 Python/3.8.2', 'date': 'Tue, 17 Mar 2020 14:10:47 GMT', 'content-type': 'text/html; charset=utf-8', 'content-length': '709', 'access-control-allow-origin': '*', 'access-control-allow-methods': 'HEAD,GET,PUT,POST,DELETE,OPTIONS,PATCH', 'access-control-allow-headers': 'authorization,content-type,content-md5,cache-control,x-amz-content-sha256,x-amz-date,x-amz-security-token,x-amz-user-agent,x-amz-target,x-amz-acl,x-amz-version-id,x-localstack-target,x-amz-tagging', 'access-control-expose-headers': 'x-amz-version-id'}, 'RetryAttempts': 0}}
localstack_main | 2020-03-17T14:10:47:warning:localstack.services.awslambda.lambda_api: Function not found: arn:aws:lambda:us-east-1:000000000000:function:sample1-local-downloadFile
localstack_main | 2020-03-17T14:10:48:ERROR:localstack.services.cloudformation.cloudformation_starter: Unable to parse and create resource "DownloadFileLambdaFunction": An error occurred (InvalidParameterValueException) when calling the None operation: Error occurred while GetObject. S3 Error Code: NoSuchBucket. S3 Error Message: The specified bucket does not exist Traceback (most recent call last):
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/s3/models.py", line 1190, in get_bucket
localstack_main |     return self.buckets[bucket_name]
localstack_main | KeyError: '__local__'
localstack_main |
localstack_main | During handling of the above exception, another exception occurred:
localstack_main |
localstack_main | Traceback (most recent call last):
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/awslambda/models.py", line 219, in __init__
localstack_main |     key = s3_backend.get_key(self.code["S3Bucket"], self.code["S3Key"])
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/s3/models.py", line 1323, in get_key
localstack_main |     bucket = self.get_bucket(bucket_name)
localstack_main |   File "/opt/code/localstack/localstack/services/s3/s3_starter.py", line 103, in get_bucket
localstack_main |     return get_bucket_orig(bucket_name, *args, **kwargs)
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/s3/models.py", line 1192, in get_bucket
localstack_main |     raise MissingBucket(bucket=bucket_name)
localstack_main | moto.s3.exceptions.MissingBucket: 404 Not Found: <?xml version="1.0" encoding="UTF-8"?>
localstack_main | <Error>
localstack_main |     <Code>NoSuchBucket</Code>
localstack_main |     <Message>The specified bucket does not exist</Message>
localstack_main |     <BucketName>__local__</BucketName>
localstack_main |     <RequestID>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestID>
localstack_main | </Error>
localstack_main |
localstack_main | During handling of the above exception, another exception occurred:
localstack_main |
localstack_main | Traceback (most recent call last):
localstack_main |   File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 174, in parse_and_create_resource
localstack_main |     return _parse_and_create_resource(logical_id, resource_json,
localstack_main |   File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 242, in _parse_and_create_resource
localstack_main |     raise moto_create_error
localstack_main |   File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 228, in _parse_and_create_resource
localstack_main |     resource = parse_and_create_resource_orig(logical_id,
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 338, in parse_and_create_resource
localstack_main |     resource = resource_class.create_from_cloudformation_json(
localstack_main |   File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 549, in Lambda_create_from_cloudformation_json
localstack_main |     return Lambda_create_from_cloudformation_json_orig(resource_name, cloudformation_json, region_name)
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/awslambda/models.py", line 516, in create_from_cloudformation_json
localstack_main |     fn = backend.create_function(spec)
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/awslambda/models.py", line 822, in create_function
localstack_main |     fn = LambdaFunction(spec, self.region_name, version="$LATEST")
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/awslambda/models.py", line 222, in __init__
localstack_main |     raise InvalidParameterValueException(
localstack_main | moto.awslambda.exceptions.InvalidParameterValueException: An error occurred (InvalidParameterValueException) when calling the None operation: Error occurred while GetObject. S3 Error Code: NoSuchBucket. S3 Error Message: The specified bucket does not exist
```


Discussion:
i have  the same issue !
Looks like this occurs when you're mounting from local. Do you have mountCode: set to true in your localStack properties in your serverless.yaml?

This also happens to me with and without the `mountCode` flag.

This is on OS X Catalina 10.15.4

Bringing up the containers with

```sh
TMPDIR=/private$TMPDIR docker-compose up
```
I'm having the same issue, I've already documented what I tried at:
https://github.com/localstack/serverless-localstack/issues/80#issuecomment-605370721

And since I've also tried changing the way I'm launching localstack such as not using a `DATA_DIR` and not mounting `/tmp/localstack`, running it locally on OSX instead of on Ubuntu 19.04, but no luck, I keep getting next error message:
```
localstack_main | 2020-03-28T01:25:53:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "DescribeStacks" (400) POST /: b'<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">\n  <Error>\n    <Type>Sender</Type>\n    <Code>ValidationError</Code>\n    <Message>Stack with id simplelambdatest-local does not exist</Message>\n  </Error>\n  <RequestId>cf4c737e-5ae2-11e4-a7c9-ad44eEXAMPLE</RequestId>\n</ErrorResponse>'
localstack_main | 2020-03-28T01:25:53:DEBUG:localstack.services.cloudformation.cloudformation_starter: Currently processing stack resource simplelambdatest-local/ServerlessDeploymentBucket: None
localstack_main | 2020-03-28T01:25:53:DEBUG:localstack.services.cloudformation.cloudformation_starter: Deploying CloudFormation resource (update=False, exists=False, updateable=False): {'Type': 'AWS::S3::Bucket', 'Properties': {'BucketEncryption': {'ServerSideEncryptionConfiguration': [{'ServerSideEncryptionByDefault': {'SSEAlgorithm': 'AES256'}}]}, 'BucketName': 'simplelambdatest-local-ServerlessDeploymentBucket-9XWTD856LNSQ'}}
localstack_main | 2020-03-28T01:25:53:DEBUG:localstack.utils.cloudformation.template_deployer: Running action "create" for resource type "S3::Bucket" id "ServerlessDeploymentBucket"
localstack_main | 2020-03-28T01:25:53:DEBUG:localstack.utils.cloudformation.template_deployer: Request for resource type "S3::Bucket" in region us-east-1: create_bucket {'Bucket': 'simplelambdatest-local-ServerlessDeploymentBucket-9XWTD856LNSQ', 'ACL': 'public-read', 'CreateBucketConfiguration': {'LocationConstraint': 'us-east-1'}}
localstack_main | 2020-03-28T01:25:53:DEBUG:localstack.services.cloudformation.cloudformation_starter: Currently processing stack resource simplelambdatest-local/ServerlessDeploymentBucketPolicy: None
localstack_main | 2020-03-28T01:25:53:WARNING:moto: No Moto CloudFormation support for AWS::S3::BucketPolicy
localstack_main | 2020-03-28T01:25:53:DEBUG:localstack.services.cloudformation.cloudformation_starter: Running CloudFormation stack deployment loop iteration 1
localstack_main | 2020-03-28T01:25:58:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "DescribeStackEvents" (400) POST /: b'<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">\n  <Error>\n    <Type>Sender</Type>\n    <Code>ValidationError</Code>\n    <Message>Unable to find stack "simplelambdatest-local" in region us-east-1</Message>\n  </Error>\n  <RequestId>cf4c737e-5ae2-11e4-a7c9-ad44eEXAMPLE</RequestId>\n</ErrorResponse>'
localstack_main | 2020-03-28T01:25:58:ERROR:localstack.services.generic_proxy: Error forwarding request: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1 Traceback (most recent call last):
localstack_main |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 247, in forward
localstack_main |     listener_result = listener.forward_request(method=method,
localstack_main |   File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_listener.py", line 208, in forward_request
localstack_main |     tmp = client.describe_stack_events(StackName=stack_name)['StackEvents'][:1]
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 316, in _api_call
localstack_main |     return self._make_api_call(operation_name, kwargs)
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 626, in _make_api_call
localstack_main |     raise error_class(parsed_response, operation_name)
localstack_main | botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1
localstack_main | 
localstack_main | 2020-03-28T01:25:58:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "DescribeStackEvents" (400) POST /: b'<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">\n  <Error>\n    <Type>Sender</Type>\n    <Code>ValidationError</Code>\n    <Message>Unable to find stack "simplelambdatest-local" in region us-east-1</Message>\n  </Error>\n  <RequestId>cf4c737e-5ae2-11e4-a7c9-ad44eEXAMPLE</RequestId>\n</ErrorResponse>'
localstack_main | 2020-03-28T01:25:58:ERROR:localstack.services.generic_proxy: Error forwarding request: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1 Traceback (most recent call last):
localstack_main |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 247, in forward
localstack_main |     listener_result = listener.forward_request(method=method,
localstack_main |   File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_listener.py", line 208, in forward_request
localstack_main |     tmp = client.describe_stack_events(StackName=stack_name)['StackEvents'][:1]
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 316, in _api_call
localstack_main |     return self._make_api_call(operation_name, kwargs)
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 626, in _make_api_call
localstack_main |     raise error_class(parsed_response, operation_name)
localstack_main | botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1
localstack_main | 
localstack_main | 2020-03-28T01:25:59:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "DescribeStackEvents" (400) POST /: b'<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">\n  <Error>\n    <Type>Sender</Type>\n    <Code>ValidationError</Code>\n    <Message>Unable to find stack "simplelambdatest-local" in region us-east-1</Message>\n  </Error>\n  <RequestId>cf4c737e-5ae2-11e4-a7c9-ad44eEXAMPLE</RequestId>\n</ErrorResponse>'
localstack_main | 2020-03-28T01:25:59:ERROR:localstack.services.generic_proxy: Error forwarding request: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1 Traceback (most recent call last):
localstack_main |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 247, in forward
localstack_main |     listener_result = listener.forward_request(method=method,
localstack_main |   File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_listener.py", line 208, in forward_request
localstack_main |     tmp = client.describe_stack_events(StackName=stack_name)['StackEvents'][:1]
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 316, in _api_call
localstack_main |     return self._make_api_call(operation_name, kwargs)
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 626, in _make_api_call
localstack_main |     raise error_class(parsed_response, operation_name)
localstack_main | botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1
localstack_main | 
localstack_main | 2020-03-28T01:25:59:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "DescribeStackEvents" (400) POST /: b'<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">\n  <Error>\n    <Type>Sender</Type>\n    <Code>ValidationError</Code>\n    <Message>Unable to find stack "simplelambdatest-local" in region us-east-1</Message>\n  </Error>\n  <RequestId>cf4c737e-5ae2-11e4-a7c9-ad44eEXAMPLE</RequestId>\n</ErrorResponse>'
localstack_main | 2020-03-28T01:25:59:ERROR:localstack.services.generic_proxy: Error forwarding request: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1 Traceback (most recent call last):
localstack_main |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 247, in forward
localstack_main |     listener_result = listener.forward_request(method=method,
localstack_main |   File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_listener.py", line 208, in forward_request
localstack_main |     tmp = client.describe_stack_events(StackName=stack_name)['StackEvents'][:1]
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 316, in _api_call
localstack_main |     return self._make_api_call(operation_name, kwargs)
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 626, in _make_api_call
localstack_main |     raise error_class(parsed_response, operation_name)
localstack_main | botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1
localstack_main | 
localstack_main | 2020-03-28T01:26:05:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "DescribeStackEvents" (400) POST /: b'<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">\n  <Error>\n    <Type>Sender</Type>\n    <Code>ValidationError</Code>\n    <Message>Unable to find stack "simplelambdatest-local" in region us-east-1</Message>\n  </Error>\n  <RequestId>cf4c737e-5ae2-11e4-a7c9-ad44eEXAMPLE</RequestId>\n</ErrorResponse>'
localstack_main | 2020-03-28T01:26:05:ERROR:localstack.services.generic_proxy: Error forwarding request: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1 Traceback (most recent call last):
localstack_main |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 247, in forward
localstack_main |     listener_result = listener.forward_request(method=method,
localstack_main |   File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_listener.py", line 208, in forward_request
localstack_main |     tmp = client.describe_stack_events(StackName=stack_name)['StackEvents'][:1]
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 316, in _api_call
localstack_main |     return self._make_api_call(operation_name, kwargs)
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 626, in _make_api_call
localstack_main |     raise error_class(parsed_response, operation_name)
localstack_main | botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1
localstack_main | 
localstack_main | 2020-03-28T01:26:05:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "DescribeStackEvents" (400) POST /: b'<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">\n  <Error>\n    <Type>Sender</Type>\n    <Code>ValidationError</Code>\n    <Message>Unable to find stack "simplelambdatest-local" in region us-east-1</Message>\n  </Error>\n  <RequestId>cf4c737e-5ae2-11e4-a7c9-ad44eEXAMPLE</RequestId>\n</ErrorResponse>'
localstack_main | 2020-03-28T01:26:05:ERROR:localstack.services.generic_proxy: Error forwarding request: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1 Traceback (most recent call last):
localstack_main |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 247, in forward
localstack_main |     listener_result = listener.forward_request(method=method,
localstack_main |   File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_listener.py", line 208, in forward_request
localstack_main |     tmp = client.describe_stack_events(StackName=stack_name)['StackEvents'][:1]
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 316, in _api_call
localstack_main |     return self._make_api_call(operation_name, kwargs)
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 626, in _make_api_call
localstack_main |     raise error_class(parsed_response, operation_name)
localstack_main | botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the DescribeStackEvents operation: Unable to find stack "simplelambdatest-local" in region us-east-1
localstack_main | 
```

I'd be okay trying out some thing so let me know what else I can try!
Having the same issue!  However I can work around it temporarily by using localstack/localstack:0.10.8. 


Resolving patch:
diff --git a/localstack/services/s3/s3_starter.py b/localstack/services/s3/s3_starter.py
--- a/localstack/services/s3/s3_starter.py
+++ b/localstack/services/s3/s3_starter.py
@@ -12,6 +12,7 @@
 from localstack.services.s3 import s3_listener
 from localstack.utils.common import wait_for_port_open
 from localstack.services.infra import start_moto_server
+from localstack.services.awslambda.lambda_api import BUCKET_MARKER_LOCAL
 
 LOG = logging.getLogger(__name__)
 
@@ -101,6 +102,8 @@ def create_bucket(self, bucket_name, region_name, *args, **kwargs):
     # patch S3Bucket.get_bucket(..)
     def get_bucket(self, bucket_name, *args, **kwargs):
         bucket_name = s3_listener.normalize_bucket_name(bucket_name)
+        if bucket_name == BUCKET_MARKER_LOCAL:
+            return None
         return get_bucket_orig(bucket_name, *args, **kwargs)
 
     get_bucket_orig = s3_models.s3_backend.get_bucket


Test patch: