Every time I ran a plan/apply, the two of the aws_route_table_association
resources are being forced to be recreated:
Terraform will perform the following actions:
<= module.mon.data.aws_subnet_ids.snetid
id: <computed>
ids.#: <computed>
tags.%: "1"
tags.Name: "zencopl-mon-*"
vpc_id: "vpc-0xxxxxxxxxxxxxxf"
-/+ module.mon.aws_route_table_association.snet[0] (new resource required)
id: "rtbassoc-058a3a92f42c51c9b" => <computed> (forces new resource)
route_table_id: "rtb-05401d41b7281d81f" => "rtb-05401d41b7281d81f"
subnet_id: "subnet-032a4ee6fc6ebe945" => "${data.aws_subnet_ids.snetid.ids[count.index]}" (forces new resource)
-/+ module.mon.aws_route_table_association.snet[1] (new resource required)
id: "rtbassoc-09858f67c89412e90" => <computed> (forces new resource)
route_table_id: "rtb-05401d41b7281d81f" => "rtb-05401d41b7281d81f"
subnet_id: "subnet-0bd026945b213219d" => "${data.aws_subnet_ids.snetid.ids[count.index]}" (forces new resource)
Looks like, it's because of the data-source that I defined to get the subnet-id:
data "aws_subnet_ids" "snetid" {
vpc_id = "${var.vpc_ids[var.idx]}"
depends_on = [ "aws_subnet.snets" ]
tags = {
Name = "${var.vpc_names[var.idx]}-${var.inst_role}-*"
}
}
and then it's used like this:
locals {
a_zones = ["${slice(data.aws_availability_zones.azs.names,0,2)}"]
}
#
resource "aws_route_table_association" "snet" {
count = "${length(local.a_zones)}"
route_table_id = "${aws_route_table.rtb.id}"
subnet_id = "${data.aws_subnet_ids.snetid.ids[count.index]}"
depends_on = [ "aws_subnet.snets" ]
}
#
module "mon" {
source = "../../modules/core-network"
idx = "0"
inst_role = "mon"
vpc_names = "${module.vpc.vpc_names}"
vpc_ids = "${module.vpc.vpc_ids}"
......
......
}
and I cannot findout what's going worng (or if it's a bug). I tried using
lifecycle { ignore_changes = [ .... ]}
but couldn't figure out either what's to ignore. Although it's not creating any real issue (from the deployment side) but creating a lot of confusions and really wnat to get it fixed. Can anyone point out what's I'm doing wrong or missing? Thsanks in advance!!
-San
0 Answers