> ## 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 reserved instance payment failed remediation

### Triage and Remediation

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

    <AccordionGroup>
      <Accordion title="Using Console" defaultOpen="true">
        To remediate the misconfiguration of RDS Reserved Instances having a status of "Payment Failed" in AWS, you can follow these steps using the AWS Management Console:

        1. **Identify the RDS Reserved Instances with Payment Failed Status:**
           * Go to the AWS Management Console and navigate to the RDS service.
           * Click on the "Reserved Instances" option in the left-hand menu to view all your reserved instances.
           * Look for any instances with a status of "Payment Failed".

        2. **Cancel the Reserved Instance with Payment Failed Status:**
           * Select the RDS Reserved Instance with the "Payment Failed" status that you want to remediate.
           * Click on the "Actions" dropdown menu and select "Modify Reserved Instances".
           * In the Modify Reserved Instances wizard, select the option to "Cancel Reserved Instance" and follow the on-screen instructions to cancel the instance.

        3. **Purchase a New Reserved Instance:**
           * Once you have canceled the Reserved Instance with the Payment Failed status, you can purchase a new Reserved Instance to replace it.
           * Click on the "Purchase Reserved Instances" button in the Reserved Instances dashboard.
           * Follow the on-screen instructions to select the desired instance type, term length, and quantity for the new Reserved Instance.

        4. **Verify the New Reserved Instance Status:**
           * After purchasing the new Reserved Instance, verify that its status is "Active" and not "Payment Failed".
           * You can check the status of the new Reserved Instance in the Reserved Instances dashboard.

        By following these steps, you can remediate the misconfiguration of RDS Reserved Instances having a status of "Payment Failed" in AWS RDS using the AWS Management Console.

        #
      </Accordion>

      <Accordion title="Using CLI">
        To remediate the misconfiguration of an RDS Reserved Instance having a status of "Payment Failed" in AWS using AWS CLI, follow these steps:

        1. Identify the RDS Reserved Instance with the "Payment Failed" status:

        ```bash theme={null}
        aws rds describe-reserved-db-instances --query "ReservedDBInstances[?State=='payment-failed']"
        ```

        2. Take note of the Reserved Instance ID of the RDS instance with the "Payment Failed" status.

        3. Modify the RDS Reserved Instance to update the payment method:

        ```bash theme={null}
        aws rds modify-reserved-db-instances --reserved-db-instance-id <RESERVED_INSTANCE_ID> --reserved-db-instances-offering-id <OFFERING_ID>
        ```

        Replace `<RESERVED_INSTANCE_ID>` with the Reserved Instance ID noted in step 2 and `<OFFERING_ID>` with the new offering ID for the Reserved Instance. You can find the available offering IDs by listing the available Reserved DB Instances offerings using the following command:

        ```bash theme={null}
        aws rds describe-reserved-db-instances-offerings
        ```

        4. Confirm the changes by describing the updated Reserved Instance:

        ```bash theme={null}
        aws rds describe-reserved-db-instances --reserved-db-instance-id <RESERVED_INSTANCE_ID>
        ```

        By following these steps, you should be able to remediate the misconfiguration of an RDS Reserved Instance with a status of "Payment Failed" in AWS using AWS CLI.
      </Accordion>

      <Accordion title="Using Python">
        To remediate the issue of RDS Reserved Instances having a status of "Payment Failed" in AWS using Python, you can follow these steps:

        1. **Identify Reserved Instances with Payment Failed Status**:
           * Use the AWS SDK for Python (Boto3) to describe all the RDS Reserved Instances.
           * Filter the instances that have a status of "Payment Failed".

        2. **Modify the Reserved Instances**:
           * For each Reserved Instance with a status of "Payment Failed", you can modify the instance to update the payment details.
           * Use the `modify_reserved_db_instances` method from the Boto3 RDS client to update the payment details for the Reserved Instance.

        3. **Update Payment Information**:
           * You will need to provide valid payment information to update the status of the Reserved Instance.
           * Use the `modify_db_instance` method to update the payment details of the Reserved Instance.

        4. **Verify the Status**:
           * After updating the payment information, describe the Reserved Instance again to verify that the status is no longer "Payment Failed".

        Here is a sample Python script to remediate the issue:

        ```python theme={null}
        import boto3

        # Initialize the RDS client
        rds_client = boto3.client('rds')

        # Describe all Reserved Instances
        reserved_instances = rds_client.describe_reserved_db_instances()

        # Filter Reserved Instances with Payment Failed status
        payment_failed_instances = [instance for instance in reserved_instances['ReservedDBInstances'] if instance['State'] == 'payment-failed']

        # Update payment information for each Reserved Instance with Payment Failed status
        for instance in payment_failed_instances:
            # Modify the Reserved Instance to update payment details
            rds_client.modify_reserved_db_instances(ReservedDBInstanceId=instance['ReservedDBInstanceId'], PaymentType='POSTPAID')

            # Describe the modified Reserved Instance to verify the status
            modified_instance = rds_client.describe_reserved_db_instances(ReservedDBInstanceId=instance['ReservedDBInstanceId'])
            print(f"Reserved Instance {modified_instance['ReservedDBInstances'][0]['ReservedDBInstanceId']} status updated to {modified_instance['ReservedDBInstances'][0]['State']}")
        ```

        Make sure to replace the placeholders in the script with actual values as per your AWS account configuration. Also, ensure that you have the necessary permissions to modify RDS Reserved Instances in your AWS account.
      </Accordion>

      <Accordion title="Using Terraform">
        Terraform cannot remediate this finding because RDS Reserved Instances (and their payment status) are not represented as Terraform resources in the AWS provider; they are a billing/commerce construct managed entirely in AWS.

        To fix a `payment-failed` RDS Reserved Instance, you must use the AWS Console or Support:

        1. Go to AWS Console → RDS → Reserved instances.
        2. Filter by status = `payment-failed`.
        3. Either update the payment method in your AWS Billing console and retry the purchase, or cancel/let the failed reservation lapse and re-purchase a new RDS Reserved Instance.

        Since there is no Terraform resource for RDS reserved instances, `terraform plan` will show no changes related to this remediation.
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>
