Chapter 61 · Amazon Elasticache
Subchapter 61.42
references/setup/create-secure-cache.mdMarkdown8 KBView on GitHub
End-to-end workflow from intent to a production-safe ElastiCache cache. Use when the user wants to create a new cache and you have enough context (engine, region, VPC). If context is missing, run requirements sub-skill first.
Do not create a new VPC if one already exists. Use the VPC where the user’s compute (Lambda, ECS, EKS, EC2) already runs. Find it from existing IaC, task definitions, or ask the user. If no VPC is found, confirm with the user before creating one.
Before provisioning, verify:
| Check | Pass criteria | Severity |
|---|---|---|
| Subnets span 2+ AZs | At least 2 subnets in different AZs | FAIL |
| Available IPs | Each subnet has 10+ free IPs (serverless needs ENIs) | WARN |
| Security group allows port 6379 | Inbound from app SG on TCP 6379 | FAIL |
| Security group allows port 6380 (serverless only) | Inbound from app SG on TCP 6380 (reader endpoint) | FAIL |
| Service quotas | Nodes per region (L-DFE45DF3), nodes per cluster CME (L-AF354865), or serverless caches per region (L-BBCDAECC) have headroom | FAIL |
| Caller permissions | elasticache:Create*, ec2:CreateNetworkInterface (serverless) | FAIL |
| Node type available (node-based only) | Offerings exist for the node type in the target region | FAIL |
| Subnet group exists (node-based only) | Named subnet group found | FAIL |
preferred, then required).Key differences from node-based:
SnapshotRetentionLimit > 0 and optionally DailySnapshotTime. They are not enabled by default.--cache-usage-limits for cost controls (DataStorage in GB + ECPUPerSecond)aws elasticache create-serverless-cache ... (or boto3 create_serverless_cache, or CloudFormation AWS::ElastiCache::ServerlessCache)Key differences from serverless:
--transit-encryption-enabled, --at-rest-encryption-enabled, --automatic-failover-enabled, --multi-az-enabled, --snapshot-retention-limit 7iac-reference.mdaws elasticache create-replication-group ... (Valkey/Redis with replication; or boto3 create_replication_group, or CloudFormation AWS::ElastiCache::ReplicationGroup). Use create-cache-cluster only for Memcached.Always tell the user after creating:
Your cache is VPC-only. ElastiCache has no public endpoints. If you are on a local machine, you need a tunnel to connect.
- Reuse an existing EC2 instance ($0):
- Primary:
python3 scripts/find_tunnel_host.py --vpc-id <vpc-id> --region <region>(locates an SSM-managed instance via boto3)- Create a new jump host (approximately $3/month, t4g.nano in us-east-1, pricing subject to change; verify current rates, only if no existing instance found):
- Primary: launch a t4g.nano with
aws ec2 run-instancesand attach theAmazonSSMManagedInstanceCoreIAM policy so SSM can manage it. Then open the tunnel withpython3 scripts/start_tunnel.py. Bills until stopped/terminated.- Skip if your app runs inside the VPC (Lambda, ECS, EKS, EC2)
Use the bundled scripts (
scripts/find_tunnel_host.py,scripts/start_tunnel.py) as the primary path. Always try option 1 before option 2.
Tunnel startup:
python3 scripts/start_tunnel.py --instance-id <id> --cache-host <endpoint> --region <region>
python3 scripts/test_connection.py 127.0.0.1 --port 6379 --tunnel-mode --server-name <endpoint>create-user --user-id <name>-appuser --user-name <name>-appuser --engine <valkey|redis> --access-string "on ~* +@all" --authentication-mode Type=iamcreate-user-group --user-group-id <name>-usergroup --engine <valkey|redis> --user-ids default <name>-appuserUse the engine value that matches your cache engine (valkey for Valkey caches, redis for Redis OSS caches).
3. Attach to cache:
modify-serverless-cache --serverless-cache-name <name> --user-group-id <name>-usergroup--user-group-ids at creation timeNote: The --engine value for user and user-group accepts valkey or redis. Use the value that matches your cache engine.
| Mode | Flag | When to use |
|---|---|---|
| IAM auth (recommended) | --authentication-mode Type=iam | Cloud-native clients (Lambda, ECS, EKS). Requires Valkey 7.2+ or Redis OSS 7.0+ and TLS. |
| Password auth | --authentication-mode Type=password,Passwords=<pw> | Clients without IAM token support. Store password in Secrets Manager with rotation enabled. |
Always disable the default user: modify-user --user-id default --access-string "off ~* -@all"
Restore creates a new cache (cannot restore to an existing one). Constraints:
create-serverless-cache --snapshot-arns-to-restore vs create-replication-group --snapshot-name--final-snapshot-name (serverless) vs --final-snapshot-identifier (node-based). Memcached has no snapshot support; --final-snapshot-identifier does not apply to Memcached.export-serverless-cache-snapshot and then copied cross-region through S3.copy-snapshot --target-bucket. For serverless snapshots, use the separate export-serverless-cache-snapshot --serverless-cache-snapshot-name <name> --s3-bucket-name <bucket> command. Available for Valkey and Redis OSS only (not Serverless Memcached). Bucket needs elasticache.amazonaws.com service principal in its policy.python3 scripts/test_connection.py <endpoint> (or with --tunnel-mode if local)connectivity-diagnostics.mdpython3 scripts/security_audit.py --serverless <name> --region <region> to verify security posturepython3 scripts/generate_dashboards.py --serverless <name> --region <region>iac-reference.mdApply to all resources created by the skill:
| Tag Key | Value |
|---|---|
managed_by | aws-skills |
skill | elasticache |
skill_version | 1.0.0 |
created_by | elasticache-skill |
generation_model | model ID of the Claude instance that ran the skill (e.g. claude-sonnet-4-20250514) |
Environment | dev / staging / prod |