Skip to content

Commit

Permalink
Fix --ignore-dependencies with stack_output
Browse files Browse the repository at this point in the history
This commit fixes an issue where a users attempts to launch a single
stack that utilises the `stack_output_resolver` with the
`--ignore-dependencies`.

Previously, with `--ignore-dependencies` set, any dependencies that arose
through `!stack_output_resolver` would not be added to
`stack.dependencies` and the `next()` function in
`StackOutput.resolve()` would raise a `StopIteration` as the
stack.dependencies list would be empty.

This commit handles the stack_output by utilising the argument passed
into `stack_output`.

[Resolves Sceptre#778]
  • Loading branch information
ngfgrant authored and bwchhibber committed Aug 20, 2019
1 parent 35b3a92 commit c14e44a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
8 changes: 8 additions & 0 deletions integration-tests/features/stack-output-resolver.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 30 additions & 7 deletions sceptre/resolvers/stack_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c14e44a

Please sign in to comment.