Skip to content

decrease_replica_count

decrease_replica_count(
    *,
    config_overrides: Optional[ElastiCacheClientConfig] = None,
    replication_group_id: Optional[String] = None,
    new_replica_count: Optional[IntegerOptional] = None,
    replica_configuration: Optional[ReplicaConfigurationList] = None,
    replicas_to_remove: Optional[RemoveReplicasList] = None,
    apply_immediately: Optional[Boolean] = None,
) -> DecreaseReplicaCountResult

Dynamically decreases the number of replicas in a Valkey or Redis OSS (cluster mode disabled) replication group or the number of replica nodes in one or more node groups (shards) of a Valkey or Redis OSS (cluster mode enabled) replication group. This operation is performed with no cluster down time.

Parameters:

  • replication_group_id (Optional[String], default: None ) –

    The id of the replication group from which you want to remove replica nodes.

  • new_replica_count (Optional[IntegerOptional], default: None ) –

    The number of read replica nodes you want at the completion of this operation. For Valkey or Redis OSS (cluster mode disabled) replication groups, this is the number of replica nodes in the replication group. For Valkey or Redis OSS (cluster mode enabled) replication groups, this is the number of replica nodes in each of the replication group's node groups.

    The minimum number of replicas in a shard or replication group is:

    • Valkey or Redis OSS (cluster mode disabled)

      • If Multi-AZ is enabled: 1

      • If Multi-AZ is not enabled: 0

    • Valkey or Redis OSS (cluster mode enabled): 0 (though you will not be able to failover to a replica if your primary node fails)

  • replica_configuration (Optional[ReplicaConfigurationList], default: None ) –

    A list of ConfigureShard objects that can be used to configure each shard in a Valkey or Redis OSS replication group. The ConfigureShard has three members: NewReplicaCount, NodeGroupId, and PreferredAvailabilityZones.

  • replicas_to_remove (Optional[RemoveReplicasList], default: None ) –

    A list of the node ids to remove from the replication group or node group (shard).

  • apply_immediately (Optional[Boolean], default: None ) –

    If True, the number of replica nodes is decreased immediately. ApplyImmediately=False is not currently supported.

Raises:

