ansible-collections / community.aws

Ansible Collection for Community AWS
GNU General Public License v3.0
188 stars 397 forks source link

How to delete an Elasticache Replication Group #683

Closed rust84 closed 3 years ago

rust84 commented 3 years ago

Summary

We are trying to delete an Elasticache redis cluster which is part of a replication group. I have tried the following.

    - name: Ensure cache cluster is gone
      community.aws.elasticache:
        region: eu-west-1
        name: "cluster-name-001"
        state: absent

We are getting the following error because the cluster is Primary for the replication group. What we would like to achieve is destroying the replication group. I am creating a playbook for destroying and restoring the cluster from a snapshot so need to ensure that the original cluster is cleaned up first. I am reading the docs but cannot see a way to manage the destruction of the replication group as a whole.

TASK [Ensure cache cluster is gone] ********************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'InvalidCacheClusterStateFault' object has no attribute 'message'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_elasticache_payload_jk7fnkc7/ansible_elasticache_payload.zip/ansible/modules/cloud/amazon/elasticache.py\", line 238, in delete\n  File \"/home/russell/.local/lib/python3.9/site-packages/botocore/client.py\", line 386, in _api_call\n    return self._make_api_call(operation_name, kwargs)\n  File \"/home/russell/.local/lib/python3.9/site-packages/botocore/client.py\", line 705, in _make_api_call\n    raise error_class(parsed_response, operation_name)\nbotocore.errorfactory.InvalidCacheClusterStateFault: An error occurred (InvalidCacheClusterState) when calling the DeleteCacheCluster operation: Cache cluster cluster-name-001 is serving as primary for replication group replication-group-name and cannot be deleted. To delete the entire replication group, use DeleteReplicationGroup.\n

Issue Type

Documentation Report

Component Name

elasticache

Ansible Version

$ ansible --version

Collection Versions

  - name: community.aws
    version: 1.5.0

Configuration

ansible 2.9.10

OS / Environment

No response

Additional Information

No response

Code of Conduct

ansibullbot commented 3 years ago

Files identified in the description: None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

tremble commented 3 years ago

I'm not familiar with Elasticache, but the error:

Cache cluster cluster-name-001 is serving as primary

would seem to imply you need to delete the replica clusters before you delete the primay

ansibullbot commented 3 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 3 years ago

cc @alachaum @jillr @jsdalton @markuman @s-hertel @wimnat click here for bot help