createSubnetGroup method

Future<CreateSubnetGroupResponse> createSubnetGroup({
  1. required String subnetGroupName,
  2. required List<String> subnetIds,
  3. String? description,
  4. List<Tag>? tags,
})

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.

May throw InvalidSubnet. May throw ServiceLinkedRoleNotFoundFault. May throw SubnetGroupAlreadyExistsFault. May throw SubnetGroupQuotaExceededFault. May throw SubnetNotAllowedFault. May throw SubnetQuotaExceededFault. May throw TagQuotaPerResourceExceeded.

Parameter subnetGroupName : The name of the subnet group.

Parameter subnetIds : A list of VPC subnet IDs for the subnet group.

Parameter description : A description for the subnet group.

Parameter tags : 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.

Implementation

Future<CreateSubnetGroupResponse> createSubnetGroup({
  required String subnetGroupName,
  required List<String> subnetIds,
  String? description,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonMemoryDB.CreateSubnetGroup'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'SubnetGroupName': subnetGroupName,
      'SubnetIds': subnetIds,
      if (description != null) 'Description': description,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateSubnetGroupResponse.fromJson(jsonResponse.body);
}