-
Notifications
You must be signed in to change notification settings - Fork 0
Using Heat API with Boto
Boto is a Python package that provides interfaces to Amazon Web Services. It supports all services including the CloudFormations API, we need to interact with by Heat API.
http://docs.pythonboto.org/en/latest/ref/cloudformation.html
The latest version of 'boto' will not work(!), because they now use newer AWS signature (v2) which is not (yet) supported by Heat. Also the older version (2.4.x) will not work as well, because it lacks support for setting the 'host' for CloudFormations server. However, you can use pip
to install the right version (and we can add the version to tox environment):
$ pip install "boto==2.5.2"
Boto use the ~/.boto
config file to store settings. I'm pretty much sure we can override the location and store it in tuskar/etc/boto.conf
. For testing, just use the ~/.boto
:
[Boto]
cfn_region_name = heat
cfn_region_endpoint = HEAT_SERVER_HOSTNAME
debug = True
is_secure = False
[Credentials]
aws_access_key_id = EC2_KEY
aws_secret_access_key = EC2_SECRET
The 'HEAT_SERVER_HOSTNAME' is the domain name or IP address of the Heat API server (without 'http' !). The credentials must be generated on the Heat server:
$ source /root/keystonerc_admin
$ keystone ec2-credentials-create
+-----------+----------------------------------+
| Property | Value |
+-----------+----------------------------------+
| access | EC_KEY |
| secret | EC2_SECRET |
| tenant_id | 3661d05ad41e493fbcdec6826b9a7ba3 |
| user_id | 4b7f47864e4948aaa16fdbcf774f8358 |
+-----------+----------------------------------+
Note, the ec2-credentials-create
command will use the current keystone user_id (OS_USERNAME=admin in keystonerc_admin), if you want to create credentials for other user, you need to change the keystonerc_admin
file.
from boto.cloudformation import CloudFormationConnection
# FIXME: The 'port' and 'path' should be stored in config file...
conn = CloudFormationConnection(port=8000, path='/v1')
print conn.list_stacks()