cloudposse / terraform-aws-vpc-peering

Terraform module to create a peering connection between two VPCs in the same AWS account.

Home Page:https://cloudposse.com/accelerate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unable to disable module: value of 'count' cannot be computed

dekimsey opened this issue · comments

terraform v0.11.11
I am unable to use the var.enabled functionality in this module. When attempting to add the module with the VPC peering to disabled by default to my terraform infrastructure I get the following error:

Error: Error refreshing state: 2 error(s) occurred:

* module.vpc_peering.data.aws_route_table.requestor: data.aws_route_table.requestor: value of 'count' cannot be computed
* module.vpc_peering.data.aws_route_table.acceptor: data.aws_route_table.acceptor: value of 'count' cannot be computed

Below is an excerpt:

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "1.53.0"
  # ....
}
locals {
  unique_namespace = "..."
}
module "vpc_peering" {
  source           = "git::https://github.com/cloudposse/terraform-aws-vpc-peering.git?ref=master"
  namespace        = "${local.unique_namespace}"
  stage            = "stg"
  name             = "them"
  acceptor_vpc_id  = "${module.vpc.vpc_id}"
  requestor_vpc_id = "vpc-deadbeef"
  enabled          = "false"

  tags {
    terraform = "true"
  }
}

I know this is an outstanding issue in Terraform, I was hoping there might be some guidelines on how to get this addressed correctly. Thank you!

Hello,
I have the same problem in terraform v0.11.11

@dekimsey @manpirez @kmcquade
I was trying to see what could be done to fix the count errors when enabled=false, but it looks like a difficult case because of many data source lookups :(
will see what could be done here

I've filed enough of these type of issues, I'm beginning to think trying to enable/disable resources with count logic in v0.11 is a fool's errand. I'm hoping the changes coming in v0.12 will help tackle this. If you are unable to come up with a reasonable resolution, that's okay! Thank you for looking into it though.

The module was converted to TF 0.12
https://github.com/cloudposse/terraform-aws-vpc-peering/releases/tag/0.3.0
The count issue must be solved for many cases (maybe not for all).
Take a look at the example https://github.com/cloudposse/terraform-aws-vpc-peering/tree/master/examples/complete
and Terratest for the example (which deploys it on AWS) https://github.com/cloudposse/terraform-aws-vpc-peering/blob/master/test/src/examples_complete_test.go
Will close for now.
Please report back if any issues.