diff --git a/changelogs/fragments/1800-elb_target_group_property.yml b/changelogs/fragments/1800-elb_target_group_property.yml new file mode 100644 index 00000000000..3c8e2625680 --- /dev/null +++ b/changelogs/fragments/1800-elb_target_group_property.yml @@ -0,0 +1,2 @@ +bugfixes: + - elb_target_group - get ``ProtocolVersion`` key from ``target_group`` attributes only when exists (https://github.com/ansible-collections/community.aws/pull/1800). diff --git a/plugins/modules/elb_target_group.py b/plugins/modules/elb_target_group.py index bbab1507d2d..93a3f333df6 100644 --- a/plugins/modules/elb_target_group.py +++ b/plugins/modules/elb_target_group.py @@ -719,7 +719,7 @@ def create_or_update_target_group(connection, module): # TODO: required and here? if "Matcher" in params: code_key = "HttpCode" - if target_group["ProtocolVersion"] == "GRPC": + if target_group.get("ProtocolVersion") == "GRPC": code_key = "GrpcCode" current_matcher_list = target_group["Matcher"][code_key].split(",") requested_matcher_list = params["Matcher"][code_key].split(",")