Skip to content

Commit

Permalink
use d.GetOk to retrieve input values on update
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 committed Feb 4, 2021
1 parent cd1c4a4 commit e6556f6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions aws/resource_aws_ssoadmin_permission_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,21 @@ func resourceAwsSsoAdminPermissionSetUpdate(d *schema.ResourceData, meta interfa
PermissionSetArn: aws.String(arn),
}

if d.HasChange("description") {
input.Description = aws.String(d.Get("description").(string))
}

// The AWS SSO API requires we send the RelayState value regardless if it's unchanged
// else the existing Permission Set's RelayState value will be cleared
// else the existing Permission Set's RelayState value will be cleared;
// for consistency, we'll check for the "presence of" instead of "if changed" for all input fields
// Reference: https://github.com/hashicorp/terraform-provider-aws/issues/17411

if v, ok := d.GetOk("description"); ok {
input.Description = aws.String(v.(string))
}

if v, ok := d.GetOk("relay_state"); ok {
input.RelayState = aws.String(v.(string))
}

if d.HasChange("session_duration") {
input.SessionDuration = aws.String(d.Get("session_duration").(string))
if v, ok := d.GetOk("session_duration"); ok {
input.SessionDuration = aws.String(v.(string))
}

_, err := conn.UpdatePermissionSet(input)
Expand Down

0 comments on commit e6556f6

Please sign in to comment.