> ## Documentation Index
> Fetch the complete documentation index at: https://cloudanix.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Elasticache Automatic Failover Should Be Enabled

### More Info:

This rule checks if Amazon ElastiCache Redis replication groups have automatic failover enabled. The rule is NON\_COMPLIANT for an ElastiCache replication group if ‘AutomaticFailover’ is not set to ‘enabled’.

### Risk Level

Medium

### Address

Configuration

### Compliance Standards

CBP

### Triage and Remediation

<Tabs>
  <Tab title="Remediation">
    ### Remediation

    <AccordionGroup>
      <Accordion title="Using Console" defaultOpen="true">
        To remediate the misconfiguration of Elasticache Automatic Failover not being enabled for AWS ElastiCache using the AWS Management Console, follow these step-by-step instructions:

        1. **Access AWS Management Console**: Go to the AWS Management Console at [https://aws.amazon.com/](https://aws.amazon.com/) and sign in to your AWS account.

        2. **Navigate to ElastiCache Dashboard**: Click on the "Services" dropdown menu at the top left corner of the console and select "ElastiCache" under the "Database" section.

        3. **Select Redis Cluster**: In the ElastiCache dashboard, select the Redis cluster for which you want to enable automatic failover.

        4. **Modify the Cluster**: Click on the name of the Redis cluster to access its details. In the cluster details page, click on the "Modify" button at the top.

        5. **Enable Automatic Failover**: Scroll down to the "Advanced Redis settings" section in the modify cluster settings page. Look for the "Automatic Failover" option and set it to "Enabled".

        6. **Review and Apply Changes**: Review the other settings to ensure they are correct. Once you have confirmed that automatic failover is enabled and other settings are as desired, click on the "Modify" button at the bottom of the page.

        7. **Monitor the Cluster**: After modifying the cluster settings, monitor the cluster to ensure that the changes have been successfully applied. You can do this by checking the cluster status in the ElastiCache dashboard.

        By following these steps, you have successfully enabled automatic failover for your AWS ElastiCache Redis cluster, helping to ensure high availability and reliability for your cache system.

        #
      </Accordion>

      <Accordion title="Using CLI">
        To remediate the misconfiguration of Elasticache Automatic Failover not being enabled for AWS ElastiCache using AWS CLI, follow these steps:

        1. **Enable Automatic Failover for ElastiCache Cluster**:

           Run the following AWS CLI command to modify the ElastiCache cluster to enable automatic failover:

           ```
           aws elasticache modify-replication-group --replication-group-id <your-replication-group-id> --automatic-failover-enabled
           ```

           Replace `<your-replication-group-id>` with the ID of your ElastiCache replication group.

        2. **Verify Automatic Failover Configuration**:

           To confirm that the automatic failover has been enabled successfully, describe the ElastiCache replication group using the following command:

           ```
           aws elasticache describe-replication-groups --replication-group-id <your-replication-group-id>
           ```

           Ensure that the `AutomaticFailover` parameter is set to `enabled` in the output.

        3. **Monitor and Test Failover**:

           It is recommended to monitor the ElastiCache cluster after enabling automatic failover to ensure that it functions as expected. You can simulate a failover scenario to test the automatic failover capability.

        By following these steps, you can successfully remediate the misconfiguration of Elasticache Automatic Failover not being enabled for AWS ElastiCache using AWS CLI.
      </Accordion>

      <Accordion title="Using Python">
        To remediate the misconfiguration of Elasticache Automatic Failover not being enabled for AWS Elasticache using Python, you can follow these steps:

        1. Install the AWS SDK for Python (Boto3) if you haven't already. You can install it using pip:

           ```
           pip install boto3
           ```

        2. Use the following Python script to enable Automatic Failover for your Elasticache cluster:

        ```python theme={null}
        import boto3

        # Initialize the Elasticache client
        elasticache_client = boto3.client('elasticache')

        # Specify the cluster identifier of your Elasticache cluster
        cluster_id = 'your-cluster-id'

        # Enable Automatic Failover for the specified cluster
        response = elasticache_client.modify_replication_group(
            ReplicationGroupId=cluster_id,
            AutomaticFailoverEnabled=True
        )

        print("Automatic Failover has been enabled for the Elasticache cluster.")
        ```

        3. Replace `'your-cluster-id'` with the actual identifier of your Elasticache cluster.

        4. Run the Python script. It will enable Automatic Failover for the specified Elasticache cluster.

        By following these steps and running the Python script, you can remediate the misconfiguration of Elasticache Automatic Failover not being enabled for your AWS Elasticache cluster.
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>
