Skip to content

create_serverless_cache

create_serverless_cache(
    *,
    config_overrides: Optional[ElastiCacheClientConfig] = None,
    serverless_cache_name: Optional[String] = None,
    description: Optional[String] = None,
    engine: Optional[String] = None,
    major_engine_version: Optional[String] = None,
    cache_usage_limits: Optional[CacheUsageLimits] = None,
    kms_key_id: Optional[String] = None,
    security_group_ids: Optional[SecurityGroupIdsList] = None,
    snapshot_arns_to_restore: Optional[SnapshotArnsList] = None,
    tags: Optional[TagList] = None,
    user_group_id: Optional[String] = None,
    subnet_ids: Optional[SubnetIdsList] = None,
    snapshot_retention_limit: Optional[IntegerOptional] = None,
    daily_snapshot_time: Optional[String] = None,
    network_type: Optional[NetworkType] = None,
    connection_type: Optional[ConnectionType] = None,
) -> CreateServerlessCacheResponse

Creates a serverless cache.

Parameters:

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

    User-provided identifier for the serverless cache. This parameter is stored as a lowercase string.

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

    User-provided description for the serverless cache. The default is NULL, i.e. if no description is provided then an empty string will be returned. The maximum length is 255 characters.

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

    The name of the cache engine to be used for creating the serverless cache.

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

    The version of the cache engine that will be used to create the serverless cache.

  • cache_usage_limits (Optional[CacheUsageLimits], default: None ) –

    Sets the cache usage limits for storage and ElastiCache Processing Units for the cache.

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

    ARN of the customer managed key for encrypting the data at rest. If no KMS key is provided, a default service key is used.

  • security_group_ids (Optional[SecurityGroupIdsList], default: None ) –

    A list of the one or more VPC security groups to be associated with the serverless cache. The security group will authorize traffic access for the VPC end-point (private-link). If no other information is given this will be the VPC’s Default Security Group that is associated with the cluster VPC end-point.

  • snapshot_arns_to_restore (Optional[SnapshotArnsList], default: None ) –

    The ARN(s) of the snapshot that the new serverless cache will be created from. Available for Valkey, Redis OSS and Serverless Memcached only.

  • tags (Optional[TagList], default: None ) –

    The list of tags (key, value) pairs to be added to the serverless cache resource. Default is NULL.

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

    The identifier of the UserGroup to be associated with the serverless cache. Available for Valkey and Redis OSS only. Default is NULL.

  • subnet_ids (Optional[SubnetIdsList], default: None ) –

    A list of the identifiers of the subnets where the VPC endpoint for the serverless cache will be deployed. All the subnetIds must belong to the same VPC.

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

    The number of days for which ElastiCache retains automatic snapshots before deleting them. Available for Valkey, Redis OSS and Serverless Memcached only. The maximum value allowed is 35 days.

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

    The daily time that snapshots will be created from the new serverless cache. By default this number is populated with 0, i.e. no snapshots will be created on an automatic daily basis. Available for Valkey, Redis OSS and Serverless Memcached only.

  • network_type (Optional[NetworkType], default: None ) –

    The IP protocol version used by the serverless cache. Must be either ipv4 | ipv6 | dual_stack. ipv6 is only supported with IPv6-only subnets. If not specified, defaults to ipv4, unless all provided subnets are IPv6-only, in which case it defaults to ipv6.

  • connection_type (Optional[ConnectionType], default: None ) –

    The connection type for the serverless cache. Must be either vpc | public. Use vpc to access the cache through a VPC endpoint, or public to access the cache over the internet. If not specified, defaults to vpc. This value cannot be changed after the serverless cache is created. Setting this to public requires Valkey 9 or above.

Raises:

