Skip to content

Commit

Permalink
Merge pull request #31755 from holly-evans/f-aws-sagemaker-model-pack…
Browse files Browse the repository at this point in the history
…age-name-23968

F/Add model_package_name for aws_sagemaker_model
  • Loading branch information
ewbankkit authored Jun 5, 2023
2 parents 7c0740c + de8b90a commit 4c60e5e
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 84 deletions.
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

0 comments on commit 4c60e5e

Please sign in to comment.