Skip to content

coder_app: When adding multiple coder_agents gets duplicated coder_app #12949

Closed
@lasttry

Description

@lasttry

If we have multiple coder_agent and then add a coder_app for one of the agents we have it repeated across all agents. It's not respecting the agent_id.

terraform {
  required_version = ">= 1.0"
  required_providers {
    coder = {
      source  = "coder/coder"
      version = ">=0.20.0"
    }
    aws = {
      source  = "hashicorp/aws"
      version = ">=5.44"
    }
    hashicorptls = {
      source  = "hashicorp/tls"
      version = ">=4.0.5"
    }
    hashicorpnull = {
      source  = "hashicorp/null"
      version = ">=3.2.2"
    }
  }
}

provider "coder" {
}

data "coder_workspace" "me" {
}

 resource "coder_agent" "master" {
   arch               = "amd64"
   auth               = "aws-instance-identity"
   os                 = "linux"
 }

resource "coder_agent" "ad" {
  arch = "amd64"
  auth = "aws-instance-identity"
  os   = "windows"
}

locals {
  agent_master = coder_agent.master.init_script
  agent_ad = coder_agent.ad.init_script
}

resource "coder_app" "s2-studio" {
  agent_id     = coder_agent.master.id
  slug         = "s2-studio"
  display_name = "SingleStore Studio"
  icon         = "https://www.singlestore.com/favicon-32x32.png" # "${data.coder_workspace.me.access_url}/icon/code.svg"
  url          = "http://localhost:13337"
  share        = "owner"
  subdomain    = false
  healthcheck {
    url       = "http://localhost:13337/healthz"
    interval  = 5
    threshold = 6
  }
}

resource "aws_instance" "master" {
  count                  = 1
  ami                    = ""
  instance_type          = "m6a.xlarge"
  vpc_security_group_ids = [""]
  subnet_id              = ""
  user_data              = local.agent_master
}

resource "aws_instance" "ad" {
  count                  = 1
  ami                    = ""
  instance_type          = "m6a.xlarge"
  vpc_security_group_ids = [""]
  subnet_id              = ""
  user_data              = local.agent_ad
}

On the above example I am expecting that the coder_app.s2-studio to be present only in the coder_agent.master, but that is not the case:

image

Metadata

Metadata

Assignees

Labels

s2Broken use cases or features (with a workaround). Only humans may set this.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions