From 7d69003d1c766fa3a43f7917bc8ed88238a5bb81 Mon Sep 17 00:00:00 2001 From: nesies <> Date: Mon, 5 Jun 2023 12:44:07 +0200 Subject: [PATCH] 1594_ec2_instance_key_name_is_not_an_error --- .../fragments/1594_ec2_instance_key_name_is_not_an_error.yml | 3 +++ plugins/modules/ec2_instance.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/1594_ec2_instance_key_name_is_not_an_error.yml diff --git a/changelogs/fragments/1594_ec2_instance_key_name_is_not_an_error.yml b/changelogs/fragments/1594_ec2_instance_key_name_is_not_an_error.yml new file mode 100644 index 0000000000..2729045d48 --- /dev/null +++ b/changelogs/fragments/1594_ec2_instance_key_name_is_not_an_error.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - if key_name is empty, assume it is absent diff --git a/plugins/modules/ec2_instance.py b/plugins/modules/ec2_instance.py index a70b6bf15d..38792b0508 100644 --- a/plugins/modules/ec2_instance.py +++ b/plugins/modules/ec2_instance.py @@ -1260,7 +1260,7 @@ def build_top_level_options(params): msg="You must include an image_id or image.id parameter to create an instance, or use a launch_template." ) - if params.get("key_name") is not None: + if params.get("key_name") not in (None, ""): spec["KeyName"] = params.get("key_name") spec.update(build_userdata(params))