Ask Your Question
0

Is there a way to reference resources in separate stack except by uuid?

asked 2014-10-03 14:20:49 -0500

Heather gravatar image

Is there any intention to add a function in the template (or maybe it exists and I have missed it) to allow the orchestrator to query the api from within the HOT document? We anticipate having some very large and complex ecommerce environments. Managing all that from a single HOT document may get a little unwieldy.

When working within the template it is easy enough to reference things you need for the various resource services using get_resource: the_resource. If I have two templates, let's say one is for the full size web experience and the other manages the mobile part of my application, and I need to cross reference between the two for shared resources then I have to resort to knowing the uuid's for those resources if they did not originate in my template. I can't reference them by an easily remembered name. I understand the reason for this is that the resource-name namespace is not guaranteed to be unique (unless, maybe, at the stack level?). Yet in very large projects it would be very nice to be able to reference resources created outside the template by a name rather than a uuid.

Maybe this exists and I've just overlooked it (wouldn't be the 10th time :-) ). It would be nice to have something like:

get_resource: {namespace}:resource-name

We've considered creating some sort of pre-compiler for the HOT doc to do something like this and enforce the namespace ourselves.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-10-06 08:17:08 -0500

zaneb gravatar image

You can break your template down into separate templates that form a tree using what we call nested stacks. The easiest way is probably to use "provider templates", where you set the URL of another template as the resource type for a resource. That resource's properties then become parameters to the nested stack, and you can access the nested stack's outputs in the parent template using the get_attr intrinsic function. So you encapsulate a bunch of resources inside a stack and only export the connection points as outputs, then wire things together in the parent stack. The Python client handles uploading all of the templates simultaneously via the 'files' key in the API.

(There is also an AWS::CloudFormation::Stack resource type that just takes a URL - so your template needs to be posted somewhere that Heat can access - and has a 'Parameters' property. Coming soon: an OS::Heat::Stack equivalent.)

So in your particular case you might have a top-level template that contains three resources - a mobile app stack, a web app stack and a 'shared' stack - that passes outputs from the shared stack as parameters to the other two. Or maybe the shared stuff would exist directly in the top-level stack.

edit flag offensive delete link more

Comments

This is the same technique where you can declare a resource for an AutoScalingGroup in a .template or .yaml file?

Heather gravatar imageHeather ( 2014-10-06 08:50:20 -0500 )edit

Essentially, yes.

zaneb gravatar imagezaneb ( 2014-10-06 08:52:16 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2014-10-03 14:20:49 -0500

Seen: 865 times

Last updated: Oct 06 '14