:doc:`RDS <../../rds>` / Client / create_db_subnet_group

**********************
create_db_subnet_group
**********************



.. py:method:: RDS.Client.create_db_subnet_group(**kwargs)

  

  Creates a new DB subnet group. DB subnet groups must contain at least one subnet in at least two AZs in the Amazon Web Services Region.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/CreateDBSubnetGroup>`_  


  **Request Syntax**
  ::

    response = client.create_db_subnet_group(
        DBSubnetGroupName='string',
        DBSubnetGroupDescription='string',
        SubnetIds=[
            'string',
        ],
        Tags=[
            {
                'Key': 'string',
                'Value': 'string'
            },
        ]
    )
    
  :type DBSubnetGroupName: string
  :param DBSubnetGroupName: **[REQUIRED]** 

    The name for the DB subnet group. This value is stored as a lowercase string.

     

    Constraints:

     

    
    * Must contain no more than 255 letters, numbers, periods, underscores, spaces, or hyphens.
     
    * Must not be default.
     
    * First character must be a letter.
    

     

    Example: ``mydbsubnetgroup``

    

  
  :type DBSubnetGroupDescription: string
  :param DBSubnetGroupDescription: **[REQUIRED]** 

    The description for the DB subnet group.

    

  
  :type SubnetIds: list
  :param SubnetIds: **[REQUIRED]** 

    The EC2 Subnet IDs for the DB subnet group.

    

  
    - *(string) --* 

    

  :type Tags: list
  :param Tags: 

    Tags to assign to the DB subnet group.

    

  
    - *(dict) --* 

      Metadata assigned to an Amazon RDS resource consisting of a key-value pair.

       

      For more information, see `Tagging Amazon RDS resources <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html>`__ in the *Amazon RDS User Guide* or `Tagging Amazon Aurora and Amazon RDS resources <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_Tagging.html>`__ in the *Amazon Aurora User Guide*.

      

    
      - **Key** *(string) --* 

        A key is the required name of the tag. The string value can be from 1 to 128 Unicode characters in length and can't be prefixed with ``aws:`` or ``rds:``. The string can only contain only the set of Unicode letters, digits, white-space, '_', '.', ':', '/', '=', '+', '-', '@' (Java regex: "^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$").

        

      
      - **Value** *(string) --* 

        A value is the optional value of the tag. The string value can be from 1 to 256 Unicode characters in length and can't be prefixed with ``aws:`` or ``rds:``. The string can only contain only the set of Unicode letters, digits, white-space, '_', '.', ':', '/', '=', '+', '-', '@' (Java regex: "^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$").

        

      
    

  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'DBSubnetGroup': {
              'DBSubnetGroupName': 'string',
              'DBSubnetGroupDescription': 'string',
              'VpcId': 'string',
              'SubnetGroupStatus': 'string',
              'Subnets': [
                  {
                      'SubnetIdentifier': 'string',
                      'SubnetAvailabilityZone': {
                          'Name': 'string'
                      },
                      'SubnetOutpost': {
                          'Arn': 'string'
                      },
                      'SubnetStatus': 'string'
                  },
              ],
              'DBSubnetGroupArn': 'string',
              'SupportedNetworkTypes': [
                  'string',
              ]
          }
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **DBSubnetGroup** *(dict) --* 

        Contains the details of an Amazon RDS DB subnet group.

         

        This data type is used as a response element in the ``DescribeDBSubnetGroups`` action.

        
        

        - **DBSubnetGroupName** *(string) --* 

          The name of the DB subnet group.

          
        

        - **DBSubnetGroupDescription** *(string) --* 

          Provides the description of the DB subnet group.

          
        

        - **VpcId** *(string) --* 

          Provides the VpcId of the DB subnet group.

          
        

        - **SubnetGroupStatus** *(string) --* 

          Provides the status of the DB subnet group.

          
        

        - **Subnets** *(list) --* 

          Contains a list of ``Subnet`` elements. The list of subnets shown here might not reflect the current state of your VPC. For the most up-to-date information, we recommend checking your VPC configuration directly.

          
          

          - *(dict) --* 

            This data type is used as a response element for the ``DescribeDBSubnetGroups`` operation.

            
            

            - **SubnetIdentifier** *(string) --* 

              The identifier of the subnet.

              
            

            - **SubnetAvailabilityZone** *(dict) --* 

              Contains Availability Zone information.

               

              This data type is used as an element in the ``OrderableDBInstanceOption`` data type.

              
              

              - **Name** *(string) --* 

                The name of the Availability Zone.

                
          
            

            - **SubnetOutpost** *(dict) --* 

              If the subnet is associated with an Outpost, this value specifies the Outpost.

               

              For more information about RDS on Outposts, see `Amazon RDS on Amazon Web Services Outposts <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-on-outposts.html>`__ in the *Amazon RDS User Guide.*

              
              

              - **Arn** *(string) --* 

                The Amazon Resource Name (ARN) of the Outpost.

                
          
            

            - **SubnetStatus** *(string) --* 

              The status of the subnet.

              
        
      
        

        - **DBSubnetGroupArn** *(string) --* 

          The Amazon Resource Name (ARN) for the DB subnet group.

          
        

        - **SupportedNetworkTypes** *(list) --* 

          The network type of the DB subnet group.

           

          Valid values:

           

          
          * ``IPV4``
           
          * ``DUAL``
          

           

          A ``DBSubnetGroup`` can support only the IPv4 protocol or the IPv4 and the IPv6 protocols ( ``DUAL``).

           

          For more information, see `Working with a DB instance in a VPC <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.WorkingWithRDSInstanceinaVPC.html>`__ in the *Amazon RDS User Guide.*

          
          

          - *(string) --* 
      
    
  
  **Exceptions**
  
  *   :py:class:`RDS.Client.exceptions.DBSubnetGroupAlreadyExistsFault`

  
  *   :py:class:`RDS.Client.exceptions.DBSubnetGroupDoesNotCoverEnoughAZs`

  
  *   :py:class:`RDS.Client.exceptions.DBSubnetQuotaExceededFault`

  
  *   :py:class:`RDS.Client.exceptions.DBSubnetGroupQuotaExceededFault`

  
  *   :py:class:`RDS.Client.exceptions.InvalidSubnet`

  

  **Examples**

  This example creates a DB subnet group.
  ::

    response = client.create_db_subnet_group(
        DBSubnetGroupDescription='My DB subnet group',
        DBSubnetGroupName='mydbsubnetgroup',
        SubnetIds=[
            'subnet-1fab8a69',
            'subnet-d43a468c',
        ],
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'DBSubnetGroup': {
        },
        'ResponseMetadata': {
            '...': '...',
        },
    }

  