Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I know this a quite old but when searching google for heat template existing keypair this question is the top result, so hopefully this answer will help some people out.

This is my existing key ~ > supernova mynova keypair-list [SUPERNOVA] Running nova against mynova... +----------+-------------------------------------------------+ | Name | Fingerprint | +----------+-------------------------------------------------+ | Public01 | 1a:f7:c0:be:00:f0:eb:7f:90:61:cc:7c:4d:1c:b9:79 | +----------+-------------------------------------------------+

In the template I set a parameter called this 'KeyName' and set a custom constraint to ensure that this resource exists in the backend, the rest is the optional and makes it look good in the control panel

parameters: KeyName: type: string default: Public01 description: Name of an existing key pair to use for the instance constraints: - custom_constraint: nova.keypair description: Must name a public key (pair) known to Nova Then simply retrieve the paramater when creating the server as you would any other parameter.

resources: server: type: "OS::Nova::Server" properties: name: { get_param: "OS::stack_name" } flavor: { get_param: server_flavor } image: { get_param: server_image } key_name: { get_param: KeyName }

I know this a quite old but when searching google for heat template existing keypair this question is the top result, so hopefully this answer will help some people out.

This is my existing key key

 ~ > supernova mynova keypair-list
[SUPERNOVA] Running nova against mynova...
+----------+-------------------------------------------------+
| Name     | Fingerprint                                     |
+----------+-------------------------------------------------+
| Public01 | 1a:f7:c0:be:00:f0:eb:7f:90:61:cc:7c:4d:1c:b9:79 |
+----------+-------------------------------------------------+

In the template I set a parameter called this 'KeyName' and set a custom constraint to ensure that this resource exists in the backend, the rest is the optional and makes it look good in the control panel

parameters:
   KeyName:
    type: string
    default: Public01
    description: Name of an existing key pair to use for the instance
    constraints:
      - custom_constraint: nova.keypair
        description: Must name a public key (pair) known to Nova
 Nova

Then simply retrieve the paramater when creating the server as you would any other parameter.

resources:  server:
    type: "OS::Nova::Server"
    properties:
      name: { get_param: "OS::stack_name" }
      flavor: { get_param: server_flavor }
      image: { get_param: server_image }
      key_name: { get_param: KeyName }

I know this a quite old but when searching google for heat template existing keypair this question is the top result, so hopefully this answer will help some people out.

This is my existing key

 ~ > supernova mynova keypair-list
[SUPERNOVA] Running nova against mynova...
+----------+-------------------------------------------------+
| Name     | Fingerprint                                     |
+----------+-------------------------------------------------+
| Public01 | 1a:f7:c0:be:00:f0:eb:7f:90:61:cc:7c:4d:1c:b9:79 |
+----------+-------------------------------------------------+

In the template I set a parameter called this 'KeyName' and set a custom constraint to ensure that this resource exists in the backend, the rest is the optional and makes it look good in the control panel

parameters:
   KeyName:
    type: string
    default: Public01
    description: Name of an existing key pair to use for the instance
    constraints:
      - custom_constraint: nova.keypair
        description: Must name a public key (pair) known to Nova

Then simply retrieve the paramater parameter when creating the server as you would any other parameter.

resources:   server:
    type: "OS::Nova::Server"
    properties:
      name: { get_param: "OS::stack_name" }
      flavor: { get_param: server_flavor }
      image: { get_param: server_image }
      key_name: { get_param: KeyName }