Multiple VM template - 1 agent + 1 user_data or ...?

Hi. Love Coder. All public templates appear to assume provisioning only 1 compute thing. I'm writing a Template that can provision a cluster of VMs but I'm getting an error when I try to create equal count of coder agents ("duplicate agent name: agent"). resource coder_agent is missing a name attribute so it can't be created in a loop/count. * Is there a reference for deploying multiple VMs? * Does each aws_instance need a unique coder_agent and unique user_data? Any guidance would be great. tyvm.
# data.coder_parameter.nodes.value = 3
# workspace deploy throws error: "duplicate agent name: agent"
resource "coder_agent" "agent" {
count = data.coder_parameter.nodes.value
arch = "amd64"
auth = "aws-instance-identity"
os = "linux"
dir = "/home/coder"
# data.coder_parameter.nodes.value = 3
# workspace deploy throws error: "duplicate agent name: agent"
resource "coder_agent" "agent" {
count = data.coder_parameter.nodes.value
arch = "amd64"
auth = "aws-instance-identity"
os = "linux"
dir = "/home/coder"
5 Replies
Codercord
Codercord3mo ago
<#1339871639327870996>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Phorcys
Phorcys3mo ago
I don't think you can create agents from a loop due to the way it's done because the resource name has to be unique, and even if you could, it would still be tough to identify which agent belongs to which VM.
Is there a reference for deploying multiple VMs?
I don't think so, no
Does each aws_instance need a unique coder_agent and unique user_data?
It all depends on what you want to achieve, the coder_agent is necessary if you want each VM to show up in the UI. for the user_data, assuming you're talking about cloud-init, reusing should be fine but you'll end up with duplicate hostnames
Matthew
MatthewOP3mo ago
@Phorcys That aligns with my late night trial-and-error debugging sessions. Thank you for the thoughtful reply!
Phorcys
Phorcys3mo ago
I'm closing this issue, please reopen it if you need help!
Codercord
Codercord3mo ago
@Phorcys closed the thread.

Did you find this page helpful?