1 Answer
- Newest
- Most votes
- Most comments
1
Documentation on applying RBAC to Amazon ElastiCache for Redis: https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Clusters.RBAC.html#rbac-using Terraform Resources documentation: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_user_group_association
High-level terraform example (untested)
resource "aws_elasticache_user" "default" {
user_id = "defaultUserID"
user_name = "default"
access_string = "on ~app::* -@all +@read +@hash +@bitmap +@geo -setbit -bitfield -hset -hsetnx -hmset -hincrby -hincrbyfloat -hdel -bitop -geoadd -georadius -georadiusbymember"
engine = "REDIS"
passwords = ["password123456789"]
}
resource "aws_elasticache_user_group" "example" {
engine = "REDIS"
user_group_id = "userGroupId"
user_ids = [aws_elasticache_user.default.user_id]
lifecycle {
ignore_changes = [user_ids]
}
}
resource "aws_elasticache_user" "example" {
user_id = "exampleUserID"
user_name = "exampleuser"
access_string = "on ~app::* -@all +@read +@hash +@bitmap +@geo -setbit -bitfield -hset -hsetnx -hmset -hincrby -hincrbyfloat -hdel -bitop -geoadd -georadius -georadiusbymember"
engine = "REDIS"
passwords = ["password123456789"]
}
resource "aws_elasticache_user_group_association" "example" {
user_group_id = aws_elasticache_user_group.example.user_group_id
user_id = aws_elasticache_user.example.user_id
}
resource "aws_elasticache_replication_group" "example" {
automatic_failover_enabled = true
preferred_cache_cluster_azs = ["us-west-2a", "us-west-2b"]
replication_group_id = "tf-rep-group-1"
description = "example description"
node_type = "cache.m4.large"
num_cache_clusters = 2
parameter_group_name = "default.redis3.2"
port = 6379
#this should be a reference to the aws_elasticache_user_group user_group_id
user_group_ids = [aws_elasticache_user_group.example.id]
lifecycle {
ignore_changes = [num_cache_clusters]
}
}
resource "aws_elasticache_cluster" "replica" {
count = 1
cluster_id = "tf-rep-group-1-${count.index}"
replication_group_id = aws_elasticache_replication_group.example.id
}
answered 10 months ago
Relevant content
- Accepted Answerasked 9 months ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 7 days ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 2 years ago