Skip to content

Commit

Permalink
r/iam_user: name change requires id to be reset
Browse files Browse the repository at this point in the history
  • Loading branch information
kl4w committed Jan 12, 2018
1 parent 984d50b commit f2a525b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions aws/resource_aws_iam_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func resourceAwsIamUserUpdate(d *schema.ResourceData, meta interface{}) error {
}
return fmt.Errorf("Error updating IAM User %s: %s", d.Id(), err)
}
d.SetId(nn.(string))
return resourceAwsIamUserRead(d, meta)
}
return nil
Expand Down
28 changes: 28 additions & 0 deletions aws/resource_aws_iam_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,34 @@ func TestAccAWSUser_basic(t *testing.T) {
})
}

func TestAccAWSUser_nameChange(t *testing.T) {
var conf iam.GetUserOutput

name1 := fmt.Sprintf("test-user-%d", acctest.RandInt())
name2 := fmt.Sprintf("test-user-%d", acctest.RandInt())
path := "/"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSUserDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSUserConfig(name1, path),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSUserExists("aws_iam_user.user", &conf),
),
},
{
Config: testAccAWSUserConfig(name2, path),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSUserExists("aws_iam_user.user", &conf),
),
},
},
})
}

func testAccCheckAWSUserDestroy(s *terraform.State) error {
iamconn := testAccProvider.Meta().(*AWSClient).iamconn

Expand Down

0 comments on commit f2a525b

Please sign in to comment.