createCluster method

Future<CreateClusterResponse> createCluster({
  1. required String hsmType,
  2. required List<String> subnetIds,
  3. BackupRetentionPolicy? backupRetentionPolicy,
  4. ClusterMode? mode,
  5. NetworkType? networkType,
  6. String? sourceBackupId,
  7. List<Tag>? tagList,
})

Creates a new CloudHSM cluster.

Cross-account use: Yes. To perform this operation with an CloudHSM backup in a different AWS account, specify the full backup ARN in the value of the SourceBackupId parameter.

May throw CloudHsmAccessDeniedException. May throw CloudHsmInternalFailureException. May throw CloudHsmInvalidRequestException. May throw CloudHsmResourceNotFoundException. May throw CloudHsmServiceException. May throw CloudHsmTagException.

Parameter hsmType : The type of HSM to use in the cluster. The allowed values are hsm1.medium and hsm2m.medium.

Parameter subnetIds : The identifiers (IDs) of the subnets where you are creating the cluster. You must specify at least one subnet. If you specify multiple subnets, they must meet the following criteria:

  • All subnets must be in the same virtual private cloud (VPC).
  • You can specify only one subnet per Availability Zone.

Parameter backupRetentionPolicy : A policy that defines how the service retains backups.

Parameter mode : The mode to use in the cluster. The allowed values are FIPS and NON_FIPS.

Parameter networkType : The NetworkType to create a cluster with. The allowed values are IPV4 and DUALSTACK.

Parameter sourceBackupId : The identifier (ID) or the Amazon Resource Name (ARN) of the cluster backup to restore. Use this value to restore the cluster from a backup instead of creating a new cluster. To find the backup ID or ARN, use DescribeBackups. If using a backup in another account, the full ARN must be supplied.

Parameter tagList : Tags to apply to the CloudHSM cluster during creation.

Implementation

Future<CreateClusterResponse> createCluster({
  required String hsmType,
  required List<String> subnetIds,
  BackupRetentionPolicy? backupRetentionPolicy,
  ClusterMode? mode,
  NetworkType? networkType,
  String? sourceBackupId,
  List<Tag>? tagList,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'BaldrApiService.CreateCluster'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'HsmType': hsmType,
      'SubnetIds': subnetIds,
      if (backupRetentionPolicy != null)
        'BackupRetentionPolicy': backupRetentionPolicy,
      if (mode != null) 'Mode': mode.value,
      if (networkType != null) 'NetworkType': networkType.value,
      if (sourceBackupId != null) 'SourceBackupId': sourceBackupId,
      if (tagList != null) 'TagList': tagList,
    },
  );

  return CreateClusterResponse.fromJson(jsonResponse.body);
}