Browse code

Fix ec2_lc failing to create multi-volume configurations (#32191)

awkspace authored on 2017/10/27 08:08:57
Showing 1 changed files
1 1
old mode 100644
2 2
new mode 100755
... ...
@@ -254,7 +254,7 @@ def create_launch_config(connection, module):
254 254
     classic_link_vpc_id = module.params.get('classic_link_vpc_id')
255 255
     classic_link_vpc_security_groups = module.params.get('classic_link_vpc_security_groups')
256 256
 
257
-    block_device_mapping = {}
257
+    block_device_mapping = []
258 258
 
259 259
     convert_list = ['image_id', 'instance_type', 'instance_type', 'instance_id', 'placement_tenancy', 'key_name', 'kernel_id', 'ramdisk_id', 'spot_price']
260 260
 
... ...
@@ -273,7 +273,7 @@ def create_launch_config(connection, module):
273 273
                 module.fail_json(msg='Device name must be set for volume')
274 274
             # Minimum volume size is 1GB. We'll use volume size explicitly set to 0 to be a signal not to create this volume
275 275
             if 'volume_size' not in volume or int(volume['volume_size']) > 0:
276
-                block_device_mapping.update(create_block_device_meta(module, volume))
276
+                block_device_mapping.append(create_block_device_meta(module, volume))
277 277
 
278 278
     try:
279 279
         launch_configs = connection.describe_launch_configurations(LaunchConfigurationNames=[name]).get('LaunchConfigurations')
... ...
@@ -298,7 +298,7 @@ def create_launch_config(connection, module):
298 298
         launch_config['ClassicLinkVPCSecurityGroups'] = classic_link_vpc_security_groups
299 299
 
300 300
     if block_device_mapping:
301
-        launch_config['BlockDeviceMappings'] = [block_device_mapping]
301
+        launch_config['BlockDeviceMappings'] = block_device_mapping
302 302
 
303 303
     if instance_profile_name is not None:
304 304
         launch_config['IamInstanceProfile'] = instance_profile_name