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 an Amazon SageMaker notebook instance. A notebook instance is a machine 15// learning (ML) compute instance running on a Jupyter notebook. In a 16// CreateNotebookInstance request, specify the type of ML compute instance that you 17// want to run. Amazon SageMaker launches the instance, installs common libraries 18// that you can use to explore datasets for model training, and attaches an ML 19// storage volume to the notebook instance. Amazon SageMaker also provides a set of 20// example notebooks. Each notebook demonstrates how to use Amazon SageMaker with a 21// specific algorithm or with a machine learning framework. After receiving the 22// request, Amazon SageMaker does the following: 23// 24// * Creates a network interface in 25// the Amazon SageMaker VPC. 26// 27// * (Option) If you specified SubnetId, Amazon 28// SageMaker creates a network interface in your own VPC, which is inferred from 29// the subnet ID that you provide in the input. When creating this network 30// interface, Amazon SageMaker attaches the security group that you specified in 31// the request to the network interface that it creates in your VPC. 32// 33// * Launches an 34// EC2 instance of the type specified in the request in the Amazon SageMaker VPC. 35// If you specified SubnetId of your VPC, Amazon SageMaker specifies both network 36// interfaces when launching this instance. This enables inbound traffic from your 37// own VPC to the notebook instance, assuming that the security groups allow 38// it. 39// 40// After creating the notebook instance, Amazon SageMaker returns its Amazon 41// Resource Name (ARN). You can't change the name of a notebook instance after you 42// create it. After Amazon SageMaker creates the notebook instance, you can connect 43// to the Jupyter server and work in Jupyter notebooks. For example, you can write 44// code to explore a dataset that you can use for model training, train a model, 45// host models by creating Amazon SageMaker endpoints, and validate hosted models. 46// For more information, see How It Works 47// (https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html). 48func (c *Client) CreateNotebookInstance(ctx context.Context, params *CreateNotebookInstanceInput, optFns ...func(*Options)) (*CreateNotebookInstanceOutput, error) { 49 if params == nil { 50 params = &CreateNotebookInstanceInput{} 51 } 52 53 result, metadata, err := c.invokeOperation(ctx, "CreateNotebookInstance", params, optFns, addOperationCreateNotebookInstanceMiddlewares) 54 if err != nil { 55 return nil, err 56 } 57 58 out := result.(*CreateNotebookInstanceOutput) 59 out.ResultMetadata = metadata 60 return out, nil 61} 62 63type CreateNotebookInstanceInput struct { 64 65 // The type of ML compute instance to launch for the notebook instance. 66 // 67 // This member is required. 68 InstanceType types.InstanceType 69 70 // The name of the new notebook instance. 71 // 72 // This member is required. 73 NotebookInstanceName *string 74 75 // When you send any requests to AWS resources from the notebook instance, Amazon 76 // SageMaker assumes this role to perform tasks on your behalf. You must grant this 77 // role necessary permissions so Amazon SageMaker can perform these tasks. The 78 // policy must allow the Amazon SageMaker service principal 79 // (sagemaker.amazonaws.com) permissions to assume this role. For more information, 80 // see Amazon SageMaker Roles 81 // (https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html). To be 82 // able to pass this role to Amazon SageMaker, the caller of this API must have the 83 // iam:PassRole permission. 84 // 85 // This member is required. 86 RoleArn *string 87 88 // A list of Elastic Inference (EI) instance types to associate with this notebook 89 // instance. Currently, only one instance type can be associated with a notebook 90 // instance. For more information, see Using Elastic Inference in Amazon SageMaker 91 // (https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html). 92 AcceleratorTypes []types.NotebookInstanceAcceleratorType 93 94 // An array of up to three Git repositories to associate with the notebook 95 // instance. These can be either the names of Git repositories stored as resources 96 // in your account, or the URL of Git repositories in AWS CodeCommit 97 // (https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html) or in any 98 // other Git repository. These repositories are cloned at the same level as the 99 // default repository of your notebook instance. For more information, see 100 // Associating Git Repositories with Amazon SageMaker Notebook Instances 101 // (https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html). 102 AdditionalCodeRepositories []string 103 104 // A Git repository to associate with the notebook instance as its default code 105 // repository. This can be either the name of a Git repository stored as a resource 106 // in your account, or the URL of a Git repository in AWS CodeCommit 107 // (https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html) or in any 108 // other Git repository. When you open a notebook instance, it opens in the 109 // directory that contains this repository. For more information, see Associating 110 // Git Repositories with Amazon SageMaker Notebook Instances 111 // (https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html). 112 DefaultCodeRepository *string 113 114 // Sets whether Amazon SageMaker provides internet access to the notebook instance. 115 // If you set this to Disabled this notebook instance will be able to access 116 // resources only in your VPC, and will not be able to connect to Amazon SageMaker 117 // training and endpoint services unless your configure a NAT Gateway in your VPC. 118 // For more information, see Notebook Instances Are Internet-Enabled by Default 119 // (https://docs.aws.amazon.com/sagemaker/latest/dg/appendix-additional-considerations.html#appendix-notebook-and-internet-access). 120 // You can set the value of this parameter to Disabled only if you set a value for 121 // the SubnetId parameter. 122 DirectInternetAccess types.DirectInternetAccess 123 124 // The Amazon Resource Name (ARN) of a AWS Key Management Service key that Amazon 125 // SageMaker uses to encrypt data on the storage volume attached to your notebook 126 // instance. The KMS key you provide must be enabled. For information, see Enabling 127 // and Disabling Keys 128 // (https://docs.aws.amazon.com/kms/latest/developerguide/enabling-keys.html) in 129 // the AWS Key Management Service Developer Guide. 130 KmsKeyId *string 131 132 // The name of a lifecycle configuration to associate with the notebook instance. 133 // For information about lifestyle configurations, see Step 2.1: (Optional) 134 // Customize a Notebook Instance 135 // (https://docs.aws.amazon.com/sagemaker/latest/dg/notebook-lifecycle-config.html). 136 LifecycleConfigName *string 137 138 // Whether root access is enabled or disabled for users of the notebook instance. 139 // The default value is Enabled. Lifecycle configurations need root access to be 140 // able to set up a notebook instance. Because of this, lifecycle configurations 141 // associated with a notebook instance always run with root access even if you 142 // disable root access for users. 143 RootAccess types.RootAccess 144 145 // The VPC security group IDs, in the form sg-xxxxxxxx. The security groups must be 146 // for the same VPC as specified in the subnet. 147 SecurityGroupIds []string 148 149 // The ID of the subnet in a VPC to which you would like to have a connectivity 150 // from your ML compute instance. 151 SubnetId *string 152 153 // An array of key-value pairs. You can use tags to categorize your AWS resources 154 // in different ways, for example, by purpose, owner, or environment. For more 155 // information, see Tagging AWS Resources 156 // (https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html). 157 Tags []types.Tag 158 159 // The size, in GB, of the ML storage volume to attach to the notebook instance. 160 // The default value is 5 GB. 161 VolumeSizeInGB *int32 162} 163 164type CreateNotebookInstanceOutput struct { 165 166 // The Amazon Resource Name (ARN) of the notebook instance. 167 NotebookInstanceArn *string 168 169 // Metadata pertaining to the operation's result. 170 ResultMetadata middleware.Metadata 171} 172 173func addOperationCreateNotebookInstanceMiddlewares(stack *middleware.Stack, options Options) (err error) { 174 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateNotebookInstance{}, middleware.After) 175 if err != nil { 176 return err 177 } 178 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateNotebookInstance{}, middleware.After) 179 if err != nil { 180 return err 181 } 182 if err = addSetLoggerMiddleware(stack, options); err != nil { 183 return err 184 } 185 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 186 return err 187 } 188 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 189 return err 190 } 191 if err = addResolveEndpointMiddleware(stack, options); err != nil { 192 return err 193 } 194 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 195 return err 196 } 197 if err = addRetryMiddlewares(stack, options); err != nil { 198 return err 199 } 200 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 201 return err 202 } 203 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 204 return err 205 } 206 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 207 return err 208 } 209 if err = addClientUserAgent(stack); err != nil { 210 return err 211 } 212 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 213 return err 214 } 215 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 216 return err 217 } 218 if err = addOpCreateNotebookInstanceValidationMiddleware(stack); err != nil { 219 return err 220 } 221 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateNotebookInstance(options.Region), middleware.Before); err != nil { 222 return err 223 } 224 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 225 return err 226 } 227 if err = addResponseErrorMiddleware(stack); err != nil { 228 return err 229 } 230 if err = addRequestResponseLogging(stack, options); err != nil { 231 return err 232 } 233 return nil 234} 235 236func newServiceMetadataMiddleware_opCreateNotebookInstance(region string) *awsmiddleware.RegisterServiceMetadata { 237 return &awsmiddleware.RegisterServiceMetadata{ 238 Region: region, 239 ServiceID: ServiceID, 240 SigningName: "sagemaker", 241 OperationName: "CreateNotebookInstance", 242 } 243} 244