Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Making block_devices non mandatory in EC2 block definition.
Browse files Browse the repository at this point in the history
This fixes #3
  • Loading branch information
lukaszraczylo committed Apr 13, 2015
1 parent 78707b7 commit c3f2775
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.rst
Expand Up @@ -76,7 +76,7 @@ This tool needs AWS credentials to create stacks and the credentials should be p

Project specific YAML file
+++++++++++++++++++++++++++
The YAML file below highlights what is possible with all the bootstrap-cfn features available to date. The minimum requirement is that it must contain an *ec2* block, you **do not** have to use RDS, S3 or ELB's.
The YAML file below highlights what is possible with all the bootstrap-cfn features available to date. The minimum requirement is that it must contain an *ec2* block, you **do not** have to use RDS, S3 or ELB's. Block devices in EC2 block is non mandatory as well.

::

Expand Down Expand Up @@ -173,9 +173,9 @@ Salt specific configuration

In order to rsync your salt states to the salt master you need to add a `salt` section to the top level of your project's YAML file. The following parameters specify the rsync sources and targets:

- **local_salt_dir**: Directory containing all the files you want to have in your salt root (for example top.sls or project specific states).
- **local_salt_dir**: Directory containing all the files you want to have in your salt root (for example top.sls or project specific states).
**Default value**: ./salt
- **local_pillar_dir**: Directory containing all the files you want to have in your pillar root.
- **local_pillar_dir**: Directory containing all the files you want to have in your pillar root.
**Default value**: ./pillar
- **local_vendor_dir**: Directory containing formulas cloned by salt-shaker.
**Default value**: ./vendor
Expand Down
9 changes: 6 additions & 3 deletions bootstrap_cfn/config.py
Expand Up @@ -262,9 +262,12 @@ def ec2(self):

# BLOCK DEVICE MAPPING
devices = []
for i in self.data['ec2']['block_devices']:
devices.append(
{'DeviceName': i['DeviceName'], 'Ebs': {'VolumeSize': i['VolumeSize']}})
try:
for i in self.data['ec2']['block_devices']:
devices.append(
{'DeviceName': i['DeviceName'], 'Ebs': {'VolumeSize': i['VolumeSize']}})
except KeyError:
pass
template['BaseHostLaunchConfig']['Properties'][
'BlockDeviceMappings'] = devices

Expand Down
9 changes: 9 additions & 0 deletions tests/tests.py
Expand Up @@ -5,6 +5,8 @@
import bootstrap_cfn.errors as errors
from testfixtures import compare

import pprint


class TestConfig(unittest.TestCase):

Expand Down Expand Up @@ -542,6 +544,13 @@ def test_ec2(self):
'dev').config, 'my-stack-name')
compare(known, config.ec2())

def test_ec2_with_no_block_device_specified(self):
from testfixtures import compare
project_config = ProjectConfig('tests/sample-project.yaml', 'dev')
project_config.config.pop('rds')
project_config.config['ec2'].pop('block_devices')
config = ConfigParser(project_config.config, 'my-stack-name')
config.process()

if __name__ == '__main__':
unittest.main()

0 comments on commit c3f2775

Please sign in to comment.