I'm having a similar experience to <@U01G362MSJH> ...
# golang
a
I'm having a similar experience to @creamy-engine-1851 - it is sometimes difficult to figure out how to get the data out of many of these custom types. As an example, retrieving the cluster cachenode DNS addresses from an AWS elasticache cluster is baffling me at the moment. The object is of type
elasticache.ClusterCacheNodeArrayOutput
and despite the fact that it appears to be just a slice of maps, it's not iterable.
Also, confusingly, the docs:
Copy code
CacheNodes
[]ClusterCacheNode
List of node objects including id, address, port and availability_zone. Referenceable e.g. as ${aws_elasticache_cluster.bar.cache_nodes.0.address}
appear to suggest referencing via terraform syntax? lol.
Probably has a lot to do with me being in over my head with Go, admittedly.
b
@ambitious-salesmen-39356 it's not iterable because it's an output, if you wrap it in an Apple func you can iterate with it. What are you trying to do exactly?
a
Just get any and all DNS addresses out of the cluster. Memcached exposes it as a top level output, redis doesn't
b
are you trying to pass them to another resource?
a
yeah a route53 record and probably as a stack export as well.
b
can you share the code you have?
a
Well, what I was trying to do is not viable apparently =D
b
ha! maybe some pseudo code for wyat you're trying to do?
a
if this was python...
Copy code
deployment.clusterDNS = cluster.CacheNodes[0].address
it's a single node cluster, I'd have to range loop it for a multi-node naturally
I have no formal developer/CS background so I probably struggle more with this sort of thing than most.
b
me neither, we can struggle through this together 🙂 give me a little while I'll try some stuff out
a
You really have been exceptionally helpful. Sadly I sent in the registration forms for my firstborn many years ago, so I'll have to find something else to name in your honour
😂 1
b
can you share your memcache code @ambitious-salesmen-39356? I'm gonna try figure this out now
a
redis actually, or this would be easy 🙂
@billowy-army-68599 I actually figured it out: https://www.pulumi.com/docs/intro/concepts/programming-model/#lifting
deployment.clusterDNS *=* cluster.CacheNodes.Index(<http://pulumi.Int|pulumi.Int>(0)).Address().Elem()
b
oh wow, I was just fighting this!
I was using the index and the nodes as well, I'll post my solution in a bit but I'd love to see yours too
a
I mean, that's it really
Copy code
r53RecordName := pulumi.String(fmt.Sprintf("<http://redis.%s.veem.com|redis.%s.veem.com>", pulumi.String(ev.Get("name"))))

	_, err = route53.NewRecord(ctx, clusterName, &route53.RecordArgs{
		Name:   r53RecordName,
		Ttl:    <http://pulumi.Int|pulumi.Int>(300),
		Type:   pulumi.String("CNAME"),
		ZoneId: pulumi.String("<REDACTED>"),
		Records: pulumi.StringArray{
			cluster.CacheNodes.Index(<http://pulumi.Int|pulumi.Int>(0)).Address().Elem(),
		},
	}, pulumi.Parent(deployment))
b
love it!
a
I just pulled it from the programming model docs and prayed ¯\_(ツ)_/¯