hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.59k stars 9.54k forks source link

Formatlist fails with Elasticache Cluster output #4761

Closed Bowbaq closed 7 years ago

Bowbaq commented 8 years ago

I'm trying to pass in the connection string for an Elasticache cluster as an environment variable to an Elastic Beanstalk environment. This is failing with the following error:

formatlist: no lists in arguments to formatlist in: 

${join(" ", formatlist("%s:%s", aws_elasticache_cluster.test.cache_nodes.*.address, aws_elasticache_cluster.test.cache_nodes.*.port))}

Relevant terraform script:

resource "aws_elasticache_cluster" "test" {
  cluster_id = "test"
  engine = "memcached"
  node_type = "cache.t2.small"
  port = 11211
  num_cache_nodes = "3"
  parameter_group_name = "default.memcached1.4"
  subnet_group_name = "${aws_elasticache_subnet_group.private.name}"
  security_group_ids = ["${aws_security_group.cache.id}"]

  tags {
    Name = "test"
    Environment = "Test"
  }
}

resource "aws_elastic_beanstalk_application" "test" {
  name = "test"
  description = "Test"
}

resource "aws_elastic_beanstalk_environment" "test" {
  name = "test"
  application = "${aws_elastic_beanstalk_application.test.name}"
  solution_stack_name = "64bit Amazon Linux 2015.09 v2.0.6 running Docker 1.7.1"

  # lots of irrelevant settings ...

  setting {
    namespace = "aws:elasticbeanstalk:application:environment"
    name = "ELASTICACHE_ADDRESSES"
    value = "${join(" ", formatlist("%s:%s", aws_elasticache_cluster.test.cache_nodes.*.address, aws_elasticache_cluster.test.cache_nodes.*.port))}"
  }
}

I built the latest terraform & inserted a debug statement in the formatlist implementation, it would appear it's getting "3" as a parameter (which happens to be the length of the list), instead of the list itself.

ligustah commented 7 years ago

Replying here, because it was the first hit on Google for me.

This is still happening in Terraform v0.8.7

astawiarski commented 7 years ago

Still happening in Terraform v0.9.6

ghost commented 4 years ago

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.