Source code in docs_src/capo_elasticache/_services/elasti_cache.py
def decrease_replica_count(
    self,
    *,
    config_overrides: Optional[ElastiCacheClientConfig] = None,
    replication_group_id: Optional["capo_elasticache.types.string.String"] = None,
    new_replica_count: Optional[
        "capo_elasticache.types.integer_optional.IntegerOptional"
    ] = None,
    replica_configuration: Optional[
        "capo_elasticache.types.replica_configuration_list.ReplicaConfigurationList"
    ] = None,
    replicas_to_remove: Optional[
        "capo_elasticache.types.remove_replicas_list.RemoveReplicasList"
    ] = None,
    apply_immediately: Optional["capo_elasticache.types.boolean.Boolean"] = None,
) -> "capo_elasticache.types.decrease_replica_count_result.DecreaseReplicaCountResult":
    """<p>Dynamically decreases the number of replicas in a Valkey or Redis OSS (cluster mode disabled) replication group or the number of replica nodes in one or more node groups (shards) of a Valkey or Redis OSS (cluster mode enabled) replication group. This operation is performed with no cluster down time.</p>

    Args:
        replication_group_id: <p>The id of the replication group from which you want to remove replica nodes.</p>
        new_replica_count: <p>The number of read replica nodes you want at the completion of this operation. For Valkey or Redis OSS (cluster mode disabled) replication groups, this is the number of replica nodes in the replication group. For Valkey or Redis OSS (cluster mode enabled) replication groups, this is the number of replica nodes in each of the replication group's node groups.</p> <p>The minimum number of replicas in a shard or replication group is:</p> <ul> <li> <p>Valkey or Redis OSS (cluster mode disabled)</p> <ul> <li> <p>If Multi-AZ is enabled: 1</p> </li> <li> <p>If Multi-AZ is not enabled: 0</p> </li> </ul> </li> <li> <p>Valkey or Redis OSS (cluster mode enabled): 0 (though you will not be able to failover to a replica if your primary node fails)</p> </li> </ul>
        replica_configuration: <p>A list of <code>ConfigureShard</code> objects that can be used to configure each shard in a Valkey or Redis OSS replication group. The <code>ConfigureShard</code> has three members: <code>NewReplicaCount</code>, <code>NodeGroupId</code>, and <code>PreferredAvailabilityZones</code>.</p>
        replicas_to_remove: <p>A list of the node ids to remove from the replication group or node group (shard).</p>
        apply_immediately: <p>If <code>True</code>, the number of replica nodes is decreased immediately. <code>ApplyImmediately=False</code> is not currently supported.</p>

    Raises:
        capo_elasticache.errors.cluster_quota_for_customer_exceeded_fault.ClusterQuotaForCustomerExceededFault: <p>The request cannot be processed because it would exceed the allowed number of clusters per customer.</p>
        capo_elasticache.errors.insufficient_cache_cluster_capacity_fault.InsufficientCacheClusterCapacityFault: <p>The requested cache node type is not available in the specified Availability Zone. For more information, see <a href="http://docs.aws.amazon.com/AmazonElastiCache/latest/dg/ErrorMessages.html#ErrorMessages.INSUFFICIENT_CACHE_CLUSTER_CAPACITY">InsufficientCacheClusterCapacity</a> in the ElastiCache User Guide.</p>
        capo_elasticache.errors.invalid_cache_cluster_state_fault.InvalidCacheClusterStateFault: <p>The requested cluster is not in the <code>available</code> state.</p>
        capo_elasticache.errors.invalid_parameter_combination_exception.InvalidParameterCombinationException: <p>Two or more incompatible parameters were specified.</p>
        capo_elasticache.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>The value for a parameter is invalid.</p>
        capo_elasticache.errors.invalid_replication_group_state_fault.InvalidReplicationGroupStateFault: <p>The requested replication group is not in the <code>available</code> state.</p>
        capo_elasticache.errors.invalid_vpc_network_state_fault.InvalidVPCNetworkStateFault: <p>The VPC network is in an invalid state.</p>
        capo_elasticache.errors.node_groups_per_replication_group_quota_exceeded_fault.NodeGroupsPerReplicationGroupQuotaExceededFault: <p>The request cannot be processed because it would exceed the maximum allowed number of node groups (shards) in a single replication group. The default maximum is 90</p>
        capo_elasticache.errors.node_quota_for_customer_exceeded_fault.NodeQuotaForCustomerExceededFault: <p>The request cannot be processed because it would exceed the allowed number of cache nodes per customer.</p>
        capo_elasticache.errors.no_operation_fault.NoOperationFault: <p>The operation was not performed because no changes were required.</p>
        capo_elasticache.errors.replication_group_not_found_fault.ReplicationGroupNotFoundFault: <p>The specified replication group does not exist.</p>
        capo_elasticache.errors.service_linked_role_not_found_fault.ServiceLinkedRoleNotFoundFault: <p>The specified service linked role (SLR) was not found.</p>
        capo_elasticache.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_elasticache.types.decrease_replica_count_message.DecreaseReplicaCountMessage]",
    ) -> OperationResponse[
        "capo_elasticache.types.decrease_replica_count_result.DecreaseReplicaCountResult"
    ]:
        import capo_elasticache._operations.amazon_elasti_cache_v9.decrease_replica_count

        output, http_response = (
            capo_elasticache._operations.amazon_elasti_cache_v9.decrease_replica_count.decrease_replica_count(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DecreaseReplicaCount")
    )
    input_: capo_elasticache.types.decrease_replica_count_message.DecreaseReplicaCountMessage = {}
    if replication_group_id is not None:
        input_["replication_group_id"] = replication_group_id
    if new_replica_count is not None:
        input_["new_replica_count"] = new_replica_count
    if replica_configuration is not None:
        input_["replica_configuration"] = replica_configuration
    if replicas_to_remove is not None:
        input_["replicas_to_remove"] = replicas_to_remove
    if apply_immediately is not None:
        input_["apply_immediately"] = apply_immediately

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output