github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/sagemaker/model.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package sagemaker
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Provides a SageMaker model resource.
    16  //
    17  // ## Example Usage
    18  //
    19  // Basic usage:
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sagemaker"
    29  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    30  //
    31  // )
    32  //
    33  //	func main() {
    34  //		pulumi.Run(func(ctx *pulumi.Context) error {
    35  //			assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    36  //				Statements: []iam.GetPolicyDocumentStatement{
    37  //					{
    38  //						Actions: []string{
    39  //							"sts:AssumeRole",
    40  //						},
    41  //						Principals: []iam.GetPolicyDocumentStatementPrincipal{
    42  //							{
    43  //								Type: "Service",
    44  //								Identifiers: []string{
    45  //									"sagemaker.amazonaws.com",
    46  //								},
    47  //							},
    48  //						},
    49  //					},
    50  //				},
    51  //			}, nil)
    52  //			if err != nil {
    53  //				return err
    54  //			}
    55  //			exampleRole, err := iam.NewRole(ctx, "example", &iam.RoleArgs{
    56  //				AssumeRolePolicy: pulumi.String(assumeRole.Json),
    57  //			})
    58  //			if err != nil {
    59  //				return err
    60  //			}
    61  //			test, err := sagemaker.GetPrebuiltEcrImage(ctx, &sagemaker.GetPrebuiltEcrImageArgs{
    62  //				RepositoryName: "kmeans",
    63  //			}, nil)
    64  //			if err != nil {
    65  //				return err
    66  //			}
    67  //			_, err = sagemaker.NewModel(ctx, "example", &sagemaker.ModelArgs{
    68  //				Name:             pulumi.String("my-model"),
    69  //				ExecutionRoleArn: exampleRole.Arn,
    70  //				PrimaryContainer: &sagemaker.ModelPrimaryContainerArgs{
    71  //					Image: pulumi.String(test.RegistryPath),
    72  //				},
    73  //			})
    74  //			if err != nil {
    75  //				return err
    76  //			}
    77  //			return nil
    78  //		})
    79  //	}
    80  //
    81  // ```
    82  // <!--End PulumiCodeChooser -->
    83  //
    84  // ## Inference Execution Config
    85  //
    86  // * `mode` - (Required) How containers in a multi-container are run. The following values are valid `Serial` and `Direct`.
    87  //
    88  // ## Import
    89  //
    90  // Using `pulumi import`, import models using the `name`. For example:
    91  //
    92  // ```sh
    93  // $ pulumi import aws:sagemaker/model:Model test_model model-foo
    94  // ```
    95  type Model struct {
    96  	pulumi.CustomResourceState
    97  
    98  	// The Amazon Resource Name (ARN) assigned by AWS to this model.
    99  	Arn pulumi.StringOutput `pulumi:"arn"`
   100  	// Specifies containers in the inference pipeline. If not specified, the `primaryContainer` argument is required. Fields are documented below.
   101  	Containers ModelContainerArrayOutput `pulumi:"containers"`
   102  	// Isolates the model container. No inbound or outbound network calls can be made to or from the model container.
   103  	EnableNetworkIsolation pulumi.BoolPtrOutput `pulumi:"enableNetworkIsolation"`
   104  	// A role that SageMaker can assume to access model artifacts and docker images for deployment.
   105  	ExecutionRoleArn pulumi.StringOutput `pulumi:"executionRoleArn"`
   106  	// Specifies details of how containers in a multi-container endpoint are called. see Inference Execution Config.
   107  	InferenceExecutionConfig ModelInferenceExecutionConfigOutput `pulumi:"inferenceExecutionConfig"`
   108  	// The name of the model (must be unique). If omitted, this provider will assign a random, unique name.
   109  	Name pulumi.StringOutput `pulumi:"name"`
   110  	// The primary docker image containing inference code that is used when the model is deployed for predictions.  If not specified, the `container` argument is required. Fields are documented below.
   111  	PrimaryContainer ModelPrimaryContainerPtrOutput `pulumi:"primaryContainer"`
   112  	// A map of tags to assign to the resource. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   113  	//
   114  	// The `primaryContainer` and `container` block both support:
   115  	Tags pulumi.StringMapOutput `pulumi:"tags"`
   116  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   117  	//
   118  	// Deprecated: Please use `tags` instead.
   119  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   120  	// Specifies the VPC that you want your model to connect to. VpcConfig is used in hosting services and in batch transform.
   121  	VpcConfig ModelVpcConfigPtrOutput `pulumi:"vpcConfig"`
   122  }
   123  
   124  // NewModel registers a new resource with the given unique name, arguments, and options.
   125  func NewModel(ctx *pulumi.Context,
   126  	name string, args *ModelArgs, opts ...pulumi.ResourceOption) (*Model, error) {
   127  	if args == nil {
   128  		return nil, errors.New("missing one or more required arguments")
   129  	}
   130  
   131  	if args.ExecutionRoleArn == nil {
   132  		return nil, errors.New("invalid value for required argument 'ExecutionRoleArn'")
   133  	}
   134  	opts = internal.PkgResourceDefaultOpts(opts)
   135  	var resource Model
   136  	err := ctx.RegisterResource("aws:sagemaker/model:Model", name, args, &resource, opts...)
   137  	if err != nil {
   138  		return nil, err
   139  	}
   140  	return &resource, nil
   141  }
   142  
   143  // GetModel gets an existing Model resource's state with the given name, ID, and optional
   144  // state properties that are used to uniquely qualify the lookup (nil if not required).
   145  func GetModel(ctx *pulumi.Context,
   146  	name string, id pulumi.IDInput, state *ModelState, opts ...pulumi.ResourceOption) (*Model, error) {
   147  	var resource Model
   148  	err := ctx.ReadResource("aws:sagemaker/model:Model", name, id, state, &resource, opts...)
   149  	if err != nil {
   150  		return nil, err
   151  	}
   152  	return &resource, nil
   153  }
   154  
   155  // Input properties used for looking up and filtering Model resources.
   156  type modelState struct {
   157  	// The Amazon Resource Name (ARN) assigned by AWS to this model.
   158  	Arn *string `pulumi:"arn"`
   159  	// Specifies containers in the inference pipeline. If not specified, the `primaryContainer` argument is required. Fields are documented below.
   160  	Containers []ModelContainer `pulumi:"containers"`
   161  	// Isolates the model container. No inbound or outbound network calls can be made to or from the model container.
   162  	EnableNetworkIsolation *bool `pulumi:"enableNetworkIsolation"`
   163  	// A role that SageMaker can assume to access model artifacts and docker images for deployment.
   164  	ExecutionRoleArn *string `pulumi:"executionRoleArn"`
   165  	// Specifies details of how containers in a multi-container endpoint are called. see Inference Execution Config.
   166  	InferenceExecutionConfig *ModelInferenceExecutionConfig `pulumi:"inferenceExecutionConfig"`
   167  	// The name of the model (must be unique). If omitted, this provider will assign a random, unique name.
   168  	Name *string `pulumi:"name"`
   169  	// The primary docker image containing inference code that is used when the model is deployed for predictions.  If not specified, the `container` argument is required. Fields are documented below.
   170  	PrimaryContainer *ModelPrimaryContainer `pulumi:"primaryContainer"`
   171  	// A map of tags to assign to the resource. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   172  	//
   173  	// The `primaryContainer` and `container` block both support:
   174  	Tags map[string]string `pulumi:"tags"`
   175  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   176  	//
   177  	// Deprecated: Please use `tags` instead.
   178  	TagsAll map[string]string `pulumi:"tagsAll"`
   179  	// Specifies the VPC that you want your model to connect to. VpcConfig is used in hosting services and in batch transform.
   180  	VpcConfig *ModelVpcConfig `pulumi:"vpcConfig"`
   181  }
   182  
   183  type ModelState struct {
   184  	// The Amazon Resource Name (ARN) assigned by AWS to this model.
   185  	Arn pulumi.StringPtrInput
   186  	// Specifies containers in the inference pipeline. If not specified, the `primaryContainer` argument is required. Fields are documented below.
   187  	Containers ModelContainerArrayInput
   188  	// Isolates the model container. No inbound or outbound network calls can be made to or from the model container.
   189  	EnableNetworkIsolation pulumi.BoolPtrInput
   190  	// A role that SageMaker can assume to access model artifacts and docker images for deployment.
   191  	ExecutionRoleArn pulumi.StringPtrInput
   192  	// Specifies details of how containers in a multi-container endpoint are called. see Inference Execution Config.
   193  	InferenceExecutionConfig ModelInferenceExecutionConfigPtrInput
   194  	// The name of the model (must be unique). If omitted, this provider will assign a random, unique name.
   195  	Name pulumi.StringPtrInput
   196  	// The primary docker image containing inference code that is used when the model is deployed for predictions.  If not specified, the `container` argument is required. Fields are documented below.
   197  	PrimaryContainer ModelPrimaryContainerPtrInput
   198  	// A map of tags to assign to the resource. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   199  	//
   200  	// The `primaryContainer` and `container` block both support:
   201  	Tags pulumi.StringMapInput
   202  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   203  	//
   204  	// Deprecated: Please use `tags` instead.
   205  	TagsAll pulumi.StringMapInput
   206  	// Specifies the VPC that you want your model to connect to. VpcConfig is used in hosting services and in batch transform.
   207  	VpcConfig ModelVpcConfigPtrInput
   208  }
   209  
   210  func (ModelState) ElementType() reflect.Type {
   211  	return reflect.TypeOf((*modelState)(nil)).Elem()
   212  }
   213  
   214  type modelArgs struct {
   215  	// Specifies containers in the inference pipeline. If not specified, the `primaryContainer` argument is required. Fields are documented below.
   216  	Containers []ModelContainer `pulumi:"containers"`
   217  	// Isolates the model container. No inbound or outbound network calls can be made to or from the model container.
   218  	EnableNetworkIsolation *bool `pulumi:"enableNetworkIsolation"`
   219  	// A role that SageMaker can assume to access model artifacts and docker images for deployment.
   220  	ExecutionRoleArn string `pulumi:"executionRoleArn"`
   221  	// Specifies details of how containers in a multi-container endpoint are called. see Inference Execution Config.
   222  	InferenceExecutionConfig *ModelInferenceExecutionConfig `pulumi:"inferenceExecutionConfig"`
   223  	// The name of the model (must be unique). If omitted, this provider will assign a random, unique name.
   224  	Name *string `pulumi:"name"`
   225  	// The primary docker image containing inference code that is used when the model is deployed for predictions.  If not specified, the `container` argument is required. Fields are documented below.
   226  	PrimaryContainer *ModelPrimaryContainer `pulumi:"primaryContainer"`
   227  	// A map of tags to assign to the resource. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   228  	//
   229  	// The `primaryContainer` and `container` block both support:
   230  	Tags map[string]string `pulumi:"tags"`
   231  	// Specifies the VPC that you want your model to connect to. VpcConfig is used in hosting services and in batch transform.
   232  	VpcConfig *ModelVpcConfig `pulumi:"vpcConfig"`
   233  }
   234  
   235  // The set of arguments for constructing a Model resource.
   236  type ModelArgs struct {
   237  	// Specifies containers in the inference pipeline. If not specified, the `primaryContainer` argument is required. Fields are documented below.
   238  	Containers ModelContainerArrayInput
   239  	// Isolates the model container. No inbound or outbound network calls can be made to or from the model container.
   240  	EnableNetworkIsolation pulumi.BoolPtrInput
   241  	// A role that SageMaker can assume to access model artifacts and docker images for deployment.
   242  	ExecutionRoleArn pulumi.StringInput
   243  	// Specifies details of how containers in a multi-container endpoint are called. see Inference Execution Config.
   244  	InferenceExecutionConfig ModelInferenceExecutionConfigPtrInput
   245  	// The name of the model (must be unique). If omitted, this provider will assign a random, unique name.
   246  	Name pulumi.StringPtrInput
   247  	// The primary docker image containing inference code that is used when the model is deployed for predictions.  If not specified, the `container` argument is required. Fields are documented below.
   248  	PrimaryContainer ModelPrimaryContainerPtrInput
   249  	// A map of tags to assign to the resource. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   250  	//
   251  	// The `primaryContainer` and `container` block both support:
   252  	Tags pulumi.StringMapInput
   253  	// Specifies the VPC that you want your model to connect to. VpcConfig is used in hosting services and in batch transform.
   254  	VpcConfig ModelVpcConfigPtrInput
   255  }
   256  
   257  func (ModelArgs) ElementType() reflect.Type {
   258  	return reflect.TypeOf((*modelArgs)(nil)).Elem()
   259  }
   260  
   261  type ModelInput interface {
   262  	pulumi.Input
   263  
   264  	ToModelOutput() ModelOutput
   265  	ToModelOutputWithContext(ctx context.Context) ModelOutput
   266  }
   267  
   268  func (*Model) ElementType() reflect.Type {
   269  	return reflect.TypeOf((**Model)(nil)).Elem()
   270  }
   271  
   272  func (i *Model) ToModelOutput() ModelOutput {
   273  	return i.ToModelOutputWithContext(context.Background())
   274  }
   275  
   276  func (i *Model) ToModelOutputWithContext(ctx context.Context) ModelOutput {
   277  	return pulumi.ToOutputWithContext(ctx, i).(ModelOutput)
   278  }
   279  
   280  // ModelArrayInput is an input type that accepts ModelArray and ModelArrayOutput values.
   281  // You can construct a concrete instance of `ModelArrayInput` via:
   282  //
   283  //	ModelArray{ ModelArgs{...} }
   284  type ModelArrayInput interface {
   285  	pulumi.Input
   286  
   287  	ToModelArrayOutput() ModelArrayOutput
   288  	ToModelArrayOutputWithContext(context.Context) ModelArrayOutput
   289  }
   290  
   291  type ModelArray []ModelInput
   292  
   293  func (ModelArray) ElementType() reflect.Type {
   294  	return reflect.TypeOf((*[]*Model)(nil)).Elem()
   295  }
   296  
   297  func (i ModelArray) ToModelArrayOutput() ModelArrayOutput {
   298  	return i.ToModelArrayOutputWithContext(context.Background())
   299  }
   300  
   301  func (i ModelArray) ToModelArrayOutputWithContext(ctx context.Context) ModelArrayOutput {
   302  	return pulumi.ToOutputWithContext(ctx, i).(ModelArrayOutput)
   303  }
   304  
   305  // ModelMapInput is an input type that accepts ModelMap and ModelMapOutput values.
   306  // You can construct a concrete instance of `ModelMapInput` via:
   307  //
   308  //	ModelMap{ "key": ModelArgs{...} }
   309  type ModelMapInput interface {
   310  	pulumi.Input
   311  
   312  	ToModelMapOutput() ModelMapOutput
   313  	ToModelMapOutputWithContext(context.Context) ModelMapOutput
   314  }
   315  
   316  type ModelMap map[string]ModelInput
   317  
   318  func (ModelMap) ElementType() reflect.Type {
   319  	return reflect.TypeOf((*map[string]*Model)(nil)).Elem()
   320  }
   321  
   322  func (i ModelMap) ToModelMapOutput() ModelMapOutput {
   323  	return i.ToModelMapOutputWithContext(context.Background())
   324  }
   325  
   326  func (i ModelMap) ToModelMapOutputWithContext(ctx context.Context) ModelMapOutput {
   327  	return pulumi.ToOutputWithContext(ctx, i).(ModelMapOutput)
   328  }
   329  
   330  type ModelOutput struct{ *pulumi.OutputState }
   331  
   332  func (ModelOutput) ElementType() reflect.Type {
   333  	return reflect.TypeOf((**Model)(nil)).Elem()
   334  }
   335  
   336  func (o ModelOutput) ToModelOutput() ModelOutput {
   337  	return o
   338  }
   339  
   340  func (o ModelOutput) ToModelOutputWithContext(ctx context.Context) ModelOutput {
   341  	return o
   342  }
   343  
   344  // The Amazon Resource Name (ARN) assigned by AWS to this model.
   345  func (o ModelOutput) Arn() pulumi.StringOutput {
   346  	return o.ApplyT(func(v *Model) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   347  }
   348  
   349  // Specifies containers in the inference pipeline. If not specified, the `primaryContainer` argument is required. Fields are documented below.
   350  func (o ModelOutput) Containers() ModelContainerArrayOutput {
   351  	return o.ApplyT(func(v *Model) ModelContainerArrayOutput { return v.Containers }).(ModelContainerArrayOutput)
   352  }
   353  
   354  // Isolates the model container. No inbound or outbound network calls can be made to or from the model container.
   355  func (o ModelOutput) EnableNetworkIsolation() pulumi.BoolPtrOutput {
   356  	return o.ApplyT(func(v *Model) pulumi.BoolPtrOutput { return v.EnableNetworkIsolation }).(pulumi.BoolPtrOutput)
   357  }
   358  
   359  // A role that SageMaker can assume to access model artifacts and docker images for deployment.
   360  func (o ModelOutput) ExecutionRoleArn() pulumi.StringOutput {
   361  	return o.ApplyT(func(v *Model) pulumi.StringOutput { return v.ExecutionRoleArn }).(pulumi.StringOutput)
   362  }
   363  
   364  // Specifies details of how containers in a multi-container endpoint are called. see Inference Execution Config.
   365  func (o ModelOutput) InferenceExecutionConfig() ModelInferenceExecutionConfigOutput {
   366  	return o.ApplyT(func(v *Model) ModelInferenceExecutionConfigOutput { return v.InferenceExecutionConfig }).(ModelInferenceExecutionConfigOutput)
   367  }
   368  
   369  // The name of the model (must be unique). If omitted, this provider will assign a random, unique name.
   370  func (o ModelOutput) Name() pulumi.StringOutput {
   371  	return o.ApplyT(func(v *Model) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   372  }
   373  
   374  // The primary docker image containing inference code that is used when the model is deployed for predictions.  If not specified, the `container` argument is required. Fields are documented below.
   375  func (o ModelOutput) PrimaryContainer() ModelPrimaryContainerPtrOutput {
   376  	return o.ApplyT(func(v *Model) ModelPrimaryContainerPtrOutput { return v.PrimaryContainer }).(ModelPrimaryContainerPtrOutput)
   377  }
   378  
   379  // A map of tags to assign to the resource. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   380  //
   381  // The `primaryContainer` and `container` block both support:
   382  func (o ModelOutput) Tags() pulumi.StringMapOutput {
   383  	return o.ApplyT(func(v *Model) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   384  }
   385  
   386  // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   387  //
   388  // Deprecated: Please use `tags` instead.
   389  func (o ModelOutput) TagsAll() pulumi.StringMapOutput {
   390  	return o.ApplyT(func(v *Model) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   391  }
   392  
   393  // Specifies the VPC that you want your model to connect to. VpcConfig is used in hosting services and in batch transform.
   394  func (o ModelOutput) VpcConfig() ModelVpcConfigPtrOutput {
   395  	return o.ApplyT(func(v *Model) ModelVpcConfigPtrOutput { return v.VpcConfig }).(ModelVpcConfigPtrOutput)
   396  }
   397  
   398  type ModelArrayOutput struct{ *pulumi.OutputState }
   399  
   400  func (ModelArrayOutput) ElementType() reflect.Type {
   401  	return reflect.TypeOf((*[]*Model)(nil)).Elem()
   402  }
   403  
   404  func (o ModelArrayOutput) ToModelArrayOutput() ModelArrayOutput {
   405  	return o
   406  }
   407  
   408  func (o ModelArrayOutput) ToModelArrayOutputWithContext(ctx context.Context) ModelArrayOutput {
   409  	return o
   410  }
   411  
   412  func (o ModelArrayOutput) Index(i pulumi.IntInput) ModelOutput {
   413  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Model {
   414  		return vs[0].([]*Model)[vs[1].(int)]
   415  	}).(ModelOutput)
   416  }
   417  
   418  type ModelMapOutput struct{ *pulumi.OutputState }
   419  
   420  func (ModelMapOutput) ElementType() reflect.Type {
   421  	return reflect.TypeOf((*map[string]*Model)(nil)).Elem()
   422  }
   423  
   424  func (o ModelMapOutput) ToModelMapOutput() ModelMapOutput {
   425  	return o
   426  }
   427  
   428  func (o ModelMapOutput) ToModelMapOutputWithContext(ctx context.Context) ModelMapOutput {
   429  	return o
   430  }
   431  
   432  func (o ModelMapOutput) MapIndex(k pulumi.StringInput) ModelOutput {
   433  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Model {
   434  		return vs[0].(map[string]*Model)[vs[1].(string)]
   435  	}).(ModelOutput)
   436  }
   437  
   438  func init() {
   439  	pulumi.RegisterInputType(reflect.TypeOf((*ModelInput)(nil)).Elem(), &Model{})
   440  	pulumi.RegisterInputType(reflect.TypeOf((*ModelArrayInput)(nil)).Elem(), ModelArray{})
   441  	pulumi.RegisterInputType(reflect.TypeOf((*ModelMapInput)(nil)).Elem(), ModelMap{})
   442  	pulumi.RegisterOutputType(ModelOutput{})
   443  	pulumi.RegisterOutputType(ModelArrayOutput{})
   444  	pulumi.RegisterOutputType(ModelMapOutput{})
   445  }