Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Resource count can't reference module variable (Question) #57

Closed
egarbi opened this issue Oct 20, 2016 · 7 comments
Closed

Resource count can't reference module variable (Question) #57

egarbi opened this issue Oct 20, 2016 · 7 comments

Comments

@egarbi
Copy link

egarbi commented Oct 20, 2016

// This will allow route traffic through the VPC peering
resource "aws_route" "internal" {
  count                     = "${length(module.stack.internal_subnets)}"
  route_table_id            = "${element(split(",", module.stack.internal_route_tables), count.index)}"
  destination_cidr_block    = "10.22.0.0/16"
  vpc_peering_connection_id = "pcx-5660d13f"
}

Error loading Terraform: module root: 1 error(s) occurred:

  • aws_route.internal: resource count can't reference module variable: module.stack.internal_subnets

Any idea what I'm doing wrong here?

@achille-roussel
Copy link
Contributor

Which version of terraform you are using?

@egarbi
Copy link
Author

egarbi commented Oct 21, 2016

@achille-roussel terraform --version
Terraform v0.7.7

@egarbi
Copy link
Author

egarbi commented Oct 25, 2016

The latest one. 0.7.7

On 20 Oct 2016 6:37 p.m., "Achille" notifications@github.com wrote:

Which version of terraform you are using?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#57 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AC2JCUvHCmHZ1YRwossGprkJlkL-CQvdks5q16blgaJpZM4Kb-Oi
.

@achille-roussel
Copy link
Contributor

I guess I'll need to have a better look at the rest of the code, it's not clear from this snippet what could be wrong.

@egarbi
Copy link
Author

egarbi commented Oct 28, 2016

I think it might be related to this issue in terraform, not 100% sure though

@achille-roussel
Copy link
Contributor

Yeah we've seen issues with the count property when it's computed dynamically in the past, sometimes you can get around it, sometimes not.

@egarbi
Copy link
Author

egarbi commented Jun 8, 2017

@achille-roussel They fix this in 0.9 so this issue is not there anymore.
Actually, if I run my example above this is the plan proposed:

+ aws_route.internal.0
    destination_cidr_block:     "10.22.0.0/16"
    destination_prefix_list_id: "<computed>"
    egress_only_gateway_id:     "<computed>"
    gateway_id:                 "<computed>"
    instance_id:                "<computed>"
    instance_owner_id:          "<computed>"
    nat_gateway_id:             "<computed>"
    network_interface_id:       "<computed>"
    origin:                     "<computed>"
    route_table_id:             "rtb-40281024"
    state:                      "<computed>"
    vpc_peering_connection_id:  "pcx-5660d13f"

+ aws_route.internal.1
    destination_cidr_block:     "10.22.0.0/16"
    destination_prefix_list_id: "<computed>"
    egress_only_gateway_id:     "<computed>"
    gateway_id:                 "<computed>"
    instance_id:                "<computed>"
    instance_owner_id:          "<computed>"
    nat_gateway_id:             "<computed>"
    network_interface_id:       "<computed>"
    origin:                     "<computed>"
    route_table_id:             "rtb-47281023"
    state:                      "<computed>"
    vpc_peering_connection_id:  "pcx-5660d13f"

+ aws_route.internal.2
    destination_cidr_block:     "10.22.0.0/16"
    destination_prefix_list_id: "<computed>"
    egress_only_gateway_id:     "<computed>"
    gateway_id:                 "<computed>"
    instance_id:                "<computed>"
    instance_owner_id:          "<computed>"
    nat_gateway_id:             "<computed>"
    network_interface_id:       "<computed>"
    origin:                     "<computed>"
    route_table_id:             "rtb-41281025"
    state:                      "<computed>"
    vpc_peering_connection_id:  "pcx-5660d13f"

@egarbi egarbi closed this as completed Jun 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants