1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package sagemaker
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/sagemaker/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates a Domain used by Amazon SageMaker Studio. A domain consists of an
15// associated Amazon Elastic File System (EFS) volume, a list of authorized users,
16// and a variety of security, application, policy, and Amazon Virtual Private Cloud
17// (VPC) configurations. An AWS account is limited to one domain per region. Users
18// within a domain can share notebook files and other artifacts with each other.
19// EFS storage When a domain is created, an EFS volume is created for use by all of
20// the users within the domain. Each user receives a private home directory within
21// the EFS volume for notebooks, Git repositories, and data files. SageMaker uses
22// the AWS Key Management Service (AWS KMS) to encrypt the EFS volume attached to
23// the domain with an AWS managed customer master key (CMK) by default. For more
24// control, you can specify a customer managed CMK. For more information, see
25// Protect Data at Rest Using Encryption
26// (https://docs.aws.amazon.com/sagemaker/latest/dg/encryption-at-rest.html). VPC
27// configuration All SageMaker Studio traffic between the domain and the EFS volume
28// is through the specified VPC and subnets. For other Studio traffic, you can
29// specify the AppNetworkAccessType parameter. AppNetworkAccessType corresponds to
30// the network access type that you choose when you onboard to Studio. The
31// following options are available:
32//
33// * PublicInternetOnly - Non-EFS traffic goes
34// through a VPC managed by Amazon SageMaker, which allows internet access. This is
35// the default value.
36//
37// * VpcOnly - All Studio traffic is through the specified VPC
38// and subnets. Internet access is disabled by default. To allow internet access,
39// you must specify a NAT gateway. When internet access is disabled, you won't be
40// able to run a Studio notebook or to train or host models unless your VPC has an
41// interface endpoint to the SageMaker API and runtime or a NAT gateway and your
42// security groups allow outbound connections.
43//
44// For more information, see Connect
45// SageMaker Studio Notebooks to Resources in a VPC
46// (https://docs.aws.amazon.com/sagemaker/latest/dg/studio-notebooks-and-internet-access.html).
47func (c *Client) CreateDomain(ctx context.Context, params *CreateDomainInput, optFns ...func(*Options)) (*CreateDomainOutput, error) {
48	if params == nil {
49		params = &CreateDomainInput{}
50	}
51
52	result, metadata, err := c.invokeOperation(ctx, "CreateDomain", params, optFns, addOperationCreateDomainMiddlewares)
53	if err != nil {
54		return nil, err
55	}
56
57	out := result.(*CreateDomainOutput)
58	out.ResultMetadata = metadata
59	return out, nil
60}
61
62type CreateDomainInput struct {
63
64	// The mode of authentication that members use to access the domain.
65	//
66	// This member is required.
67	AuthMode types.AuthMode
68
69	// The default settings to use to create a user profile when UserSettings isn't
70	// specified in the call to the CreateUserProfile API. SecurityGroups is aggregated
71	// when specified in both calls. For all other settings in UserSettings, the values
72	// specified in CreateUserProfile take precedence over those specified in
73	// CreateDomain.
74	//
75	// This member is required.
76	DefaultUserSettings *types.UserSettings
77
78	// A name for the domain.
79	//
80	// This member is required.
81	DomainName *string
82
83	// The VPC subnets that Studio uses for communication.
84	//
85	// This member is required.
86	SubnetIds []string
87
88	// The ID of the Amazon Virtual Private Cloud (VPC) that Studio uses for
89	// communication.
90	//
91	// This member is required.
92	VpcId *string
93
94	// Specifies the VPC used for non-EFS traffic. The default value is
95	// PublicInternetOnly.
96	//
97	// * PublicInternetOnly - Non-EFS traffic is through a VPC
98	// managed by Amazon SageMaker, which allows direct internet access
99	//
100	// * VpcOnly -
101	// All Studio traffic is through the specified VPC and subnets
102	AppNetworkAccessType types.AppNetworkAccessType
103
104	// This member is deprecated and replaced with KmsKeyId.
105	//
106	// Deprecated: This property is deprecated, use KmsKeyId instead.
107	HomeEfsFileSystemKmsKeyId *string
108
109	// SageMaker uses AWS KMS to encrypt the EFS volume attached to the domain with an
110	// AWS managed customer master key (CMK) by default. For more control, specify a
111	// customer managed CMK.
112	KmsKeyId *string
113
114	// Tags to associated with the Domain. Each tag consists of a key and an optional
115	// value. Tag keys must be unique per resource. Tags are searchable using the
116	// Search API.
117	Tags []types.Tag
118}
119
120type CreateDomainOutput struct {
121
122	// The Amazon Resource Name (ARN) of the created domain.
123	DomainArn *string
124
125	// The URL to the created domain.
126	Url *string
127
128	// Metadata pertaining to the operation's result.
129	ResultMetadata middleware.Metadata
130}
131
132func addOperationCreateDomainMiddlewares(stack *middleware.Stack, options Options) (err error) {
133	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateDomain{}, middleware.After)
134	if err != nil {
135		return err
136	}
137	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateDomain{}, middleware.After)
138	if err != nil {
139		return err
140	}
141	if err = addSetLoggerMiddleware(stack, options); err != nil {
142		return err
143	}
144	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
145		return err
146	}
147	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
148		return err
149	}
150	if err = addResolveEndpointMiddleware(stack, options); err != nil {
151		return err
152	}
153	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
154		return err
155	}
156	if err = addRetryMiddlewares(stack, options); err != nil {
157		return err
158	}
159	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
160		return err
161	}
162	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
163		return err
164	}
165	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
166		return err
167	}
168	if err = addClientUserAgent(stack); err != nil {
169		return err
170	}
171	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
172		return err
173	}
174	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
175		return err
176	}
177	if err = addOpCreateDomainValidationMiddleware(stack); err != nil {
178		return err
179	}
180	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateDomain(options.Region), middleware.Before); err != nil {
181		return err
182	}
183	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
184		return err
185	}
186	if err = addResponseErrorMiddleware(stack); err != nil {
187		return err
188	}
189	if err = addRequestResponseLogging(stack, options); err != nil {
190		return err
191	}
192	return nil
193}
194
195func newServiceMetadataMiddleware_opCreateDomain(region string) *awsmiddleware.RegisterServiceMetadata {
196	return &awsmiddleware.RegisterServiceMetadata{
197		Region:        region,
198		ServiceID:     ServiceID,
199		SigningName:   "sagemaker",
200		OperationName: "CreateDomain",
201	}
202}
203