Skip to content

create_subnet_group

create_subnet_group(
    subnet_group_name: String,
    subnet_ids: SubnetIdentifierList,
    *,
    config_overrides: Optional[MemoryDBClientConfig] = None,
    description: Optional[String] = None,
    tags: Optional[TagList] = None,
) -> CreateSubnetGroupResponse

Creates a subnet group. A subnet group is a collection of subnets (typically private) that you can designate for your clusters running in an Amazon Virtual Private Cloud (VPC) environment. When you create a cluster in an Amazon VPC, you must specify a subnet group. MemoryDB uses that subnet group to choose a subnet and IP addresses within that subnet to associate with your nodes. For more information, see Subnets and subnet groups.

Parameters:

  • subnet_group_name (String) –

    The name of the subnet group.

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

    A description for the subnet group.

  • subnet_ids (SubnetIdentifierList) –

    A list of VPC subnet IDs for the 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:

Source code in docs_src/capo_memorydb/_services/memory_db.py
def create_subnet_group(
    self,
    subnet_group_name: "capo_memorydb.types.string.String",
    subnet_ids: "capo_memorydb.types.subnet_identifier_list.SubnetIdentifierList",
    *,
    config_overrides: Optional[MemoryDBClientConfig] = None,
    description: Optional["capo_memorydb.types.string.String"] = None,
    tags: Optional["capo_memorydb.types.tag_list.TagList"] = None,
) -> "capo_memorydb.types.create_subnet_group_response.CreateSubnetGroupResponse":
    """<p>Creates a subnet group. A subnet group is a collection of subnets (typically private) that you can designate for your clusters running in an Amazon Virtual Private Cloud (VPC) environment. When you create a cluster in an Amazon VPC, you must specify a subnet group. MemoryDB uses that subnet group to choose a subnet and IP addresses within that subnet to associate with your nodes. For more information, see <a href="https://docs.aws.amazon.com/MemoryDB/latest/devguide/subnetgroups.html">Subnets and subnet groups</a>.</p>

    Args:
        subnet_group_name: <p>The name of the subnet group.</p>
        description: <p>A description for the subnet group.</p>
        subnet_ids: <p>A list of VPC subnet IDs for the 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_memorydb.errors.invalid_subnet.InvalidSubnet: <p>The specified subnet is not valid.</p>
        capo_memorydb.errors.service_linked_role_not_found_fault.ServiceLinkedRoleNotFoundFault: <p>The required service-linked role was not found.</p>
        capo_memorydb.errors.subnet_group_already_exists_fault.SubnetGroupAlreadyExistsFault: <p>A subnet group with the specified name already exists.</p>
        capo_memorydb.errors.subnet_group_quota_exceeded_fault.SubnetGroupQuotaExceededFault: <p>The request cannot be processed because it would exceed the maximum number of subnet groups allowed.</p>
        capo_memorydb.errors.subnet_not_allowed_fault.SubnetNotAllowedFault: <p>The specified subnet is not allowed for this operation.</p>
        capo_memorydb.errors.subnet_quota_exceeded_fault.SubnetQuotaExceededFault: <p>The request cannot be processed because it would exceed the maximum number of subnets allowed.</p>
        capo_memorydb.errors.tag_quota_per_resource_exceeded.TagQuotaPerResourceExceeded: <p>The request cannot be processed because it would exceed the maximum number of tags allowed per resource.</p>
        capo_memorydb.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_memorydb.types.create_subnet_group_request.CreateSubnetGroupRequest]",
    ) -> OperationResponse[
        "capo_memorydb.types.create_subnet_group_response.CreateSubnetGroupResponse"
    ]:
        import capo_memorydb._operations.amazon_memory_db.create_subnet_group

        output, http_response = (
            capo_memorydb._operations.amazon_memory_db.create_subnet_group.create_subnet_group(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSubnetGroup")
    )
    input_: capo_memorydb.types.create_subnet_group_request.CreateSubnetGroupRequest = {
        "subnet_group_name": subnet_group_name,
        "subnet_ids": subnet_ids,
    }
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags

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