diff --git a/README.rst b/README.rst index 6941459..d9e5cc7 100644 --- a/README.rst +++ b/README.rst @@ -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. :: @@ -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 diff --git a/bootstrap_cfn/config.py b/bootstrap_cfn/config.py index 18e9562..e649da3 100644 --- a/bootstrap_cfn/config.py +++ b/bootstrap_cfn/config.py @@ -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 diff --git a/tests/tests.py b/tests/tests.py index 37aae98..596d552 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -542,6 +542,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()