Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embedded resolvers - resolver ouput as entry paramter for another resolver #1258

Closed
tbensalem-bkom opened this issue Oct 4, 2022 · 3 comments

Comments

@tbensalem-bkom
Copy link

Subject of the issue

I have been trying to run embedded resolvers, to be exact I want to have a resolver output as input for another resolver.
I have described how I have implemented that below.

parameters:
   Param1: !CustomResolver1
      parameter1: !stack_output stack::output1
      parameter2: !stack_output stack::output2

Your environment

  • version of sceptre (3.1.0)
  • version of python (3.9.1)
  • which OS/distro (Windows)

Expected behavior

I'm expecting the !stack_output stack::output1 and !stack_output stack::output2 to get resolved first than output it send to the upper-level function !CustomResolver1

Actual behavior

it does not work

@zaro0508
Copy link
Contributor

zaro0508 commented Oct 4, 2022

I don't think resolvers work that way or at least I do not know of an embedded resolvers feature. Is there something in the docs or code that makes you think sceptre will execute resolvers within a resolver context?

Once a resolver is triggered for Param1: !CustomResolver1 it will execute the code in CustomResolver1, if additional resolvers need to be handled then the code in CustomResolver1 must handle processing of the embedded resolvers. I don't believe sceptre handles embedded for you.

@jfalkenstein
Copy link
Contributor

Hi @tbensalem-bkom, what you're trying to do isn't exactly how resolvers work (but there's a way to get it to work!).

Take a look here: https://github.com/Sceptre/sceptre/blob/master/sceptre/stack.py#L108

The way resolvers work that they need to be added to ResolvableProperty (which are Python descriptors), which automates a lot of the machinery around making them work like "magic". When you pass a resolver as a custom resolver's arguments, you won't have access to the magic and instead will receive instances of the StackOutput resolver.

Take a look at the base class of resolvers here, though. There's a way to make this work, but it will require changing your Custom resolver's code: https://github.com/Sceptre/sceptre/blob/master/sceptre/resolvers/__init__.py#L24

Imagine this in your custom resolver's code

def setup(self):
    for key, value in self.argument.items():
        # You need to propagate the top-level resolver's stack to the inner resolver and then invoke setup on them
        if isinstance(value, Resolver):
            value.stack = self.stack
            value.setup()

def resolve(self):
    for key, value in self.argument.items():
        if isinstance(value, Resolver):
            self.argument[key] = value.resolve()

That should probably work for you, though that is a bit clumsy.

@zaro0508
Copy link
Contributor

zaro0508 commented Apr 18, 2023

This is fixed with PR #1313 and available in sceptre v4.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants