terraform-community-modules / tf_aws_elasticsearch

[DEPRECATED] Use https://github.com/terraform-aws-modules/terraform-aws-opensearch
MIT License
79 stars 97 forks source link

Module dependency #7

Closed pessoa closed 5 years ago

pessoa commented 6 years ago

If we make this module (in VPC mode) use subnet_ids:

  vpc_options   = {
    security_group_ids = ["${aws_security_group.es_sg.id}"]
    subnet_ids        = ["${module.vpc.private_subnets}"]
  }

from another module (eg. https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws) it will fail with:

* module.elastic_search.data.aws_iam_policy_document.es_vpc_management_access: data.aws_iam_policy_document.es_vpc_management_access: value of 'count' cannot be computed
* module.elastic_search.data.aws_iam_policy_document.es_management_access: data.aws_iam_policy_document.es_management_access: value of 'count' cannot be computed

I believe this is caused because there's no way to tell terraform about module dependencies: https://github.com/hashicorp/terraform/issues/10462

So far I have not been able to workaround it. Not even by using something like https://github.com/hashicorp/terraform/issues/1178#issuecomment-105613781

hakamadare commented 6 years ago

hm. i’ve seen this too, and have worked around it with something like this:

data “aws_subnet_ids” “es” {
  vpc_id = “${module.vpc.vpc_id}”

  tags {
    es = “True”
  }
}

iirc that will eventually produce a working configuration, provided you put the appropriate tag on the subnets in the other module.