Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F/Add model_package_name for aws_sagemaker_model #31755

Merged
3 changes: 3 additions & 0 deletions .changelog/31755.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_sagemaker_model: Add `container.model_package_name` and `primary_container.model_package_name` arguments
```
32 changes: 27 additions & 5 deletions internal/service/sagemaker/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func ResourceModel() *schema.Resource {
},
"image": {
Type: schema.TypeString,
Required: true,
Optional: true,
ForceNew: true,
ValidateFunc: validImage,
},
Expand Down Expand Up @@ -106,6 +106,12 @@ func ResourceModel() *schema.Resource {
ForceNew: true,
ValidateFunc: validModelDataURL,
},
"model_package_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: verify.ValidARN,
},
},
},
},
Expand Down Expand Up @@ -164,7 +170,7 @@ func ResourceModel() *schema.Resource {
},
"image": {
Type: schema.TypeString,
Required: true,
Optional: true,
ForceNew: true,
ValidateFunc: validImage,
},
Expand Down Expand Up @@ -211,6 +217,12 @@ func ResourceModel() *schema.Resource {
ForceNew: true,
ValidateFunc: validModelDataURL,
},
"model_package_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: verify.ValidARN,
},
},
},
},
Expand Down Expand Up @@ -404,8 +416,10 @@ func resourceModelDelete(ctx context.Context, d *schema.ResourceData, meta inter
}

func expandContainer(m map[string]interface{}) *sagemaker.ContainerDefinition {
container := sagemaker.ContainerDefinition{
Image: aws.String(m["image"].(string)),
container := sagemaker.ContainerDefinition{}

if v, ok := m["image"]; ok && v.(string) != "" {
container.Image = aws.String(v.(string))
}

if v, ok := m["mode"]; ok && v.(string) != "" {
Expand All @@ -418,6 +432,9 @@ func expandContainer(m map[string]interface{}) *sagemaker.ContainerDefinition {
if v, ok := m["model_data_url"]; ok && v.(string) != "" {
container.ModelDataUrl = aws.String(v.(string))
}
if v, ok := m["model_package_name"]; ok && v.(string) != "" {
container.ModelPackageName = aws.String(v.(string))
}
if v, ok := m["environment"].(map[string]interface{}); ok && len(v) > 0 {
container.Environment = flex.ExpandStringMap(v)
}
Expand Down Expand Up @@ -478,7 +495,9 @@ func flattenContainer(container *sagemaker.ContainerDefinition) []interface{} {

cfg := make(map[string]interface{})

cfg["image"] = aws.StringValue(container.Image)
if container.Image != nil {
cfg["image"] = aws.StringValue(container.Image)
}

if container.Mode != nil {
cfg["mode"] = aws.StringValue(container.Mode)
Expand All @@ -490,6 +509,9 @@ func flattenContainer(container *sagemaker.ContainerDefinition) []interface{} {
if container.ModelDataUrl != nil {
cfg["model_data_url"] = aws.StringValue(container.ModelDataUrl)
}
if container.ModelPackageName != nil {
cfg["model_package_name"] = aws.StringValue(container.ModelPackageName)
}
if container.Environment != nil {
cfg["environment"] = aws.StringValueMap(container.Environment)
}
Expand Down
Loading