ElastiCache / Client / create_cache_subnet_group

create_cache_subnet_group#

ElastiCache.Client.create_cache_subnet_group(**kwargs)#

Creates a new cache subnet group.

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

See also: AWS API Documentation

Request Syntax

response = client.create_cache_subnet_group(
    CacheSubnetGroupName='string',
    CacheSubnetGroupDescription='string',
    SubnetIds=[
        'string',
    ],
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
Parameters:
  • CacheSubnetGroupName (string) –

    [REQUIRED]

    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

  • CacheSubnetGroupDescription (string) –

    [REQUIRED]

    A description for the cache subnet group.

  • SubnetIds (list) –

    [REQUIRED]

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

    • (string) –

  • Tags (list) –

    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.

    • (dict) –

      A tag that can be added to an ElastiCache cluster or replication group. Tags are composed of a Key/Value pair. You can use tags to categorize and track all your ElastiCache resources, with the exception of global replication group. When you add or remove tags on replication groups, those actions will be replicated to all nodes in the replication group. A tag with a null Value is permitted.

      • Key (string) –

        The key for the tag. May not be null.

      • Value (string) –

        The tag’s value. May be null.

Return type:

dict

Returns:

Response Syntax

{
    'CacheSubnetGroup': {
        'CacheSubnetGroupName': 'string',
        'CacheSubnetGroupDescription': 'string',
        'VpcId': 'string',
        'Subnets': [
            {
                'SubnetIdentifier': 'string',
                'SubnetAvailabilityZone': {
                    'Name': 'string'
                },
                'SubnetOutpost': {
                    'SubnetOutpostArn': 'string'
                },
                'SupportedNetworkTypes': [
                    'ipv4'|'ipv6'|'dual_stack',
                ]
            },
        ],
        'ARN': 'string',
        'SupportedNetworkTypes': [
            'ipv4'|'ipv6'|'dual_stack',
        ]
    }
}

Response Structure

  • (dict) –

    • CacheSubnetGroup (dict) –

      Represents the output of one of the following operations:

      • CreateCacheSubnetGroup

      • ModifyCacheSubnetGroup

      • CacheSubnetGroupName (string) –

        The name of the cache subnet group.

      • CacheSubnetGroupDescription (string) –

        The description of the cache subnet group.

      • VpcId (string) –

        The Amazon Virtual Private Cloud identifier (VPC ID) of the cache subnet group.

      • Subnets (list) –

        A list of subnets associated with the cache subnet group.

        • (dict) –

          Represents the subnet associated with a cluster. This parameter refers to subnets defined in Amazon Virtual Private Cloud (Amazon VPC) and used with ElastiCache.

          • SubnetIdentifier (string) –

            The unique identifier for the subnet.

          • SubnetAvailabilityZone (dict) –

            The Availability Zone associated with the subnet.

            • Name (string) –

              The name of the Availability Zone.

          • SubnetOutpost (dict) –

            The outpost ARN of the subnet.

            • SubnetOutpostArn (string) –

              The outpost ARN of the subnet.

          • SupportedNetworkTypes (list) –

            Either ipv4 | ipv6 | dual_stack. IPv6 is supported for workloads using Redis engine version 6.2 onward or Memcached engine version 1.6.6 on all instances built on the Nitro system.

            • (string) –

      • ARN (string) –

        The ARN (Amazon Resource Name) of the cache subnet group.

      • SupportedNetworkTypes (list) –

        Either ipv4 | ipv6 | dual_stack. IPv6 is supported for workloads using Redis engine version 6.2 onward or Memcached engine version 1.6.6 on all instances built on the Nitro system.

        • (string) –

Exceptions

  • ElastiCache.Client.exceptions.CacheSubnetGroupAlreadyExistsFault

  • ElastiCache.Client.exceptions.CacheSubnetGroupQuotaExceededFault

  • ElastiCache.Client.exceptions.CacheSubnetQuotaExceededFault

  • ElastiCache.Client.exceptions.TagQuotaPerResourceExceeded

  • ElastiCache.Client.exceptions.InvalidSubnet

  • ElastiCache.Client.exceptions.SubnetNotAllowedFault

Examples

Creates a new cache subnet group.

response = client.create_cache_subnet_group(
    CacheSubnetGroupDescription='Sample subnet group',
    CacheSubnetGroupName='my-sn-grp2',
    SubnetIds=[
        'subnet-6f28c982',
        'subnet-bcd382f3',
        'subnet-845b3e7c0',
    ],
)

print(response)

Expected Output:

{
    'CacheSubnetGroup': {
        'CacheSubnetGroupDescription': 'My subnet group.',
        'CacheSubnetGroupName': 'my-sn-grp',
        'Subnets': [
            {
                'SubnetAvailabilityZone': {
                    'Name': 'us-east-1a',
                },
                'SubnetIdentifier': 'subnet-6f28c982',
            },
            {
                'SubnetAvailabilityZone': {
                    'Name': 'us-east-1c',
                },
                'SubnetIdentifier': 'subnet-bcd382f3',
            },
            {
                'SubnetAvailabilityZone': {
                    'Name': 'us-east-1b',
                },
                'SubnetIdentifier': 'subnet-845b3e7c0',
            },
        ],
        'VpcId': 'vpc-91280df6',
    },
    'ResponseMetadata': {
        '...': '...',
    },
}