CreateDBSubnetGroupCommand

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

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { DocDBClient, CreateDBSubnetGroupCommand } from "@aws-sdk/client-docdb"; // ES Modules import
// const { DocDBClient, CreateDBSubnetGroupCommand } = require("@aws-sdk/client-docdb"); // CommonJS import
const client = new DocDBClient(config);
const input = { // CreateDBSubnetGroupMessage
  DBSubnetGroupName: "STRING_VALUE", // required
  DBSubnetGroupDescription: "STRING_VALUE", // required
  SubnetIds: [ // SubnetIdentifierList // required
    "STRING_VALUE",
  ],
  Tags: [ // TagList
    { // Tag
      Key: "STRING_VALUE",
      Value: "STRING_VALUE",
    },
  ],
};
const command = new CreateDBSubnetGroupCommand(input);
const response = await client.send(command);
// { // CreateDBSubnetGroupResult
//   DBSubnetGroup: { // DBSubnetGroup
//     DBSubnetGroupName: "STRING_VALUE",
//     DBSubnetGroupDescription: "STRING_VALUE",
//     VpcId: "STRING_VALUE",
//     SubnetGroupStatus: "STRING_VALUE",
//     Subnets: [ // SubnetList
//       { // Subnet
//         SubnetIdentifier: "STRING_VALUE",
//         SubnetAvailabilityZone: { // AvailabilityZone
//           Name: "STRING_VALUE",
//         },
//         SubnetStatus: "STRING_VALUE",
//       },
//     ],
//     DBSubnetGroupArn: "STRING_VALUE",
//   },
// };

CreateDBSubnetGroupCommand Input

See CreateDBSubnetGroupCommandInput for more details

Parameter
Type
Description
DBSubnetGroupDescription
Required
string | undefined

The description for the subnet group.

DBSubnetGroupName
Required
string | undefined

The name for the 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.

Example: mySubnetgroup

SubnetIds
Required
string[] | undefined

The Amazon EC2 subnet IDs for the subnet group.

Tags
Tag[] | undefined

The tags to be assigned to the subnet group.

CreateDBSubnetGroupCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
DBSubnetGroup
DBSubnetGroup | undefined

Detailed information about a subnet group.

Throws

Name
Fault
Details
DBSubnetGroupAlreadyExistsFault
client

DBSubnetGroupName is already being used by an existing subnet group.

DBSubnetGroupDoesNotCoverEnoughAZs
client

Subnets in the subnet group should cover at least two Availability Zones unless there is only one Availability Zone.

DBSubnetGroupQuotaExceededFault
client

The request would cause you to exceed the allowed number of subnet groups.

DBSubnetQuotaExceededFault
client

The request would cause you to exceed the allowed number of subnets in a subnet group.

InvalidSubnet
client

The requested subnet is not valid, or multiple subnets were requested that are not all in a common virtual private cloud (VPC).

DocDBServiceException
Base exception class for all service exceptions from DocDB service.