Skip to content

Commit

Permalink
r/aws_elasticache_user: Fix `UserNotFound: ... is not available for t…
Browse files Browse the repository at this point in the history
…agging` errors on resource Read when there is a concurrent update to the user.
  • Loading branch information
ewbankkit committed Nov 15, 2023
1 parent d8f4774 commit 19ca309
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/34396.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_elasticache_user: Fix `UserNotFound: ... is not available for tagging` errors on resource Read when there is a concurrent update to the user
```
5 changes: 4 additions & 1 deletion internal/service/elasticache/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func ResourceUser() *schema.Resource {

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(5 * time.Minute),
Read: schema.DefaultTimeout(5 * time.Minute),
Update: schema.DefaultTimeout(5 * time.Minute),
Delete: schema.DefaultTimeout(5 * time.Minute),
},
Expand Down Expand Up @@ -186,7 +187,9 @@ func resourceUserRead(ctx context.Context, d *schema.ResourceData, meta interfac
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).ElastiCacheConn(ctx)

user, err := FindUserByID(ctx, conn, d.Id())
// An ongoing OOB update (where the user is in "modifying" state) can cause "UserNotFound: ... is not available for tagging" errors.
// https://github.com/hashicorp/terraform-provider-aws/issues/34002.
user, err := waitUserUpdated(ctx, conn, d.Id(), d.Timeout(schema.TimeoutRead))

if !d.IsNewResource() && tfresource.NotFound(err) {
log.Printf("[WARN] ElastiCache User (%s) not found, removing from state", d.Id())
Expand Down
7 changes: 2 additions & 5 deletions internal/service/elasticache/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"testing"

// "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/elasticache"
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
Expand Down Expand Up @@ -304,7 +304,6 @@ func TestAccElastiCacheUser_disappears(t *testing.T) {
})
}

/*
// https://github.com/hashicorp/terraform-provider-aws/issues/34002.
func TestAccElastiCacheUser_oobModify(t *testing.T) {
ctx := acctest.Context(t)
Expand Down Expand Up @@ -332,6 +331,7 @@ func TestAccElastiCacheUser_oobModify(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckUserUpdateOOB(ctx, &user),
),
ExpectNonEmptyPlan: true,
},
// Update tags.
{
Expand All @@ -345,7 +345,6 @@ func TestAccElastiCacheUser_oobModify(t *testing.T) {
},
})
}
*/

func testAccCheckUserDestroy(ctx context.Context) resource.TestCheckFunc {
return func(s *terraform.State) error {
Expand Down Expand Up @@ -398,7 +397,6 @@ func testAccCheckUserExists(ctx context.Context, n string, v *elasticache.User)
}
}

/*
func testAccCheckUserUpdateOOB(ctx context.Context, v *elasticache.User) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := acctest.Provider.Meta().(*conns.AWSClient).ElastiCacheConn(ctx)
Expand All @@ -411,7 +409,6 @@ func testAccCheckUserUpdateOOB(ctx context.Context, v *elasticache.User) resourc
return err
}
}
*/

func testAccUserConfig_basic(rName string) string {
return fmt.Sprintf(`
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/elasticache_user.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ This resource exports the following attributes in addition to the arguments abov
[Configuration options](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts):

- `create` - (Default `5m`)
- `read` - (Default `5m`)
- `update` - (Default `5m`)
- `delete` - (Default `5m`)

Expand Down

0 comments on commit 19ca309

Please sign in to comment.