Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to specify the number of route table #3

Open
oonisim opened this issue Aug 5, 2018 · 2 comments
Open

Option to specify the number of route table #3

oonisim opened this issue Aug 5, 2018 · 2 comments

Comments

@oonisim
Copy link

oonisim commented Aug 5, 2018

Request

Enhancement to be able to use with Terraform registry AWS VPC

Possible change could be adding module values to specify the number of route tables to update. Or please suggest a work around to avoid the issue (below).

module "vpc-peering" {
  source  = "thomasbiddle/vpc-peering/aws"
  peer_from_vpc_name = "vpc_ms"
  peer_to_vpc_name   = "vpc_ds"
  peer_from_vpc_id = "${module.vpc_ms.vpc_id}"
  peer_to_vpc_id   = "${module.vpc_ds.vpc_id}"

  peer_from_route_tables        = [ "${module.vpc_ms.private_route_table_ids}" ]
  peer_from_route_tables_count  =  1  <---
  peer_to_route_tables          = [ "${module.vpc_ds.intra_route_table_ids}" ]
  peer_to_route_tables_count    =  1    <---
}

Background

Terraform has a limitation of #10857 not being able to run length() on a computed value.

This (error) is the correct behavior not because you're passing in a list, but because you're performing a function call length on a computed value.

Due to the limitation, the VPC peering module causes an error when used with AWS VPC module passing the route table resource yet to be created.

For example:

module "vpc-peering" {
  source  = "thomasbiddle/vpc-peering/aws"
  peer_from_vpc_name = "vpc_ms"
  peer_to_vpc_name   = "vpc_ds"
  peer_from_vpc_id = "${module.vpc_ms.vpc_id}"
  peer_to_vpc_id   = "${module.vpc_ds.vpc_id}"

  # Causes errors when length() is applied as the private_route_table_ids is yet to be created (calculated)
  peer_from_route_tables      = [ "${module.vpc_ms.private_route_table_ids}" ] 
  peer_to_route_tables          = [ "${module.vpc_ds.intra_route_table_ids}" ]
}

The error occurs in aws_route.tf to get the number of route tables to update.

resource "aws_route" "peer_from_to_peer_to" {
  count = "${length(var.peer_from_route_tables)}" <---
@thomasbiddle
Copy link
Owner

Thanks for the report - PRs are welcome :-)

@davehowell
Copy link

I've seen this working in Terraform 0.12, e.g. https://github.com/grem11n/terraform-aws-vpc-peering/blob/master/main.tf#L70

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants