CreateSubnetGroupCommand

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 .

Example Syntax

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

import { MemoryDBClient, CreateSubnetGroupCommand } from "@aws-sdk/client-memorydb"; // ES Modules import
// const { MemoryDBClient, CreateSubnetGroupCommand } = require("@aws-sdk/client-memorydb"); // CommonJS import
const client = new MemoryDBClient(config);
const input = { // CreateSubnetGroupRequest
  SubnetGroupName: "STRING_VALUE", // required
  Description: "STRING_VALUE",
  SubnetIds: [ // SubnetIdentifierList // required
    "STRING_VALUE",
  ],
  Tags: [ // TagList
    { // Tag
      Key: "STRING_VALUE",
      Value: "STRING_VALUE",
    },
  ],
};
const command = new CreateSubnetGroupCommand(input);
const response = await client.send(command);
// { // CreateSubnetGroupResponse
//   SubnetGroup: { // SubnetGroup
//     Name: "STRING_VALUE",
//     Description: "STRING_VALUE",
//     VpcId: "STRING_VALUE",
//     Subnets: [ // SubnetList
//       { // Subnet
//         Identifier: "STRING_VALUE",
//         AvailabilityZone: { // AvailabilityZone
//           Name: "STRING_VALUE",
//         },
//       },
//     ],
//     ARN: "STRING_VALUE",
//   },
// };

CreateSubnetGroupCommand Input

See CreateSubnetGroupCommandInput for more details

Parameter
Type
Description
SubnetGroupName
Required
string | undefined

The name of the subnet group.

SubnetIds
Required
string[] | undefined

A list of VPC subnet IDs for the subnet group.

Description
string | undefined

A description for the subnet group.

Tags
Tag[] | undefined

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.

CreateSubnetGroupCommand Output

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

The newly-created subnet group.

Throws