Question: Join Resolver output with additional strings possible?
sopeters opened this issue · 1 comments
I'm wondering how you can use resolver outputs with some additional strings - e.g. use the stack_output and use some additional strings to attach / join them with. Can Jinja2 be use for this?
Usecase for example is to build a connection string (host:hostname:port?option=A), e.g.
parameters:
paramA: host:!stack_output <stack_name>::output:1234?option=A
Dose the new stack_attr help here, e.g.
host_endpoint: !stack_output <stack_name>::output
parameters:
paramA: host:{{ stack_attr.host_endpoint }}:1234?option=A
Hey @sopeters, this seems similar to #1165, although that one is more about taking the output of one resolver and passing it as the input of another. Take a look at my comments there on the feasibility of using Jinja. It would be illuminating to see Sceptre docs on the order of resolution of values and distinction between "Render Time" and "Resolve Time" that follows it.
The approach I outlined here for using !pipe
and then sequentially resolving the values from other resolvers could be a viable pattern for your idea.
I'm thinking syntax something like this:
parameters:
# I'm shamelessly ripping off CloudFormation here...
ConnectionString: !sub # use a list argument to the resolver
- "${hostname}:${port}"
- hostname: !stack_output my/stack::hostname
port: !stack_output my/other/stack::port
You would need to experiment with this. You'd like need the !sub
resolver's setup()
method to find the resolvers in the second list element's dict's values and set the stack on those and then invoke setup on those, otherwise, you wouldn't get the dependency modifications that normally come with !stack_output
.
Anyway, I see your idea as being quite viable. I think !join
could be useful, though !sub
could be even more useful, IMO. It would be paving a somewhat new pattern, but it's one we've already been discussing. If you wanted to put together a PR, I'd be happy to work with you to get it to a state of viability and get it released.