createDomain method

Future<CreateDomainResponse> createDomain({
  1. required AuthMode authMode,
  2. required UserSettings defaultUserSettings,
  3. required String domainName,
  4. AppNetworkAccessType? appNetworkAccessType,
  5. AppSecurityGroupManagement? appSecurityGroupManagement,
  6. DefaultSpaceSettings? defaultSpaceSettings,
  7. DomainSettings? domainSettings,
  8. HomeEfsFileSystemCreation? homeEfsFileSystemCreation,
  9. String? homeEfsFileSystemKmsKeyId,
  10. String? kmsKeyId,
  11. List<String>? subnetIds,
  12. TagPropagation? tagPropagation,
  13. List<Tag>? tags,
  14. String? vpcId,
})

Creates a Domain. A domain consists of an associated Amazon Elastic File System volume, a list of authorized users, and a variety of security, application, policy, and Amazon Virtual Private Cloud (VPC) configurations. Users within a domain can share notebook files and other artifacts with each other.

EFS storage

When a domain is created, an EFS volume is created for use by all of the users within the domain. Each user receives a private home directory within the EFS volume for notebooks, Git repositories, and data files.

SageMaker AI uses the Amazon Web Services Key Management Service (Amazon Web Services KMS) to encrypt the EFS volume attached to the domain with an Amazon Web Services managed key by default. For more control, you can specify a customer managed key. For more information, see Protect Data at Rest Using Encryption.

VPC configuration

All traffic between the domain and the Amazon EFS volume is through the specified VPC and subnets. For other traffic, you can specify the AppNetworkAccessType parameter. AppNetworkAccessType corresponds to the network access type that you choose when you onboard to the domain. The following options are available:

  • PublicInternetOnly - Non-EFS traffic goes through a VPC managed by Amazon SageMaker AI, which allows internet access. This is the default value.
  • VpcOnly - All traffic is through the specified VPC and subnets. Internet access is disabled by default. To allow internet access, you must specify a NAT gateway.

    When internet access is disabled, you won't be able to run a Amazon SageMaker AI Studio notebook or to train or host models unless your VPC has an interface endpoint to the SageMaker AI API and runtime or a NAT gateway and your security groups allow outbound connections.

For more information, see Connect Amazon SageMaker AI Studio Notebooks to Resources in a VPC.

May throw ResourceInUse. May throw ResourceLimitExceeded.

Parameter authMode : The mode of authentication that members use to access the domain.

Parameter defaultUserSettings : The default settings to use to create a user profile when UserSettings isn't specified in the call to the CreateUserProfile API.

SecurityGroups is aggregated when specified in both calls. For all other settings in UserSettings, the values specified in CreateUserProfile take precedence over those specified in CreateDomain.

Parameter domainName : A name for the domain.

Parameter appNetworkAccessType : Specifies the VPC used for non-EFS traffic. The default value is PublicInternetOnly.

  • PublicInternetOnly - Non-EFS traffic is through a VPC managed by Amazon SageMaker AI, which allows direct internet access
  • VpcOnly - All traffic is through the specified VPC and subnets

Parameter appSecurityGroupManagement : The entity that creates and manages the required security groups for inter-app communication in VPCOnly mode. Required when CreateDomain.AppNetworkAccessType is VPCOnly and DomainSettings.RStudioServerProDomainSettings.DomainExecutionRoleArn is provided. If setting up the domain for use with RStudio, this value must be set to Service.

Parameter defaultSpaceSettings : The default settings for shared spaces that users create in the domain.

Parameter domainSettings : A collection of Domain settings.

Parameter homeEfsFileSystemCreation : Indicates whether to create a home EFS file system for the domain. Defaults to Enabled. Set to Disabled to skip EFS creation and reduce domain creation time. You can enable EFS later by calling UpdateDomain.

Parameter homeEfsFileSystemKmsKeyId : Use KmsKeyId.

Parameter kmsKeyId : SageMaker AI uses Amazon Web Services KMS to encrypt EFS and EBS volumes attached to the domain with an Amazon Web Services managed key by default. For more control, specify a customer managed key.

Parameter subnetIds : The VPC subnets that the domain uses for communication.

The field is optional when the AppNetworkAccessType parameter is set to PublicInternetOnly for domains created from Amazon SageMaker Unified Studio.

Parameter tagPropagation : Indicates whether custom tag propagation is supported for the domain. Defaults to DISABLED.

Parameter tags : Tags to associated with the Domain. Each tag consists of a key and an optional value. Tag keys must be unique per resource. Tags are searchable using the Search API.

Tags that you specify for the Domain are also added to all Apps that the Domain launches.

Parameter vpcId : The ID of the Amazon Virtual Private Cloud (VPC) that the domain uses for communication.

The field is optional when the AppNetworkAccessType parameter is set to PublicInternetOnly for domains created from Amazon SageMaker Unified Studio.

Implementation

Future<CreateDomainResponse> createDomain({
  required AuthMode authMode,
  required UserSettings defaultUserSettings,
  required String domainName,
  AppNetworkAccessType? appNetworkAccessType,
  AppSecurityGroupManagement? appSecurityGroupManagement,
  DefaultSpaceSettings? defaultSpaceSettings,
  DomainSettings? domainSettings,
  HomeEfsFileSystemCreation? homeEfsFileSystemCreation,
  String? homeEfsFileSystemKmsKeyId,
  String? kmsKeyId,
  List<String>? subnetIds,
  TagPropagation? tagPropagation,
  List<Tag>? tags,
  String? vpcId,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'SageMaker.CreateDomain'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'AuthMode': authMode.value,
      'DefaultUserSettings': defaultUserSettings,
      'DomainName': domainName,
      if (appNetworkAccessType != null)
        'AppNetworkAccessType': appNetworkAccessType.value,
      if (appSecurityGroupManagement != null)
        'AppSecurityGroupManagement': appSecurityGroupManagement.value,
      if (defaultSpaceSettings != null)
        'DefaultSpaceSettings': defaultSpaceSettings,
      if (domainSettings != null) 'DomainSettings': domainSettings,
      if (homeEfsFileSystemCreation != null)
        'HomeEfsFileSystemCreation': homeEfsFileSystemCreation.value,
      if (homeEfsFileSystemKmsKeyId != null)
        'HomeEfsFileSystemKmsKeyId': homeEfsFileSystemKmsKeyId,
      if (kmsKeyId != null) 'KmsKeyId': kmsKeyId,
      if (subnetIds != null) 'SubnetIds': subnetIds,
      if (tagPropagation != null) 'TagPropagation': tagPropagation.value,
      if (tags != null) 'Tags': tags,
      if (vpcId != null) 'VpcId': vpcId,
    },
  );

  return CreateDomainResponse.fromJson(jsonResponse.body);
}