Skip to content

Commit

Permalink
Merge pull request #28928 from cscacun/f-aws_elasticache_user_auth_mode
Browse files Browse the repository at this point in the history
Add authentication_mode to aws_elasticache_user
  • Loading branch information
ewbankkit committed Mar 15, 2023
2 parents d24c778 + 3557d3a commit 174bfb4
Show file tree
Hide file tree
Showing 8 changed files with 482 additions and 146 deletions.
7 changes: 7 additions & 0 deletions .changelog/28928.txt
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_elasticache_user: Add `authentication_mode` argument
```

```release-note:bug
resource/aws_elasticache_user: Change `user_id` to [ForceNew](https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-behaviors#forcenew)
```
24 changes: 0 additions & 24 deletions internal/service/elasticache/find.go
Expand Up @@ -183,30 +183,6 @@ func FindGlobalReplicationGroupMemberByID(ctx context.Context, conn *elasticache
}
}

func FindUserByID(ctx context.Context, conn *elasticache.ElastiCache, userID string) (*elasticache.User, error) {
input := &elasticache.DescribeUsersInput{
UserId: aws.String(userID),
}
out, err := conn.DescribeUsersWithContext(ctx, input)

if err != nil {
return nil, err
}

switch len(out.Users) {
case 0:
return nil, &resource.NotFoundError{
Message: "empty result",
}
case 1:
return out.Users[0], nil
default:
return nil, &resource.NotFoundError{
Message: "too many results",
}
}
}

func FindUserGroupByID(ctx context.Context, conn *elasticache.ElastiCache, groupID string) (*elasticache.UserGroup, error) {
input := &elasticache.DescribeUserGroupsInput{
UserGroupId: aws.String(groupID),
Expand Down
21 changes: 0 additions & 21 deletions internal/service/elasticache/status.go
Expand Up @@ -16,10 +16,6 @@ const (
ReplicationGroupStatusDeleting = "deleting"
ReplicationGroupStatusCreateFailed = "create-failed"
ReplicationGroupStatusSnapshotting = "snapshotting"

UserStatusActive = "active"
UserStatusDeleting = "deleting"
UserStatusModifying = "modifying"
)

// StatusReplicationGroup fetches the Replication Group and its Status
Expand Down Expand Up @@ -130,20 +126,3 @@ func statusGlobalReplicationGroupMember(ctx context.Context, conn *elasticache.E
return member, aws.StringValue(member.Status), nil
}
}

// StatusUser fetches the ElastiCache user and its Status
func StatusUser(ctx context.Context, conn *elasticache.ElastiCache, userId string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
user, err := FindUserByID(ctx, conn, userId)

if tfresource.NotFound(err) {
return nil, "", nil
}

if err != nil {
return nil, "", err
}

return user, aws.StringValue(user.Status), nil
}
}

0 comments on commit 174bfb4

Please sign in to comment.