Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Kit Ewbank <[email protected]>
  • Loading branch information
DrFaust92 and ewbankkit committed Jan 18, 2021
1 parent 71f8348 commit a4ccf92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 12 additions & 10 deletions aws/resource_aws_sagemaker_user_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ func resourceAwsSagemakerUserProfile() *schema.Resource {
Required: true,
ForceNew: true,
},
"single_sign_on_user_indentifier": {
"single_sign_on_user_identifier": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"single_sign_on_user_value": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"user_settings": {
Type: schema.TypeList,
Expand Down Expand Up @@ -227,7 +229,7 @@ func resourceAwsSagemakerUserProfileCreate(d *schema.ResourceData, meta interfac
input.UserSettings = expandSagemakerDomainDefaultUserSettings(v.([]interface{}))
}

if v, ok := d.GetOk("single_sign_on_user_indentifier"); ok {
if v, ok := d.GetOk("single_sign_on_user_identifier"); ok {
input.SingleSignOnUserIdentifier = aws.String(v.(string))
}

Expand Down Expand Up @@ -273,28 +275,28 @@ func resourceAwsSagemakerUserProfileRead(d *schema.ResourceData, meta interface{
if err != nil {
if isAWSErr(err, sagemaker.ErrCodeResourceNotFound, "") {
d.SetId("")
log.Printf("[WARN] Unable to find SageMaker UserProfile (%s), removing from state", d.Id())
log.Printf("[WARN] Unable to find SageMaker User Profile (%s), removing from state", d.Id())
return nil
}
return fmt.Errorf("error reading SageMaker UserProfile (%s): %w", d.Id(), err)
return fmt.Errorf("error reading SageMaker User Profile (%s): %w", d.Id(), err)
}

arn := aws.StringValue(UserProfile.UserProfileArn)
d.Set("user_profile_name", UserProfile.UserProfileName)
d.Set("domain_id", UserProfile.DomainId)
d.Set("single_sign_on_user_indentifier", UserProfile.SingleSignOnUserIdentifier)
d.Set("single_sign_on_user_identifier", UserProfile.SingleSignOnUserIdentifier)
d.Set("single_sign_on_user_value", UserProfile.SingleSignOnUserValue)
d.Set("arn", arn)
d.Set("home_efs_file_system_uid", UserProfile.HomeEfsFileSystemUid)

if err := d.Set("user_settings", flattenSagemakerDomainDefaultUserSettings(UserProfile.UserSettings)); err != nil {
return fmt.Errorf("error setting user_settings for SageMaker UserProfile (%s): %w", d.Id(), err)
return fmt.Errorf("error setting user_settings for SageMaker User Profile (%s): %w", d.Id(), err)
}

tags, err := keyvaluetags.SagemakerListTags(conn, arn)

if err != nil {
return fmt.Errorf("error listing tags for SageMaker UserProfile (%s): %w", d.Id(), err)
return fmt.Errorf("error listing tags for SageMaker User Profile (%s): %w", d.Id(), err)
}

if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
Expand All @@ -317,7 +319,7 @@ func resourceAwsSagemakerUserProfileUpdate(d *schema.ResourceData, meta interfac
log.Printf("[DEBUG] SageMaker User Profile update config: %#v", *input)
_, err := conn.UpdateUserProfile(input)
if err != nil {
return fmt.Errorf("error updating SageMaker UserProfile: %w", err)
return fmt.Errorf("error updating SageMaker User Profile: %w", err)
}
}

Expand Down Expand Up @@ -345,13 +347,13 @@ func resourceAwsSagemakerUserProfileDelete(d *schema.ResourceData, meta interfac

if _, err := conn.DeleteUserProfile(input); err != nil {
if !isAWSErr(err, sagemaker.ErrCodeResourceNotFound, "") {
return fmt.Errorf("error deleting SageMaker UserProfile (%s): %w", d.Id(), err)
return fmt.Errorf("error deleting SageMaker User Profile (%s): %w", d.Id(), err)
}
}

if _, err := waiter.UserProfileDeleted(conn, domainID, userProfileName); err != nil {
if !isAWSErr(err, sagemaker.ErrCodeResourceNotFound, "") {
return fmt.Errorf("error waiting for SageMaker UserProfile (%s) to delete: %w", d.Id(), err)
return fmt.Errorf("error waiting for SageMaker User Profile (%s) to delete: %w", d.Id(), err)
}
}

Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/sagemaker_user_profile.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ The following arguments are supported:

* `user_profile_name` - (Required) The name for the User Profile.
* `domain_id` - (Required) The ID of the associated Domain.
* `single_sign_on_user_indentifier` - (Optional) A specifier for the type of value specified in `single_sign_on_user_value`. Currently, the only supported value is `UserName`. If the Domain's AuthMode is SSO, this field is required. If the Domain's AuthMode is not SSO, this field cannot be specified.
* `single_sign_on_user_value` - (Required) The username of the associated AWS Single Sign-On User for this UserProfile. If the Domain's AuthMode is SSO, this field is required, and must match a valid username of a user in your directory. If the Domain's AuthMode is not SSO, this field cannot be specified.
* `single_sign_on_user_identifier` - (Optional) A specifier for the type of value specified in `single_sign_on_user_value`. Currently, the only supported value is `UserName`. If the Domain's AuthMode is SSO, this field is required. If the Domain's AuthMode is not SSO, this field cannot be specified.
* `single_sign_on_user_value` - (Required) The username of the associated AWS Single Sign-On User for this User Profile. If the Domain's AuthMode is SSO, this field is required, and must match a valid username of a user in your directory. If the Domain's AuthMode is not SSO, this field cannot be specified.
* `user_settings` - (Required) The user settings. See [User Settings](#user-settings) below.
* `tags` - (Optional) A map of tags to assign to the resource.

Expand Down

0 comments on commit a4ccf92

Please sign in to comment.