Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions docs/resources/agents_default_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "coderd_agents_default_model Resource - terraform-provider-coderd"
subcategory: ""
description: |-
~> This resource is experimental. Changes are expected, and it is not recommended for production use.
~> Warning
This resource is only compatible with Coder version 2.37.0 https://github.com/coder/coder/releases/tag/v2.37.0 and later.
Selects which coderd_agents_model is the default chat model for Coder Agents in an organization.
Coder enforces a single default model per organization: marking a model as default automatically demotes the previous default in the same operation. Only one coderd_agents_default_model resource should exist per organization.
Destroying this resource does not clear the default server-side. Coder requires a default once models exist and promotes a replacement when the current default is removed, so deleting this resource only stops Terraform from managing which model is default.
---

# coderd_agents_default_model (Resource)

~> This resource is experimental. Changes are expected, and it is not recommended for production use.

~> **Warning**
This resource is only compatible with Coder version [2.37.0](https://github.com/coder/coder/releases/tag/v2.37.0) and later.

Selects which `coderd_agents_model` is the default chat model for Coder Agents in an organization.

Coder enforces a single default model per organization: marking a model as default automatically demotes the previous default in the same operation. Only one `coderd_agents_default_model` resource should exist per organization.

Destroying this resource does not clear the default server-side. Coder requires a default once models exist and promotes a replacement when the current default is removed, so deleting this resource only stops Terraform from managing which model is default.

## Example Usage

```terraform
variable "anthropic_api_key" {
type = string
sensitive = true
}

resource "coderd_ai_provider" "anthropic" {
type = "anthropic"
name = "anthropic"
base_url = "https://api.anthropic.com"

api_key_wo = var.anthropic_api_key
api_key_wo_version = 1
}

resource "coderd_agents_model" "sonnet" {
ai_provider_id = coderd_ai_provider.anthropic.id
model = "claude-3-5-sonnet-20241022"
display_name = "Claude 3.5 Sonnet"
context_limit = 200000
}

# Mark the Sonnet model as the default for Coder Agents in its organization.
# Setting a new default automatically demotes the previous one in that
# organization, so use one resource per organization.
resource "coderd_agents_default_model" "default" {
organization_id = coderd_agents_model.sonnet.organization_id
model_id = coderd_agents_model.sonnet.id
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `model_id` (String) ID of the `coderd_agents_model` to mark as the organization's default. Usually this is `coderd_agents_model.<name>.id`.
- `organization_id` (String) Organization ID whose default Agents model is managed.

### Read-Only

- `id` (String) Organization ID that identifies this organization's default Agents model selection.

## Import

Import is supported using the following syntax:

The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:

```shell
# The ID supplied is the name of the organization whose default model should be imported.
$ terraform import coderd_agents_default_model.default <organization-name>
```
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:

```terraform
import {
to = coderd_agents_default_model.default
id = "<organization-name>"
}
```
10 changes: 5 additions & 5 deletions docs/resources/agents_mcp_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: |-
~> Warning
This resource is only compatible with Coder version 2.37.0 https://github.com/coder/coder/releases/tag/v2.37.0 and later.
-> _wo attributes are write-only https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments: their values are sent to Coder but never stored in Terraform state. This resource therefore requires Terraform 1.11 or later.
Configures an organization-scoped MCP server for Coder Agents. Import IDs use <organization_id>/<id>. Changing url, auth_type, oauth2_token_url, oauth2_revocation_url, or oauth2_client_id invalidates users' stored OAuth tokens.
Configures an organization-scoped MCP server for Coder Agents. Import IDs use <organization-name>/<slug>. Changing url, auth_type, oauth2_token_url, oauth2_revocation_url, or oauth2_client_id invalidates users' stored OAuth tokens.
Coder runs OAuth2 discovery and dynamic client registration only when a server is created with auth_type = "oauth2" and no manual endpoints; updates never re-run discovery. To switch an existing server from manual OAuth2 configuration back to discovery, replace the resource (for example with terraform apply -replace). Removing the manual OAuth2 attributes from configuration leaves the stored values unmanaged rather than clearing them.
---

Expand All @@ -20,7 +20,7 @@ This resource is only compatible with Coder version [2.37.0](https://github.com/

-> `_wo` attributes are [write-only](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments): their values are sent to Coder but never stored in Terraform state. This resource therefore requires Terraform 1.11 or later.

Configures an organization-scoped MCP server for Coder Agents. Import IDs use `<organization_id>/<id>`. Changing `url`, `auth_type`, `oauth2_token_url`, `oauth2_revocation_url`, or `oauth2_client_id` invalidates users' stored OAuth tokens.
Configures an organization-scoped MCP server for Coder Agents. Import IDs use `<organization-name>/<slug>`. Changing `url`, `auth_type`, `oauth2_token_url`, `oauth2_revocation_url`, or `oauth2_client_id` invalidates users' stored OAuth tokens.

Coder runs OAuth2 discovery and dynamic client registration only when a server is created with `auth_type = "oauth2"` and no manual endpoints; updates never re-run discovery. To switch an existing server from manual OAuth2 configuration back to discovery, replace the resource (for example with `terraform apply -replace`). Removing the manual OAuth2 attributes from configuration leaves the stored values unmanaged rather than clearing them.

Expand Down Expand Up @@ -100,14 +100,14 @@ Import is supported using the following syntax:
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:

```shell
# The ID must contain the organization UUID and MCP server configuration UUID.
$ terraform import coderd_agents_mcp_server.example <organization-id>/<mcp-server-id>
# The ID must contain the organization name and the MCP server slug.
$ terraform import coderd_agents_mcp_server.example <organization-name>/<slug>
```
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:

```terraform
import {
to = coderd_agents_mcp_server.example
id = "<organization-id>/<mcp-server-id>"
id = "<organization-name>/<slug>"
}
```
82 changes: 0 additions & 82 deletions docs/resources/default_agents_model.md

This file was deleted.

10 changes: 10 additions & 0 deletions examples/resources/coderd_agents_default_model/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# The ID supplied is the name of the organization whose default model should be imported.
$ terraform import coderd_agents_default_model.default <organization-name>
```
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:

```terraform
import {
to = coderd_agents_default_model.default
id = "<organization-name>"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ resource "coderd_agents_model" "sonnet" {
context_limit = 200000
}

# Mark the Sonnet model as the deployment-wide default for Coder Agents.
# Setting a new default automatically demotes the previous one, so only a single
# coderd_default_agents_model resource should exist per deployment.
resource "coderd_default_agents_model" "default" {
model_id = coderd_agents_model.sonnet.id
# Mark the Sonnet model as the default for Coder Agents in its organization.
# Setting a new default automatically demotes the previous one in that
# organization, so use one resource per organization.
resource "coderd_agents_default_model" "default" {
organization_id = coderd_agents_model.sonnet.organization_id
model_id = coderd_agents_model.sonnet.id
}
6 changes: 3 additions & 3 deletions examples/resources/coderd_agents_mcp_server/import.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# The ID must contain the organization UUID and MCP server configuration UUID.
$ terraform import coderd_agents_mcp_server.example <organization-id>/<mcp-server-id>
# The ID must contain the organization name and the MCP server slug.
$ terraform import coderd_agents_mcp_server.example <organization-name>/<slug>
```
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:

```terraform
import {
to = coderd_agents_mcp_server.example
id = "<organization-id>/<mcp-server-id>"
id = "<organization-name>/<slug>"
}
10 changes: 0 additions & 10 deletions examples/resources/coderd_default_agents_model/import.sh

This file was deleted.

11 changes: 6 additions & 5 deletions integration/agents-model-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ resource "coderd_agents_model" "gpt_mini" {
})
}

# Select Claude Sonnet as the deployment-wide default. Coder auto-promotes the
# first model created (claude_opus) to default, so this resource demotes it and
# proves the pointer overrides the server's automatic choice end-to-end.
resource "coderd_default_agents_model" "default" {
model_id = coderd_agents_model.claude_sonnet.id
# Select Claude Sonnet as the default in its organization. Coder auto-promotes
# the first model created (claude_opus), so this resource demotes it and proves
# the pointer overrides the server's automatic choice end-to-end.
resource "coderd_agents_default_model" "default" {
Comment thread
ethanndickson marked this conversation as resolved.
organization_id = coderd_agents_model.claude_sonnet.organization_id
model_id = coderd_agents_model.claude_sonnet.id
}
2 changes: 1 addition & 1 deletion integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func TestIntegration(t *testing.T) {
t.Errorf("model_config for %s mismatch (-want +got):\n%s", m.Model, diff)
}
}
// coderd_default_agents_model.default points at claude_sonnet, which
// coderd_agents_default_model.default points at claude_sonnet, which
// demotes the auto-promoted claude_opus, so Sonnet is the sole default.
assert.Equal(t, []string{"claude-sonnet-4-6"}, defaults)
},
Expand Down
Loading