From 0344815a451b46c5c63582603dd6506e2b0c42a7 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 19 Apr 2023 09:04:18 +0000 Subject: [PATCH] elasticache_info: ignore CacheClusterNotFound exeption during tag collect (#1777) (#1778) [PR #1777/5461b2e2 backport][stable-5] elasticache_info: ignore CacheClusterNotFound exeption during tag collect This is a backport of PR #1777 as merged into main (5461b2e). If we call get_elasticache_tags_with_backoff() on a cluster with an invalid state (eg: deleting), AWS will trigger an CacheClusterNotFound. With this change, elasticache_info will ignore the cluster and continue with the next one. Reviewed-by: Mark Chappell --- ...che_info-ignore-CacheClusterNotFound-when-reading-tags.yaml | 3 +++ plugins/modules/elasticache_info.py | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 changelogs/fragments/elasticache_info-ignore-CacheClusterNotFound-when-reading-tags.yaml diff --git a/changelogs/fragments/elasticache_info-ignore-CacheClusterNotFound-when-reading-tags.yaml b/changelogs/fragments/elasticache_info-ignore-CacheClusterNotFound-when-reading-tags.yaml new file mode 100644 index 00000000000..d8ef3c31c69 --- /dev/null +++ b/changelogs/fragments/elasticache_info-ignore-CacheClusterNotFound-when-reading-tags.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: +- "elasticache_info - Ignore the CacheClusterNotFound exception when collecting tags (https://github.com/ansible-collections/community.aws/pull/1777)." diff --git a/plugins/modules/elasticache_info.py b/plugins/modules/elasticache_info.py index 1f8af9a330c..f6c34629edb 100644 --- a/plugins/modules/elasticache_info.py +++ b/plugins/modules/elasticache_info.py @@ -472,6 +472,9 @@ def get_elasticache_clusters(client, module): arn = "arn:aws:elasticache:%s:%s:cluster:%s" % (region, account_id, cluster['cache_cluster_id']) try: tags = get_elasticache_tags_with_backoff(client, arn) + except is_boto3_error_code("CacheClusterNotFound"): + # e.g: Cluster was listed but is in deleting state + continue except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: module.fail_json_aws(e, msg="Couldn't get tags for cluster %s")