1

I want to create multiple copies of some resources defined in a template. How do I retrieve the attributes of the resources created in this fashion.

To illustrate, here is a template to create a random string (I call word.yaml):

heat_template_version: rocky

resources:
  word:
    type: OS::Heat::RandomString

Because I want a list of such random strings, I use an OS::Heat::ResourceGroup calling the template from word.yaml:

heat_template_version: rocky

resources:
  composition:
    type: OS::Heat::ResourceGroup
    properties:
      count: 2
      resource_def:
        type: word.yaml

outputs:
  composition:
    value: {get_attr: [composition, resource.word]}

Rubbing together the explanation of OS::Heat::ResourceGroup (ResourceGroup) and the template composition documentation (nested attributes), I expected a list of strings in my output, yet I get:

{
  "outputs": [
    {
      "output_key": "composition",
      "description": "No description given",
      "output_error": "Member 'word' not found in group resource 'composition'.",
      "output_value": null
    }
  ]
}

What am I missing about the interaction of the resource group and the template composition?

Frank
  • 21
  • 4

1 Answers1

1

Found the answer: I need to specify the attribute to retrieve as outpus of the composition. So the word.yaml would look like this:

heat_template_version: rocky

resources:
  word:
    type: OS::Heat::RandomString
outputs:
  word:
    description: the word
    value: {get_attr: [word]}

And the composition, like so:

heat_template_version: rocky

resources:
  composition:
    type: OS::Heat::ResourceGroup
    properties:
      count: 2
      resource_def:
        type: word.yaml

outputs:
  composition:
    value: {get_attr: [composition, word]}

Yielding the expected output:

  {
    "output_key": "composition",
    "description": "No description given",
    "output_value": [
      {
        "value": "gB7ZcXgNjJlEtf8N47yFCOQyH0a1bb9c"
      },
      {
        "value": "wXN4jAKgPqbf5i3GDR6qMkzfC7jF0xdC"
      }
    ]
  }
Frank
  • 21
  • 4