Skip to content
New issue

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

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

Already on GitHub? # to your account

Using maps in count throws circular dependency #12630

Closed
beanaroo opened this issue Mar 13, 2017 · 4 comments
Closed

Using maps in count throws circular dependency #12630

beanaroo opened this issue Mar 13, 2017 · 4 comments

Comments

@beanaroo
Copy link

Terraform Version

0.8.8

Affected Resource(s)

Please list the resources as a list, for example:

  • AWS Security group rule
  • core

Terraform Configuration Files

environment.tf

module "preview_api-nodejs" {
    source                   = "../modules/infrastructure_modules/api-nodejs"
....
    vpc                      = {
        vpc_id                = "${module.preview_vpc.vpc_id}"
        cidr                 = "${var.vpc["cidr"]}"
        Subnets              = "${join(",", module.preview_vpc.private_subnets)}"
        ELBSubnets           = "${join(",", module.preview_vpc.public_subnets)}"
        AssociatePublicIp    = "${var.nodejs_api_vpc["AssociatePublicIp"]}"
		ssh_allowed          = "${var.security["ssh_enabled"] == "true" ? 1 : 0}"
        ssh_allowed_cidrs    = "${join(",", concat(list(var.vpc["control_vpc_cidr"]), split(",",var.security["ssh_whitelist"])))}"
    }
....
}

../modules/infrastructure_modules/api-nodejs

....
resource "aws_security_group_rule" "ec2_allow_ssh" {
    count             = "${var.vpc["ssh_allowed"]}" 
    type              = "ingress"

    from_port         = 22
    to_port           = 22
    protocol          = "tcp"
    cidr_blocks       = ["${split(",", var.vpc["ssh_allowed_cidrs"])}"]

    security_group_id = "${aws_security_group.nodejs_ec2.id}"
}
....

Results in:

Errors:

  * 1 error(s) occurred:

* Cycle: module.preview_vpc.aws_subnet.public (destroy), module.preview_vpc.aws_subnet.public, module.preview_vpc.output.public_subnets, module.preview_ics-api-nodejs.var.vpc, module.preview_ics-api-nodejs.aws_security_group_rule.ec2_allow_ssh (destroy), module.preview_vpc.aws_subnet.private (destroy), module.preview_vpc.aws_subnet.private, module.preview_vpc.output.private_subnets

When we hardcode count to 1 or 0. It works.
count = "${"true" == "true" ? 1 : 0}" works too.

The work(hack)around suggested by a contributor here works but also only for string values.

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@beanaroo
Copy link
Author

On Terraform 0.9.0-dev, instead of a cycle error, I get a value of 'count' cannot be computed for the above configuration.

@beanaroo
Copy link
Author

I think I understand the issue now.

The maps I try to pass all contain values computed from other resources. So count cannot be computed because the map is incomplete.

If I am correct and if this is not a real issue, please feel free to close this report.

@jbardin
Copy link
Member

jbardin commented Mar 17, 2017

@beanaroo,

Yes, that sounds correct.

We do hope to improve the support for transferring interpolated values through module boundaries, but we can close this particular issue for now.

@jbardin jbardin closed this as completed Mar 17, 2017
@ghost
Copy link

ghost commented Apr 15, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 15, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

3 participants