Skip to content

Resource: awsElasticacheUserGroupAssociation

Associate an existing ElastiCache user and an existing user group.

\~> NOTE: Terraform will detect changes in the awsElasticacheUserGroup since awsElasticacheUserGroupAssociation changes the user IDs associated with the user group. You can ignore these changes with the lifecycle ignoreChanges meta argument as shown in the example.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsElasticacheUserDefault = new aws.elasticacheUser.ElasticacheUser(
  this,
  "default",
  {
    accessString:
      "on ~app::* -@all +@read +@hash +@bitmap +@geo -setbit -bitfield -hset -hsetnx -hmset -hincrby -hincrbyfloat -hdel -bitop -geoadd -georadius -georadiusbymember",
    engine: "REDIS",
    passwords: ["password123456789"],
    userId: "defaultUserID",
    userName: "default",
  }
);
const awsElasticacheUserExample = new aws.elasticacheUser.ElasticacheUser(
  this,
  "example",
  {
    accessString:
      "on ~app::* -@all +@read +@hash +@bitmap +@geo -setbit -bitfield -hset -hsetnx -hmset -hincrby -hincrbyfloat -hdel -bitop -geoadd -georadius -georadiusbymember",
    engine: "REDIS",
    passwords: ["password123456789"],
    userId: "exampleUserID",
    userName: "exampleuser",
  }
);
const awsElasticacheUserGroupExample =
  new aws.elasticacheUserGroup.ElasticacheUserGroup(this, "example_2", {
    engine: "REDIS",
    userGroupId: "userGroupId",
    userIds: [awsElasticacheUserDefault.userId],
  });
awsElasticacheUserGroupExample.addOverride("lifecycle", [
  {
    ignore_changes: ["${user_ids}"],
  },
]);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsElasticacheUserGroupExample.overrideLogicalId("example");
const awsElasticacheUserGroupAssociationExample =
  new aws.elasticacheUserGroupAssociation.ElasticacheUserGroupAssociation(
    this,
    "example_3",
    {
      userGroupId: awsElasticacheUserGroupExample.userGroupId,
      userId: awsElasticacheUserExample.userId,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsElasticacheUserGroupAssociationExample.overrideLogicalId("example");

Argument Reference

The following arguments are required:

  • userGroupId - (Required) ID of the user group.
  • userId - (Required) ID of the user to associated with the user group.

Attributes Reference

No additional attributes are exported.

Import

ElastiCache user group associations can be imported using the userGroupId and userId, e.g.,

$ terraform import aws_elasticache_user_group_association.example userGoupId1,userId