Skip to content

Commit

Permalink
Adding VPC config (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
KensoDev authored and jckuester committed Mar 25, 2019
1 parent 7c38b19 commit 8bc82a4
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions aws/resource_aws_sagemaker_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ func resourceAwsSagemakerModel() *schema.Resource {
},
},

"vpc_config": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"subnets": {
Type: schema.TypeSet,
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"security_group_ids": {
Type: schema.TypeSet,
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
},
},

"execution_role_arn": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -190,6 +211,11 @@ func resourceAwsSagemakerModelCreate(d *schema.ResourceData, meta interface{}) e
createOpts.SetEnableNetworkIsolation(v.(bool))
}

if v, ok := d.GetOk("vpc_config"); ok {
vpcConfig := expandSageMakerVpcConfigRequest(v.([]interface{}))
createOpts.SetVpcConfig(vpcConfig)
}

log.Printf("[DEBUG] Sagemaker model create config: %#v", *createOpts)
_, err := retryOnAwsCode("ValidationException", func() (interface{}, error) {
return conn.CreateModel(createOpts)
Expand All @@ -216,6 +242,19 @@ func expandSageMakerVpcConfigRequest(l []interface{}) *sagemaker.VpcConfig {
}
}

func expandSageMakerVpcConfigRequest(l []interface{}) *sagemaker.VpcConfig {
if len(l) == 0 {
return nil
}

m := l[0].(map[string]interface{})

return &sagemaker.VpcConfig{
SecurityGroupIds: expandStringSet(m["security_group_ids"].(*schema.Set)),
Subnets: expandStringSet(m["subnets"].(*schema.Set)),
}
}

func resourceAwsSagemakerModelRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).sagemakerconn

Expand Down

0 comments on commit 8bc82a4

Please sign in to comment.