2

Say I want to name a a resource based on 2 variables so I have something like:

heat_template_version: 2013-05-23

description: Create network with

parameters:
  client_code:
    type: string
    description: 4 character customer code. Will be used for instance naming
  project_code:
    type: string
    description: 3 character project code

Now I would like to create resource with the name based on the client and project:

resources:
  test:
    type: OS::Neutron::Net
    properties:
      name: {get_param: client_code}{get_param: project_code}

That resource creation gives me a parse error. Is there anyway I can achieve this, or do I need to use a pre-script to generate my template?

2 Answers 2

5

I found a solution using 'list_join':

heat_template_version: 2013-05-23

  int_network:
    type: OS::Neutron::Net
    properties:
    name:
       list_join: ['-', [ {get_param: tenant}, 'net']]
5

I found a solution using str_replace. My code looks something like:

heat_template_version: 2013-05-23

description: Create network with

parameters:
  client_code:
    type: string
    description: 4 character customer code. Will be used for instance naming
  project_code:
    type: string
    description: 3 character project code

resources:
  test:
    type: OS::Neutron::Net
    properties:
      name:
        str_replace:
        template: cust%-proj%
        params:
          "cust%": { get_param: client_code } 
          "proj%": { get_param: project_code }
3
  • doesn't always work e.g. when working with OS::Neutron::Net attribute value_specs, instead I had to use list_join May 3, 2018 at 7:11
  • @JonasLibbrecht My answer is 3 years old, it is quite feasible that it no longer accurate May 4, 2018 at 14:47
  • As I am testing this on OSP Newton stable, that is at least 2 years old, your answer seems to be invalid May 5, 2018 at 16:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .