Skip to content

create_cache_subnet_group async

create_cache_subnet_group(
    *,
    config_overrides: Optional[AsyncElastiCacheClientConfig] = None,
    cache_subnet_group_name: Optional[String] = None,
    cache_subnet_group_description: Optional[String] = None,
    subnet_ids: Optional[SubnetIdentifierList] = None,
    tags: Optional[TagList] = None,
) -> CreateCacheSubnetGroupResult

Creates a new cache subnet group.

Use this parameter only when you are creating a cluster in an Amazon Virtual Private Cloud (Amazon VPC).

Parameters:

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

    A name for the cache subnet group. This value is stored as a lowercase string.

    Constraints: Must contain no more than 255 alphanumeric characters or hyphens.

    Example: mysubnetgroup

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

    A description for the cache subnet group.

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

    A list of VPC subnet IDs for the cache subnet group.

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

    A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be accompanied by a tag value, although null is accepted.

Raises:

  • CacheSubnetGroupAlreadyExistsFault –

    The requested cache subnet group name is already in use by an existing cache subnet group.

  • CacheSubnetGroupQuotaExceededFault –

    The request cannot be processed because it would exceed the allowed number of cache subnet groups.

  • CacheSubnetQuotaExceededFault –

    The request cannot be processed because it would exceed the allowed number of subnets in a cache subnet group.

  • InvalidSubnet –

    An invalid subnet identifier was specified.

  • SubnetNotAllowedFault –

    At least one subnet ID does not match the other subnet IDs. This mismatch typically occurs when a user sets one subnet ID to a regional Availability Zone and a different one to an outpost. Or when a user sets the subnet ID to an Outpost when not subscribed on this service.

  • TagQuotaPerResourceExceeded –

    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.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

CreateCacheSubnet Creates a new cache subnet group.

>>> await client.create_cache_subnet_group(cache_subnet_group_name='my-sn-grp2', cache_subnet_group_description='Sample subnet group', subnet_ids=['subnet-6f28c982', 'subnet-bcd382f3', 'subnet-845b3e7c0'])
Source code in docs_src/capo_elasticache/_services/async_elasti_cache.py
async def create_cache_subnet_group(
    self,
    *,
    config_overrides: Optional[AsyncElastiCacheClientConfig] = None,
    cache_subnet_group_name: Optional[
        "capo_elasticache.types.string.String"
    ] = None,
    cache_subnet_group_description: Optional[
        "capo_elasticache.types.string.String"
    ] = None,
    subnet_ids: Optional[
        "capo_elasticache.types.subnet_identifier_list.SubnetIdentifierList"
    ] = None,
    tags: Optional["capo_elasticache.types.tag_list.TagList"] = None,
) -> "capo_elasticache.types.create_cache_subnet_group_result.CreateCacheSubnetGroupResult":
    """<p>Creates a new cache subnet group.</p> <p>Use this parameter only when you are creating a cluster in an Amazon Virtual Private Cloud (Amazon VPC).</p>

    Args:
        cache_subnet_group_name: <p>A name for the cache subnet group. This value is stored as a lowercase string.</p> <p>Constraints: Must contain no more than 255 alphanumeric characters or hyphens.</p> <p>Example: <code>mysubnetgroup</code> </p>
        cache_subnet_group_description: <p>A description for the cache subnet group.</p>
        subnet_ids: <p>A list of VPC subnet IDs for the cache subnet group.</p>
        tags: <p>A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be accompanied by a tag value, although null is accepted.</p>

    Raises:
        capo_elasticache.errors.cache_subnet_group_already_exists_fault.CacheSubnetGroupAlreadyExistsFault: <p>The requested cache subnet group name is already in use by an existing cache subnet group.</p>
        capo_elasticache.errors.cache_subnet_group_quota_exceeded_fault.CacheSubnetGroupQuotaExceededFault: <p>The request cannot be processed because it would exceed the allowed number of cache subnet groups.</p>
        capo_elasticache.errors.cache_subnet_quota_exceeded_fault.CacheSubnetQuotaExceededFault: <p>The request cannot be processed because it would exceed the allowed number of subnets in a cache subnet group.</p>
        capo_elasticache.errors.invalid_subnet.InvalidSubnet: <p>An invalid subnet identifier was specified.</p>
        capo_elasticache.errors.subnet_not_allowed_fault.SubnetNotAllowedFault: <p>At least one subnet ID does not match the other subnet IDs. This mismatch typically occurs when a user sets one subnet ID to a regional Availability Zone and a different one to an outpost. Or when a user sets the subnet ID to an Outpost when not subscribed on this service.</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.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        CreateCacheSubnet
        Creates a new cache subnet group.

        >>> await client.create_cache_subnet_group(cache_subnet_group_name='my-sn-grp2', cache_subnet_group_description='Sample subnet group', subnet_ids=['subnet-6f28c982', 'subnet-bcd382f3', 'subnet-845b3e7c0'])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_elasticache.types.create_cache_subnet_group_message.CreateCacheSubnetGroupMessage]",
    ) -> AsyncOperationResponse[
        "capo_elasticache.types.create_cache_subnet_group_result.CreateCacheSubnetGroupResult"
    ]:
        import capo_elasticache._operations.amazon_elasti_cache_v9.create_cache_subnet_group

        (
            output,
            http_response,
        ) = await capo_elasticache._operations.amazon_elasti_cache_v9.create_cache_subnet_group.async_create_cache_subnet_group(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateCacheSubnetGroup")
    )
    input_: capo_elasticache.types.create_cache_subnet_group_message.CreateCacheSubnetGroupMessage = {}
    if cache_subnet_group_name is not None:
        input_["cache_subnet_group_name"] = cache_subnet_group_name
    if cache_subnet_group_description is not None:
        input_["cache_subnet_group_description"] = cache_subnet_group_description
    if subnet_ids is not None:
        input_["subnet_ids"] = subnet_ids
    if tags is not None:
        input_["tags"] = tags

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output