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

Resource 'aws_elasticache_cluster.redis' does not have attribute 'cache_nodes.*.address' for variable 'aws_elasticache_cluster.redis.cache_nodes.*.address' #214

Closed
hashibot opened this issue Jun 13, 2017 · 10 comments
Labels
bug Addresses a defect in current functionality. service/elasticache Issues and PRs that pertain to the elasticache service.

Comments

@hashibot
Copy link

This issue was originally opened by @iroller as hashicorp/terraform#7957. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

0.7.0

Affected Resource(s)

  • aws_elasticache_cluster
  • module outputs

Terraform Configuration Files

## Module
resource "aws_elasticache_cluster" "redis" {
  engine               = "redis"
...
}

// Addresses
output "addresses" {
  value = "${join(",", aws_elasticache_cluster.redis.cache_nodes.*.address)}"
}


## Using module
module "redis" {
...
}

output "redis_endpoint_addresses" {
  value = "${module.redis.addresses}"
}

Debug Output

[WARN] Output interpolation "addresses" failed: Resource 'aws_elasticache_cluster.redis' does not have attribute 'cache_nodes.*.address' for variable 'aws_elasticache_cluster.redis.cache_nodes.*.address'

Expected Behavior

I expected a string outout, e.g. "10.10.0.1,10.10.0.2"

Actual Behavior

No output at all.

References

@hashibot hashibot added the bug Addresses a defect in current functionality. label Jun 13, 2017
@sstarcher
Copy link

sstarcher commented Oct 10, 2017

I assumed I could work around this using

output nodes {
  value = "${var.replicas == "1" ?
      aws_elasticache_cluster.cache.cache_nodes.0.address :
      join(",",aws_elasticache_cluster.cache.cache_nodes.*.address)
  }"
}

but no luck anytime I reference aws_elasticache_cluster.cache.cache_nodes.*.address it drops the output

@radeksimko radeksimko added the service/elasticache Issues and PRs that pertain to the elasticache service. label Jan 25, 2018
@fstuck37
Copy link

Hi All,
Was wondering if anyone had an update on this?
Thanks,
Fred

@bradleyess
Copy link

I also get no output with this, any updates/fixes on the horizon? Workarounds would also be appreciated.

@pberswe
Copy link

pberswe commented May 3, 2018

I have the same issue as described

@hbagdi
Copy link

hbagdi commented Oct 1, 2018

Is there any update on this being fixed?
Happy to help out in fixing with some guidance.

@promiseofcake
Copy link

We also are having this issue.

@adybuxton
Copy link

I am also seeing a similar issue and i've raised a seperate issue here hashicorp/terraform#19964

@admssa
Copy link

admssa commented Apr 30, 2019

The funny thing - next construction works for other resources but not for this one:
with registry_enabled = false

output "redis_endpoint" {
  value = "${var.registry_enabled ?  aws_elasticache_cluster.docker-registry-cache.cache_nodes.0.address : "nope" }"

it returns

Resource 'aws_elasticache_cluster.docker-registry-cache' does not have attribute 'cache_nodes.0.address' for variable 'aws_elasticache_cluster.docker-registry-cache.cache_nodes.0.address'

Created route 53 CNAME record as a temporary solution:

resource "aws_route53_record" "redis_endpoint" {
  count                = "${var.registry_enabled ? 1 : 0}"
 ....
  type                 = "CNAME"

  records = ["${aws_elasticache_cluster.docker-registry-cache.cache_nodes.0.address}"]
}

output "redis_endpoint" {
  value = "${var.registry_enabled ? join(",", aws_route53_record.redis_endpoint.*.fqdn)  : "not available"}"
}

@bflad
Copy link
Contributor

bflad commented Jul 24, 2019

Hi folks 👋 This issue is resolved in Terraform 0.12, which fully supports indexed splat (*) notation with list attribute values.

Given this configuration:

terraform {
  required_providers {
    aws = "2.20.0"
  }
  required_version = "0.12.5"
}

provider "aws" {
  region = "us-east-2"
}

resource "aws_elasticache_cluster" "test" {
  cluster_id      = "bflad-testing"
  engine          = "memcached"
  node_type       = "cache.t2.micro"
  num_cache_nodes = 3
}

output "test1" {
  value = aws_elasticache_cluster.test.cache_nodes[*].address
}

output "test2" {
  value = element(aws_elasticache_cluster.test.cache_nodes[*].address, 1)
}

output "test3" {
  value = join(",", formatlist("%s:%s", aws_elasticache_cluster.test.cache_nodes[*].address, aws_elasticache_cluster.test.cache_nodes[*].port))
}

We can get the various expected outputs that were problematic in Terraform 0.11 and earlier:

Outputs:

test1 = [
  "bflad-testing.asxu6y.0001.use2.cache.amazonaws.com",
  "bflad-testing.asxu6y.0002.use2.cache.amazonaws.com",
  "bflad-testing.asxu6y.0003.use2.cache.amazonaws.com",
]
test2 = bflad-testing.asxu6y.0002.use2.cache.amazonaws.com
test3 = bflad-testing.asxu6y.0001.use2.cache.amazonaws.com:11211,bflad-testing.asxu6y.0002.use2.cache.amazonaws.com:11211,bflad-testing.asxu6y.0003.use2.cache.amazonaws.com:11211

Enjoy! 🚀

@bflad bflad closed this as completed Jul 24, 2019
@ghost
Copy link

ghost commented Nov 2, 2019

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/elasticache Issues and PRs that pertain to the elasticache service.
Projects
None yet
Development

No branches or pull requests