一、首先创建AWS ELC时,启用TLS,Terraform Code
resource "aws_elasticache_replication_group" “test”{
transit_encryption_enabled = true
}
二、编译redis-cli,env = Ubuntu 18.0.4
参考aws doc :
https://docs.aws.amazon.com/zh_cn/AmazonElastiCache/latest/red-ug/in-transit-encryption.html
1.安装依赖包
$ apt-get update
$ apt-get upgrade
$ apt-get install gcc openssl tcl clang wget
$ apt-get install libssl-dev // 其实安装的是 opnessl-devel
$ apt-get install libjemalloc-dev // 其实安装的是 jemalloc-devel
// tcl-devel ,Ubuntu找不到,至今也未安装成功
2.编译 redis-cli,必须是redis 6.0版本,才能支持TLS
$ wget http://download.redis.io/redis-stable.tar.gz
$ tar zxvf redis-stable.tar.gz
$ cd redis-stable/
$ make distclean
$ make redis-cli CC=clang BUILD_TLS=yes
$ install -m 755 src/redis-cli /usr/local/bin/
三、使用AWS ELC CLI启用AUTH(ELC必须已经启用了TLS)并验证:注意参数 --tls 的位置
// auth-token-update-strategy ROTATE,因为创建之初,无法设置AUTH,所以这里必须指定ROTATE策略,使得无密码和设定的密码同时可用状态
aws elasticache modify-replication-group --replication-group-id "创建的ELC NAME" --auth-token "密码:必须符合AWS密码要求" --auth-token-update-strategy ROTATE --apply-immediately
// 设定为仅用密码登录
aws elasticache modify-replication-group --replication-group-id "创建的ELC NAME" --auth-token "必须是上面已经设定的密码" --auth-token-update-strategy SET --apply-immediately
// 验证:如果ELC是集群模式,必须使用参数 -c
redis-cli -c -h hostname --tls -a "auth token" -p port