Hello,
I have a slightly peculiar setup where my AWS instances need the load balancer's address as an argument on the command line.
The reason for this is to allow discovery of existing nodes. we don't need an exhaustive list, just a random one, with retries if the target is not good.
There are other ways of doing this (actual registry, round-robin DNS, etc...) but using a load balancer is fairly simple and reliable, and avoids extra infrastructure.
The problem I run into is a dependency cycle between aws_elb and aws_instance due to the aws_elb.instances field.
I currently get around it by starting the load balancer with an instance count of 0, outputting its dns_name, and using it as a variable on a second run with an instance count > 0.
While this works, it's a bit tedious from a user's perspective. Ideally, I would like to break the dependency cycle so that I could just use aws_elb.dns_name in the aws_instance config.
One way of doing this would be to reverse the instance <-> elb relationship by having a new "aws_instance.elb" field which would denote a new backend on a load balancer.
In our current deployment tool (also written in go), this is pretty much what I do: create the load balancer first then have instance creation trigger elb updates.
aws_elb.availability_zones can also refer to instances. I get around this by having a list of zones in a given region passed to the ELB.
I've only briefly examined the code, so I do not know how complex this would be, or whether it's even desirable. Hence the email rather than an issue.
I'd also be curious to see if anyone has a similar situation.
Our custom deployment tool (which I'm trying to replace with terraform) is the rest of the repository.
Thank you,
- Marc