get_attr

The get_attr function references the attribute value of an instantiated resource.

The name of an attribute defined for the resource type must be specified.

get_attr:
  - <resource ID>
  - <attribute name>
  - <key/index 1>
  - <key/index 2>
  - ...
Element Required Description
<resource ID> Yes Resources SectionSpecifies a resource ID defined in the Resources Section.
<attribute name> Yes Specifies the name of an attribute for which you want to reference the value. The name of the attribute defined for the resource type can be used.
<key/index 1,2,..> No Specifies the key or index for obtaining data, when the attribute is a list or hash.

Example specification of the get_attr function:

resources:
  my_instance:
    type: OS::Nova::Server

outputs:
  instance_ip:
    description: IP address of the deployed compute instance
    value: { get_attr: [my_instance, first_address] }
  instance_private_ip:
    description: Private IP address of the deployed compute instance
    value: { get_attr: [my_instance, networks, private, 0] }

In this example, the networks attribute holds data such as the following.

{"public": ["2001:0db8:0000:0000:0000:ff00:0042:8329", "1.2.3.4"],
"private": ["10.0.0.1"]}

In the above example, the "instance_private_ip" value in the outputs section is "10.0.0.1".