2

I am attempting to change the node type of Elasticache from older generation (cache.t2.) to newer generation (cache.t3.) using Terraform.

Able to modify the node types successfully for all of Memcached instances via terraform apply, but unfortunately when I attempt to change the node type of Redis using terraform apply the command reaches completion in just ~30s and no change is applied.

To apply the node types change I have to login to web console and click individual Redis instance & click modify and apply the pending changes and wait for it to complete. This is manual work for me, I have to do this for 100 Redis instances.

Is it possible to force terraform to apply the pending changes for Redis on Elasticache?.

2 Answers2

1

Did you try to argument https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster#apply_immediately ?

Maybe another solution is to run a bash script with aws-cli --apply-immediately option https://docs.aws.amazon.com/cli/latest/reference/elasticache/modify-cache-cluster.html

bast
  • 90
  • 8
  • Some reason terraform apply_immediately was not working, but the below aws-cli command worked fine: `aws-okta exec development -- aws --region us-west-2 elasticache modify-replication-group --replication-group-id "redis-clustername1" --apply-immediately` – Blissful Pathfinder Aug 27 '20 at 13:05
  • Still not working as of 27th October. Although I have noticed if you terraform apply a change with 'apply immediately' within the maintenance period then it modifies it – Toofy Oct 27 '21 at 18:15
1

For me Terraform's apply immediately is not working so I am using the aws-cli to apply changes immediately.

The below shell commands will identify the pending changes on all clusters and submit apply immediately on each cluster instance.

PRFIL="profile1"
RGN="eu-west-1"

for cls in `aws-okta exec $PRFIL -- aws --region $RGN elasticache describe-cache-clusters | jq '.CacheClusters | .[] | select((.PendingModifiedValues | length ) > 0 and (.CacheClusterStatus!="modifying")) | .ReplicationGroupId ' | sort | uniq `  
  do
  echo $cls
  echo "aws-okta exec $PRFIL -- aws --region $RGN elasticache modify-replication-group --replication-group-id $cls --apply-immediately" | bash -vx | jq '.ReplicationGroup.Status'
done