Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using local environment variables in heat template

I want to create an instance that can hit the same API endpoints as I am using create my stack. These endpoints could vary from usage to usage, but they will always be the same as the ones I use to create the instance. As a result I would like to automatically put my credentials (OS_AUTH_URL etc) into my template to inject them into the instance via cloud-init.

How can I do something like:

Parameters :
  os_auth_url :
    default: env[OS_AUTH_URL]
  os_username :
    default: env[OS_AUTH_URL]


Resources :
…
      user_data:
        str_replace:
          "%os_auth_url%": {get_param: os_auth_url }
          "%os_username%": {get_param: os_username }

        template: |
          #cloud-config
          write_files:
          - content: |
              export OS_AUTH_URL=%os_auth_url%
              export OS_USERNAME=%os_username%
            path: /home/cloud/authcreds.rc

At the moment, my solution is to create a template.in that I then pass through sed to create my actual template. Is there a way I can do this natively in Heat?