Source code in docs_src/capo_elasticache/_services/elasti_cache.py
def create_serverless_cache(
    self,
    *,
    config_overrides: Optional[ElastiCacheClientConfig] = None,
    serverless_cache_name: Optional["capo_elasticache.types.string.String"] = None,
    description: Optional["capo_elasticache.types.string.String"] = None,
    engine: Optional["capo_elasticache.types.string.String"] = None,
    major_engine_version: Optional["capo_elasticache.types.string.String"] = None,
    cache_usage_limits: Optional[
        "capo_elasticache.types.cache_usage_limits.CacheUsageLimits"
    ] = None,
    kms_key_id: Optional["capo_elasticache.types.string.String"] = None,
    security_group_ids: Optional[
        "capo_elasticache.types.security_group_ids_list.SecurityGroupIdsList"
    ] = None,
    snapshot_arns_to_restore: Optional[
        "capo_elasticache.types.snapshot_arns_list.SnapshotArnsList"
    ] = None,
    tags: Optional["capo_elasticache.types.tag_list.TagList"] = None,
    user_group_id: Optional["capo_elasticache.types.string.String"] = None,
    subnet_ids: Optional[
        "capo_elasticache.types.subnet_ids_list.SubnetIdsList"
    ] = None,
    snapshot_retention_limit: Optional[
        "capo_elasticache.types.integer_optional.IntegerOptional"
    ] = None,
    daily_snapshot_time: Optional["capo_elasticache.types.string.String"] = None,
    network_type: Optional[
        "capo_elasticache.types.network_type.NetworkType"
    ] = None,
    connection_type: Optional[
        "capo_elasticache.types.connection_type.ConnectionType"
    ] = None,
) -> "capo_elasticache.types.create_serverless_cache_response.CreateServerlessCacheResponse":
    """<p>Creates a serverless cache.</p>

    Args:
        serverless_cache_name: <p>User-provided identifier for the serverless cache. This parameter is stored as a lowercase string.</p>
        description: <p>User-provided description for the serverless cache. The default is NULL, i.e. if no description is provided then an empty string will be returned. The maximum length is 255 characters. </p>
        engine: <p>The name of the cache engine to be used for creating the serverless cache.</p>
        major_engine_version: <p>The version of the cache engine that will be used to create the serverless cache.</p>
        cache_usage_limits: <p>Sets the cache usage limits for storage and ElastiCache Processing Units for the cache.</p>
        kms_key_id: <p>ARN of the customer managed key for encrypting the data at rest. If no KMS key is provided, a default service key is used.</p>
        security_group_ids: <p>A list of the one or more VPC security groups to be associated with the serverless cache. The security group will authorize traffic access for the VPC end-point (private-link). If no other information is given this will be the VPC’s Default Security Group that is associated with the cluster VPC end-point.</p>
        snapshot_arns_to_restore: <p>The ARN(s) of the snapshot that the new serverless cache will be created from. Available for Valkey, Redis OSS and Serverless Memcached only.</p>
        tags: <p>The list of tags (key, value) pairs to be added to the serverless cache resource. Default is NULL.</p>
        user_group_id: <p>The identifier of the UserGroup to be associated with the serverless cache. Available for Valkey and Redis OSS only. Default is NULL.</p>
        subnet_ids: <p>A list of the identifiers of the subnets where the VPC endpoint for the serverless cache will be deployed. All the subnetIds must belong to the same VPC.</p>
        snapshot_retention_limit: <p>The number of days for which ElastiCache retains automatic snapshots before deleting them. Available for Valkey, Redis OSS and Serverless Memcached only. The maximum value allowed is 35 days.</p>
        daily_snapshot_time: <p>The daily time that snapshots will be created from the new serverless cache. By default this number is populated with 0, i.e. no snapshots will be created on an automatic daily basis. Available for Valkey, Redis OSS and Serverless Memcached only.</p>
        network_type: <p>The IP protocol version used by the serverless cache. Must be either <code>ipv4</code> | <code>ipv6</code> | <code>dual_stack</code>. <code>ipv6</code> is only supported with IPv6-only subnets. If not specified, defaults to <code>ipv4</code>, unless all provided subnets are IPv6-only, in which case it defaults to <code>ipv6</code>. </p>
        connection_type: <p>The connection type for the serverless cache. Must be either <code>vpc</code> | <code>public</code>. Use <code>vpc</code> to access the cache through a VPC endpoint, or <code>public</code> to access the cache over the internet. If not specified, defaults to <code>vpc</code>. This value cannot be changed after the serverless cache is created. Setting this to <code>public</code> requires Valkey 9 or above.</p>

    Raises:
        capo_elasticache.errors.invalid_credentials_exception.InvalidCredentialsException: <p>You must enter valid credentials.</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_serverless_cache_state_fault.InvalidServerlessCacheStateFault: <p>The account for these credentials is not currently active.</p>
        capo_elasticache.errors.invalid_user_group_state_fault.InvalidUserGroupStateFault: <p>The user group is not in an active state.</p>
        capo_elasticache.errors.serverless_cache_already_exists_fault.ServerlessCacheAlreadyExistsFault: <p>A serverless cache with this name already exists.</p>
        capo_elasticache.errors.serverless_cache_not_found_fault.ServerlessCacheNotFoundFault: <p>The serverless cache was not found or does not exist.</p>
        capo_elasticache.errors.serverless_cache_quota_for_customer_exceeded_fault.ServerlessCacheQuotaForCustomerExceededFault: <p>The number of serverless caches exceeds the customer quota.</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.tag_quota_per_resource_exceeded.TagQuotaPerResourceExceeded: <p>The request cannot be processed because it would cause the resource to have more than the allowed number of tags. The maximum number of tags permitted on a resource is 50.</p>
        capo_elasticache.errors.user_group_not_found_fault.UserGroupNotFoundFault: <p>The user group was not found or does not exist</p>
        capo_elasticache.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_elasticache.types.create_serverless_cache_request.CreateServerlessCacheRequest]",
    ) -> OperationResponse[
        "capo_elasticache.types.create_serverless_cache_response.CreateServerlessCacheResponse"
    ]:
        import capo_elasticache._operations.amazon_elasti_cache_v9.create_serverless_cache

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateServerlessCache")
    )
    input_: capo_elasticache.types.create_serverless_cache_request.CreateServerlessCacheRequest = {}
    if serverless_cache_name is not None:
        input_["serverless_cache_name"] = serverless_cache_name
    if description is not None:
        input_["description"] = description
    if engine is not None:
        input_["engine"] = engine
    if major_engine_version is not None:
        input_["major_engine_version"] = major_engine_version
    if cache_usage_limits is not None:
        input_["cache_usage_limits"] = cache_usage_limits
    if kms_key_id is not None:
        input_["kms_key_id"] = kms_key_id
    if security_group_ids is not None:
        input_["security_group_ids"] = security_group_ids
    if snapshot_arns_to_restore is not None:
        input_["snapshot_arns_to_restore"] = snapshot_arns_to_restore
    if tags is not None:
        input_["tags"] = tags
    if user_group_id is not None:
        input_["user_group_id"] = user_group_id
    if subnet_ids is not None:
        input_["subnet_ids"] = subnet_ids
    if snapshot_retention_limit is not None:
        input_["snapshot_retention_limit"] = snapshot_retention_limit
    if daily_snapshot_time is not None:
        input_["daily_snapshot_time"] = daily_snapshot_time
    if network_type is not None:
        input_["network_type"] = network_type
    if connection_type is not None:
        input_["connection_type"] = connection_type

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