Skip to content

Commit cbdd9d8

Browse files
committed
minor updates
1 parent d215fd2 commit cbdd9d8

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

plugins/modules/ec2_launch_template.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,26 +1000,26 @@
10001000
elements: str
10011001
returned: if applicable
10021002
sample: {
1003-
"BlockDeviceMappings": [
1003+
"block_device_mappings": [
10041004
{
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
10101010
}
10111011
}
10121012
],
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": [
10171017
{
1018-
"AssociatePublicIpAddress": false,
1019-
"DeviceIndex": 0,
1020-
"Ipv6Addresses": [
1018+
"associate_public_ip_address": false,
1019+
"device_index": 0,
1020+
"ipv6_addresses": [
10211021
{
1022-
"Ipv6Address": "2001:0:130F:0:0:9C0:876A:130B"
1022+
"ipv6_address": "2001:0:130F:0:0:9C0:876A:130B"
10231023
}
10241024
]
10251025
}
@@ -1222,19 +1222,23 @@ def find_existing(client, module: AnsibleAWSModule) -> Tuple[Optional[Dict[str,
12221222
def params_to_launch_data(
12231223
template_params: Dict[str, Any], iam_instance_profile_arn: Optional[str] = None
12241224
) -> Dict[str, Any]:
1225+
tag_specifications = []
12251226
if template_params.get("tag_specifications"):
1226-
template_params["tag_specifications"] = [
1227+
tag_specifications = [
12271228
{"resource_type": ts["resource_type"], "tags": ansible_dict_to_boto3_tag_list(ts["tags"])}
12281229
for ts in template_params["tag_specifications"]
12291230
]
12301231
if template_params.get("tags"):
1231-
if "tag_specifications" not in template_params:
1232-
template_params["tag_specifications"] = []
12331232
tag_list = ansible_dict_to_boto3_tag_list(template_params.get("tags"))
1234-
template_params["tag_specifications"] += [
1233+
tag_specifications += [
12351234
{"resource_type": r_type, "tags": tag_list} for r_type in ("instance", "volume", "network-interface")
12361235
]
12371236
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+
12381242
if iam_instance_profile_arn:
12391243
template_params["iam_instance_profile"] = {"arn": iam_instance_profile_arn}
12401244
for interface in template_params.get("network_interfaces") or []:
@@ -1465,7 +1469,7 @@ def ensure_present(
14651469
version_description = module.params.get("version_description")
14661470
iam_instance_profile = module.params.get("iam_instance_profile")
14671471
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)
14691473
launch_template_data = params_to_launch_data(
14701474
dict((k, v) for k, v in module.params.items() if k in template_options), iam_instance_profile
14711475
)

0 commit comments

Comments
 (0)