> ## 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.

# Rds retention days remediation

### Triage and Remediation

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

    <AccordionGroup>
      <Accordion title="Using Console" defaultOpen="true">
        To remediate the backup retention duration misconfiguration for an AWS RDS instance using the AWS Management Console, follow these steps:

        1. **Sign in to the AWS Management Console:**
           * Go to [https://aws.amazon.com/](https://aws.amazon.com/) and sign in to the AWS Management Console using your credentials.

        2. **Navigate to the RDS Console:**
           * In the AWS Management Console, navigate to the Amazon RDS console by clicking on "Services" at the top of the page and then selecting "RDS" under the Database section.

        3. **Select the RDS Instance:**
           * From the list of RDS instances, select the instance for which you want to set the backup retention duration.

        4. **Modify the Backup Retention Period:**
           * Click on the instance name to open its details page.
           * In the navigation pane on the left, click on "Modify".
           * Scroll down to the "Backup" section.
           * Locate the "Backup retention period" option and set the desired backup retention duration in days. The valid values range from 0 (for disabling automated backups) to a maximum of 35 days.

        5. **Apply the Changes:**
           * Scroll to the bottom of the page and click on the "Continue" button.
           * Review the summary of changes and click on the "Modify DB Instance" button to apply the new backup retention duration.

        6. **Monitor the Modification:**
           * Once the modification is complete, you can monitor the progress in the RDS console. The instance may undergo a brief downtime during the modification process.

        By following these steps, you can remediate the backup retention duration misconfiguration for an AWS RDS instance using the AWS Management Console.

        #
      </Accordion>

      <Accordion title="Using CLI">
        To remediate the issue of missing Backup Retention Duration for an AWS RDS instance using AWS CLI, you can follow these steps:

        1. **List Current Backup Retention Settings**:
           Run the following AWS CLI command to list the current backup retention settings for your RDS instance:
           ```bash theme={null}
           aws rds describe-db-instances --db-instance-identifier YOUR_DB_INSTANCE_IDENTIFIER
           ```

        2. **Update Backup Retention Duration**:
           Run the following AWS CLI command to modify the backup retention period for your RDS instance. Replace `YOUR_DB_INSTANCE_IDENTIFIER` with the actual identifier of your RDS instance and `NEW_RETENTION_PERIOD` with the desired retention period in days:
           ```bash theme={null}
           aws rds modify-db-instance --db-instance-identifier YOUR_DB_INSTANCE_IDENTIFIER --backup-retention-period NEW_RETENTION_PERIOD
           ```

        3. **Verify the Changes**:
           Run the `describe-db-instances` command again to verify that the backup retention period has been updated successfully:
           ```bash theme={null}
           aws rds describe-db-instances --db-instance-identifier YOUR_DB_INSTANCE_IDENTIFIER
           ```

        4. **Monitor the Backup Retention**:
           Monitor the backup retention settings periodically to ensure that the changes are applied correctly and the backups are retained for the specified duration.

        By following these steps, you can remediate the issue of missing Backup Retention Duration for an AWS RDS instance using AWS CLI.
      </Accordion>

      <Accordion title="Using Python">
        To remediate the backup retention duration misconfiguration for AWS RDS using Python, you can use the AWS SDK for Python (Boto3). Here are the step-by-step instructions:

        1. Install Boto3:
           If you haven't already installed Boto3, you can install it using pip:
           ```
           pip install boto3
           ```

        2. Write a Python script to update the backup retention duration for the desired RDS instance. Here's an example script:

        ```python theme={null}
        import boto3

        # Define the RDS instance identifier and the desired backup retention period
        rds_instance_identifier = 'your_rds_instance_identifier'
        backup_retention_period = 7  # Set the desired retention period in days

        # Create an RDS client
        rds_client = boto3.client('rds')

        # Update the backup retention period for the specified RDS instance
        response = rds_client.modify_db_instance(
            DBInstanceIdentifier=rds_instance_identifier,
            BackupRetentionPeriod=backup_retention_period
        )

        print(f"Backup retention period updated for RDS instance {rds_instance_identifier}")
        ```

        3. Replace `'your_rds_instance_identifier'` with the actual identifier of your RDS instance.

        4. Set the `backup_retention_period` variable to the desired retention period in days.

        5. Run the Python script. This script will update the backup retention period for the specified RDS instance to the value you set.

        By following these steps, you can remediate the backup retention duration misconfiguration for AWS RDS using Python and ensure that your RDS instances have the correct backup retention period set.
      </Accordion>

      <Accordion title="Using Terraform">
        ```hcl theme={null}
        resource "aws_db_instance" "THIS_DB" {
          # Replace THIS_DB with your DB identifier resource name
          identifier = "DB_INSTANCE_IDENTIFIER" # replace with your DB instance identifier

          # ...other required arguments like engine, instance_class, etc...

          # Set automated backup retention to 7 days
          backup_retention_period = 7
        }
        ```

        This change updates the existing RDS instance in place; it does not force replacement, but applying it may cause a brief outage when AWS applies the modification.

        `terraform plan` should show a change on the existing `aws_db_instance` with `backup_retention_period` going from its current value (e.g., `0` or another number) to `7`.
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>
