如何解决Terraform Elasticache cacheParameterGroupAlreadyExists,terraform apply 不起作用
我正在尝试更新使用 Terraform 部署的现有资源 (Elasticache),现在当我尝试运行 terraform apply
时,控制台显示以下错误:
Error: error creating ElastiCache Parameter Group: CacheParameterGroupAlreadyExists: Parameter group lead-cache-lab already exists
在运行 terraform destroy
命令后,Elasticache 资源在 AWS Web 控制台中仍然可用。
我的 Terraform 版本是 0.12.13
这是我的 terraform 文件:
resource "aws_elasticache_parameter_group" "elasticache" {
name = "${var.name}-${var.environment_name}" # Here is the issue
description = "Parameter group for Elasticache"
family = var.parameter_group
}
resource "aws_security_group" "elasticache" {
name = "${var.name}-cache-${var.environment_name}" # Here is the issue
vpc_id = var.vpc_id
description = "Security group for Elasticache"
tags = {
Name = var.name
}
ingress {
protocol = -1
from_port = 0
to_port = 0
cidr_blocks = [var.vpc_cidr]
}
egress {
protocol = -1
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_elasticache_subnet_group" "elasticache" {
name = "${var.name}-${var.environment_name}" # Here is the issue
subnet_ids = [var.subnet_ids]
description = "Subnet group for Elasticache"
}
resource "aws_elasticache_replication_group" "replication-group" {
automatic_failover_enabled = true
availability_zones = ["us-east-1a","us-east-1b"]
replication_group_id = "${var.name}-${var.environment_name}" # Here is the issue
replication_group_description = var.replication_group_description
node_type = var.instance_type
number_cache_clusters = var.initial_cached_cluster
port = var.port
multi_az_enabled = true
lifecycle {
ignore_changes = [number_cache_clusters]
}
}
resource "aws_elasticache_cluster" "elasticache" {
cluster_id = "${var.environment_name}-${var.name}" # Here is the issue
replication_group_id = aws_elasticache_replication_group.replication-group.id
}
我尝试添加 # Here is the issue
一个词,但(显然)创建了一组新资源,但我无法覆盖现有资源或销毁这些资源以重新创建。
有人知道我该如何解决这个问题吗?
谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。