diff --git a/minio/resource_minio_iam_user.go b/minio/resource_minio_iam_user.go index f37e28d0..09b7bd7e 100644 --- a/minio/resource_minio_iam_user.go +++ b/minio/resource_minio_iam_user.go @@ -27,6 +27,7 @@ func resourceMinioIAMUser() *schema.Resource { "name": { Type: schema.TypeString, Required: true, + ForceNew: true, ValidateFunc: validateMinioIamUserName, }, "force_destroy": { @@ -107,23 +108,6 @@ func minioUpdateUser(ctx context.Context, d *schema.ResourceData, meta interface } } - if d.HasChange(iamUserConfig.MinioIAMName) { - on, nn := d.GetChange(iamUserConfig.MinioIAMName) - - log.Println("[DEBUG] Update IAM User:", iamUserConfig.MinioIAMName) - err := iamUserConfig.MinioAdmin.RemoveUser(ctx, on.(string)) - if err != nil { - return NewResourceError("error updating IAM User %s: %s", d.Id(), err) - } - - err = iamUserConfig.MinioAdmin.AddUser(ctx, nn.(string), secretKey) - if err != nil { - return NewResourceError("error updating IAM User %s: %s", d.Id(), err) - } - - d.SetId(nn.(string)) - } - userStatus := UserStatus{ AccessKey: iamUserConfig.MinioIAMName, SecretKey: secretKey, diff --git a/minio/resource_minio_iam_user_test.go b/minio/resource_minio_iam_user_test.go index df5b2ea0..cabda15c 100644 --- a/minio/resource_minio_iam_user_test.go +++ b/minio/resource_minio_iam_user_test.go @@ -77,6 +77,35 @@ func TestAccAWSUser_basic(t *testing.T) { }) } +func TestAccAWSUser_UpdateName(t *testing.T) { + var user madmin.UserInfo + + name := fmt.Sprintf("test-user-%d", acctest.RandInt()) + status := "enabled" + resourceName := "minio_iam_user.test" + updatedName := fmt.Sprintf("test-user-%d", acctest.RandInt()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviders, + CheckDestroy: testAccCheckMinioUserDestroy, + Steps: []resource.TestStep{ + { + Config: testAccMinioUserConfig(name), + Check: resource.ComposeTestCheckFunc( + testAccCheckMinioUserExists(resourceName, &user), + ), + }, + { + Config: testAccMinioUserConfig(updatedName), + Check: resource.ComposeTestCheckFunc( + testAccCheckMinioUserAttributes(resourceName, updatedName, status), + ), + }, + }, + }) +} + func TestAccAWSUser_DisableUser(t *testing.T) { var user madmin.UserInfo