|
1000 | 1000 | elements: str |
1001 | 1001 | returned: if applicable |
1002 | 1002 | sample: { |
1003 | | - "BlockDeviceMappings": [ |
| 1003 | + "block_device_mappings": [ |
1004 | 1004 | { |
1005 | | - "DeviceName": "/dev/sdb", |
1006 | | - "Ebs": { |
1007 | | - "DeleteOnTermination": true, |
1008 | | - "Encrypted": true, |
1009 | | - "VolumeSize": 5 |
| 1005 | + "device_name": "/dev/sdb", |
| 1006 | + "ebs": { |
| 1007 | + "delete_on_termination": true, |
| 1008 | + "encrypted": true, |
| 1009 | + "volumeSize": 5 |
1010 | 1010 | } |
1011 | 1011 | } |
1012 | 1012 | ], |
1013 | | - "EbsOptimized": false, |
1014 | | - "ImageId": "ami-0231217be14a6f3ba", |
1015 | | - "InstanceType": "t2.micro", |
1016 | | - "NetworkInterfaces": [ |
| 1013 | + "ebs_optimized": false, |
| 1014 | + "image_id": "ami-0231217be14a6f3ba", |
| 1015 | + "instance_type": "t2.micro", |
| 1016 | + "network_interfaces": [ |
1017 | 1017 | { |
1018 | | - "AssociatePublicIpAddress": false, |
1019 | | - "DeviceIndex": 0, |
1020 | | - "Ipv6Addresses": [ |
| 1018 | + "associate_public_ip_address": false, |
| 1019 | + "device_index": 0, |
| 1020 | + "ipv6_addresses": [ |
1021 | 1021 | { |
1022 | | - "Ipv6Address": "2001:0:130F:0:0:9C0:876A:130B" |
| 1022 | + "ipv6_address": "2001:0:130F:0:0:9C0:876A:130B" |
1023 | 1023 | } |
1024 | 1024 | ] |
1025 | 1025 | } |
@@ -1222,19 +1222,23 @@ def find_existing(client, module: AnsibleAWSModule) -> Tuple[Optional[Dict[str, |
1222 | 1222 | def params_to_launch_data( |
1223 | 1223 | template_params: Dict[str, Any], iam_instance_profile_arn: Optional[str] = None |
1224 | 1224 | ) -> Dict[str, Any]: |
| 1225 | + tag_specifications = [] |
1225 | 1226 | if template_params.get("tag_specifications"): |
1226 | | - template_params["tag_specifications"] = [ |
| 1227 | + tag_specifications = [ |
1227 | 1228 | {"resource_type": ts["resource_type"], "tags": ansible_dict_to_boto3_tag_list(ts["tags"])} |
1228 | 1229 | for ts in template_params["tag_specifications"] |
1229 | 1230 | ] |
1230 | 1231 | if template_params.get("tags"): |
1231 | | - if "tag_specifications" not in template_params: |
1232 | | - template_params["tag_specifications"] = [] |
1233 | 1232 | tag_list = ansible_dict_to_boto3_tag_list(template_params.get("tags")) |
1234 | | - template_params["tag_specifications"] += [ |
| 1233 | + tag_specifications += [ |
1235 | 1234 | {"resource_type": r_type, "tags": tag_list} for r_type in ("instance", "volume", "network-interface") |
1236 | 1235 | ] |
1237 | 1236 | del template_params["tags"] |
| 1237 | + |
| 1238 | + # In case some tags were defined, add them to the template parameters |
| 1239 | + if tag_specifications: |
| 1240 | + template_params["tag_specifications"] = tag_specifications |
| 1241 | + |
1238 | 1242 | if iam_instance_profile_arn: |
1239 | 1243 | template_params["iam_instance_profile"] = {"arn": iam_instance_profile_arn} |
1240 | 1244 | for interface in template_params.get("network_interfaces") or []: |
@@ -1465,7 +1469,7 @@ def ensure_present( |
1465 | 1469 | version_description = module.params.get("version_description") |
1466 | 1470 | iam_instance_profile = module.params.get("iam_instance_profile") |
1467 | 1471 | if iam_instance_profile: |
1468 | | - iam_instance_profile = determine_iam_arn_from_name(module, iam_instance_profile) |
| 1472 | + iam_instance_profile = determine_iam_arn_from_name(module.client("iam"), iam_instance_profile) |
1469 | 1473 | launch_template_data = params_to_launch_data( |
1470 | 1474 | dict((k, v) for k, v in module.params.items() if k in template_options), iam_instance_profile |
1471 | 1475 | ) |
|
0 commit comments