Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
fix CF unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
whummer committed Feb 6, 2020
1 parent 4b14cb2 commit ae1da5b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions localstack/utils/cloudformation/template_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,13 @@ def resolve_ref(stack_name, ref, resources, attribute):
return aws_stack.get_region()
if ref == 'AWS::Partition':
return 'aws'

# first, check stack parameters
stack_param = get_stack_parameter(stack_name, ref)
if stack_param is not None:
return stack_param

# second, resolve resource references
resource_status = {}
if stack_name:
resource_status = describe_stack_resource(stack_name, ref)
Expand Down Expand Up @@ -645,14 +652,8 @@ def resolve_refs_recursively(stack_name, value, resources):
keys_list = list(value.keys())
# process special operators
if keys_list == ['Ref']:
# first, check stack parameters
stack_param = get_stack_parameter(stack_name, value['Ref'])
if stack_param is not None:
return stack_param
# second, resolve resource references
result = resolve_ref(stack_name, value['Ref'],
return resolve_ref(stack_name, value['Ref'],
resources, attribute='PhysicalResourceId')
return result
if keys_list and keys_list[0].lower() == 'fn::getatt':
return resolve_ref(stack_name, value[keys_list[0]][0],
resources, attribute=value[keys_list[0]][1])
Expand All @@ -679,8 +680,11 @@ def resolve_refs_recursively(stack_name, value, resources):


def get_stack_parameter(stack_name, parameter):
client = aws_stack.connect_to_service('cloudformation')
stack = client.describe_stacks(StackName=stack_name)['Stacks']
try:
client = aws_stack.connect_to_service('cloudformation')
stack = client.describe_stacks(StackName=stack_name)['Stacks']
except Exception:
return None
stack = stack and stack[0]
if not stack:
return None
Expand Down

0 comments on commit ae1da5b

Please sign in to comment.