Skip to content

Commit

Permalink
fix default region for CF; fix error in Lambda log creation (localsta…
Browse files Browse the repository at this point in the history
  • Loading branch information
whummer authored Oct 29, 2019
1 parent ee93f83 commit 0474179
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion localstack/services/awslambda/lambda_executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def _store_logs(self, func_details, log_output, invocation_time):
if 'ResourceAlreadyExistsException' in str(e):
# this can happen in certain cases, possibly due to a race condition
pass
raise e
else:
raise e

# create a new log stream for this lambda invocation
logs_client.create_log_stream(logGroupName=log_group_name, logStreamName=log_stream_name)
Expand Down
12 changes: 10 additions & 2 deletions localstack/services/cloudformation/cloudformation_starter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import json
import logging
import traceback
import six
Expand All @@ -16,7 +17,7 @@
from moto.cloudformation.exceptions import ValidationError, UnformattedGetAttTemplateException
from localstack import config
from localstack.constants import DEFAULT_PORT_CLOUDFORMATION_BACKEND, TEST_AWS_ACCOUNT_ID, MOTO_ACCOUNT_ID
from localstack.utils.aws import aws_stack
from localstack.utils.aws import aws_stack, aws_responses
from localstack.utils.common import FuncThread, short_uid, recurse_object, clone, json_safe
from localstack.stepfunctions import models as sfn_models
from localstack.services.infra import (
Expand Down Expand Up @@ -557,6 +558,14 @@ def describe_stack_resource(self):
stack_name = self._get_param('StackName')
stack = self.cloudformation_backend.get_stack(stack_name)
logical_resource_id = self._get_param('LogicalResourceId')
if not stack:
msg = ('Unable to find CloudFormation stack "%s" in region %s' %
(stack_name, aws_stack.get_region()))
if aws_stack.get_region() != self.region:
msg = '%s/%s' % (msg, self.region)
LOG.warning(msg)
response = aws_responses.flask_error_response(msg, code=404, error_type='ResourceNotFoundException')
return 404, response.headers, response.data

for stack_resource in stack.stack_resources:
# Note: Line below has been patched
Expand All @@ -577,7 +586,6 @@ def describe_stack_resource(self):
def inject_stats_endpoint():
""" Inject a simple /_stats endpoint into the moto server backend Web app. """
# TODO: move this utility method to a shared file and enable it for all API endpoints
import json
from moto import server as moto_server

def _get_stats():
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ flask-cors==3.0.3
flask_swagger==0.2.12
forbiddenfruit==0.1.3
jsonpath-rw==1.4.0
localstack-ext[full]>=0.10.2
localstack-ext>=0.10.2 #basic-lib
localstack-ext[full]>=0.10.51
localstack-ext>=0.10.51 #basic-lib
localstack-client>=0.14 #basic-lib
moto-ext>=1.3.14.2
nose>=1.3.7
Expand Down

0 comments on commit 0474179

Please sign in to comment.