Terraform aws provider

our security team has rolled out some policies and when running terraform plan, terraform has observed the drift and is overwritting the policies. so, in order to retain the policies i have included intelligent_tiering in my code, which comes with aws provider version: 1.51.

So, when i include aws provider 2.15 in my code, plan is failing because prevent_destroy is set to true for aws_elasticache_replication_group. this will destroy our cache, because of which we will lose all our pipeline data. i am on terraform 0.11.13.

How can i handle the below errors. I read in one of the terraform issues that upgrade to terraform 0.12.2 should work. but we are in contain mode. So, an easier workaround would be helpful. thanks in advance.

how to prevent Terraform plan failing as prevent_destroy is set to true for aws_elasticache_replication_group resource.
Error: Error running plan: 3 error(s) occurred:

  • module.swimlane.module.elastiCache.aws_elasticache_replication_group.spinnaker_cache: 1 error(s) occurred:

  • module.swimlane.module.elastiCache.aws_elasticache_replication_group.spinnaker_cache: aws_elasticache_replication_group.spinnaker_cache: the plan would destroy this resource, but it currently has lifecycle.prevent_destroy set to true. To avoid this error and continue with the plan, either disable lifecycle.prevent_destroy or adjust the scope of the plan using the -target flag.

  • module.swimlane.module.elastiCache.aws_elasticache_replication_group.clouddriver_cache: 1 error(s) occurred:

  • module.swimlane.module.elastiCache.aws_elasticache_replication_group.clouddriver_cache: aws_elasticache_replication_group.clouddriver_cache: the plan would destroy this resource, but it currently has lifecycle.prevent_destroy set to true. To avoid this error and continue with the plan, either disable lifecycle.prevent_destroy or adjust the scope of the plan using the -target flag.

  • module.swimlane.module.igor.aws_elasticache_replication_group.igor_cache: 1 error(s) occurred:

  • module.swimlane.module.igor.aws_elasticache_replication_group.igor_cache: aws_elasticache_replication_group.igor_cache: the plan would destroy this resource, but it currently has lifecycle.prevent_destroy set to true. To avoid this error and continue with the plan, either disable lifecycle.prevent_destroy or adjust the scope of the plan using the -target flag.

Summary

This text will be hidden

**strong text**