diff --git a/integration-tests/features/stack-output-resolver.feature b/integration-tests/features/stack-output-resolver.feature index 8f7932161..f97ff467b 100644 --- a/integration-tests/features/stack-output-resolver.feature +++ b/integration-tests/features/stack-output-resolver.feature @@ -7,6 +7,14 @@ Feature: Stack output resolver When the user launches stack "6/1/B" Then stack "6/1/B" exists in "CREATE_COMPLETE" state + Scenario: launch a stack referencing an output of existing stack with ignore dependencies + Given stack "6/1/A" exists using "dependencies/independent_template.json" + and stack "6/1/B" does not exist + and stack "6/1/C" does not exist + When the user launches stack "6/1/B" with ignore dependencies + Then stack "6/1/B" exists in "CREATE_COMPLETE" state + And stack "6/1/C" does not exist + Scenario: launch a stack referencing an output of a non-existant stack Given stack "6/1/B" does not exist and stack "6/1/A" does not exist diff --git a/sceptre/resolvers/stack_output.py b/sceptre/resolvers/stack_output.py index c3594497b..6b89cb099 100644 --- a/sceptre/resolvers/stack_output.py +++ b/sceptre/resolvers/stack_output.py @@ -121,16 +121,39 @@ def resolve(self): """ self.logger.debug("Resolving Stack output: {0}".format(self.argument)) - friendly_stack_name = self.dependency_stack_name.replace(TEMPLATE_EXTENSION, "") + if self.stack.dependencies: + friendly_stack_name = self.dependency_stack_name.replace( + TEMPLATE_EXTENSION, "") - stack = next( - stack for stack in self.stack.dependencies if stack.name == friendly_stack_name - ) + stack = next( + stack for stack in self.stack.dependencies + if stack.name == friendly_stack_name + ) - stack_name = "-".join([stack.project_code, friendly_stack_name.replace("/", "-")]) + stack_name = "-".join([ + stack.project_code, + friendly_stack_name.replace("/", "-") + ]) - return self._get_output_value(stack_name, self.output_key, - profile=stack.profile, region=stack.region) + return self._get_output_value( + stack_name, + self.output_key, + profile=stack.profile, + region=stack.region + ) + else: + dep_stack_name, self.output_key = self.argument.split("::") + friendly_stack_name = dep_stack_name.replace(TEMPLATE_EXTENSION, "") + stack_name = "-".join([ + self.stack.project_code, + friendly_stack_name.replace("/", "-") + ]) + return self._get_output_value( + stack_name, + self.output_key, + profile=self.stack.profile, + region=self.stack.region + ) class StackOutputExternal(StackOutputBase):