diff --git a/changelogs/fragments/opensearch_domainconfig_no_options.yaml b/changelogs/fragments/opensearch_domainconfig_no_options.yaml new file mode 100644 index 00000000000..d86d379f55d --- /dev/null +++ b/changelogs/fragments/opensearch_domainconfig_no_options.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: +- "opensearch - Don't try to read a non existing key from the domain config (https://github.com/ansible-collections/community.aws/pull/1910)." diff --git a/plugins/module_utils/opensearch.py b/plugins/module_utils/opensearch.py index 2152a939827..173c8ba6edf 100644 --- a/plugins/module_utils/opensearch.py +++ b/plugins/module_utils/opensearch.py @@ -61,7 +61,8 @@ def get_domain_config(client, module, domain_name): arn = None if response is not None: for k in response["DomainConfig"]: - domain_config[k] = response["DomainConfig"][k]["Options"] + if "Options" in response["DomainConfig"][k]: + domain_config[k] = response["DomainConfig"][k]["Options"] domain_config["DomainName"] = domain_name # If ES cluster is attached to the Internet, the "VPCOptions" property is not present. if "VPCOptions" in domain_config: