fix(provisioner): handle multiple agents, apps, scripts and envs (#13741)

This commit is contained in:
Marcin Tojek
2024-07-03 14:55:28 +02:00
committed by GitHub
parent f6639b788f
commit 07d41716ad
17 changed files with 2786 additions and 4 deletions

View File

@ -427,9 +427,11 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*State, error
for _, agents := range resourceAgents {
for _, agent := range agents {
// Find agents with the matching ID and associate them!
if agent.Id != attrs.AgentID {
if !dependsOnAgent(graph, agent, attrs.AgentID, resource) {
continue
}
agent.Apps = append(agent.Apps, &proto.App{
Slug: attrs.Slug,
DisplayName: attrs.DisplayName,
@ -461,7 +463,7 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*State, error
for _, agents := range resourceAgents {
for _, agent := range agents {
// Find agents with the matching ID and associate them!
if agent.Id != attrs.AgentID {
if !dependsOnAgent(graph, agent, attrs.AgentID, resource) {
continue
}
agent.ExtraEnvs = append(agent.ExtraEnvs, &proto.Env{
@ -487,7 +489,7 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*State, error
for _, agents := range resourceAgents {
for _, agent := range agents {
// Find agents with the matching ID and associate them!
if agent.Id != attrs.AgentID {
if !dependsOnAgent(graph, agent, attrs.AgentID, resource) {
continue
}
agent.Scripts = append(agent.Scripts, &proto.Script{
@ -748,6 +750,30 @@ func convertAddressToLabel(address string) string {
return cut
}
func dependsOnAgent(graph *gographviz.Graph, agent *proto.Agent, resourceAgentID string, resource *tfjson.StateResource) bool {
// Plan: we need to find if there is edge between the agent and the resource.
if agent.Id == "" && resourceAgentID == "" {
resourceNodeSuffix := fmt.Sprintf(`] %s.%s (expand)"`, resource.Type, resource.Name)
agentNodeSuffix := fmt.Sprintf(`] coder_agent.%s (expand)"`, agent.Name)
// Traverse the graph to check if the coder_<resource_type> depends on coder_agent.
for _, dst := range graph.Edges.SrcToDsts {
for _, edges := range dst {
for _, edge := range edges {
if strings.HasSuffix(edge.Src, resourceNodeSuffix) &&
strings.HasSuffix(edge.Dst, agentNodeSuffix) {
return true
}
}
}
}
return false
}
// Provision: agent ID and child resource ID are present
return agent.Id == resourceAgentID
}
type graphResource struct {
Label string
Depth uint

View File

@ -219,6 +219,150 @@ func TestConvertResources(t *testing.T) {
}},
}},
},
"multiple-agents-multiple-apps": {
resources: []*proto.Resource{{
Name: "dev1",
Type: "null_resource",
Agents: []*proto.Agent{{
Name: "dev1",
OperatingSystem: "linux",
Architecture: "amd64",
Apps: []*proto.App{
{
Slug: "app1",
DisplayName: "app1",
// Subdomain defaults to false if unspecified.
Subdomain: false,
},
{
Slug: "app2",
DisplayName: "app2",
Subdomain: true,
Healthcheck: &proto.Healthcheck{
Url: "http://localhost:13337/healthz",
Interval: 5,
Threshold: 6,
},
},
},
Auth: &proto.Agent_Token{},
ConnectionTimeoutSeconds: 120,
DisplayApps: &displayApps,
}},
}, {
Name: "dev2",
Type: "null_resource",
Agents: []*proto.Agent{{
Name: "dev2",
OperatingSystem: "linux",
Architecture: "amd64",
Apps: []*proto.App{
{
Slug: "app3",
DisplayName: "app3",
Subdomain: false,
},
},
Auth: &proto.Agent_Token{},
ConnectionTimeoutSeconds: 120,
DisplayApps: &displayApps,
}},
}},
},
"multiple-agents-multiple-envs": {
resources: []*proto.Resource{{
Name: "dev1",
Type: "null_resource",
Agents: []*proto.Agent{{
Name: "dev1",
OperatingSystem: "linux",
Architecture: "amd64",
ExtraEnvs: []*proto.Env{
{
Name: "ENV_1",
Value: "Env 1",
},
{
Name: "ENV_2",
Value: "Env 2",
},
},
Auth: &proto.Agent_Token{},
ConnectionTimeoutSeconds: 120,
DisplayApps: &displayApps,
}},
}, {
Name: "dev2",
Type: "null_resource",
Agents: []*proto.Agent{{
Name: "dev2",
OperatingSystem: "linux",
Architecture: "amd64",
ExtraEnvs: []*proto.Env{
{
Name: "ENV_3",
Value: "Env 3",
},
},
Auth: &proto.Agent_Token{},
ConnectionTimeoutSeconds: 120,
DisplayApps: &displayApps,
}},
}, {
Name: "env1",
Type: "coder_env",
}, {
Name: "env2",
Type: "coder_env",
}, {
Name: "env3",
Type: "coder_env",
}},
},
"multiple-agents-multiple-scripts": {
resources: []*proto.Resource{{
Name: "dev1",
Type: "null_resource",
Agents: []*proto.Agent{{
Name: "dev1",
OperatingSystem: "linux",
Architecture: "amd64",
Scripts: []*proto.Script{
{
DisplayName: "Foobar Script 1",
Script: "echo foobar 1",
RunOnStart: true,
},
{
DisplayName: "Foobar Script 2",
Script: "echo foobar 2",
RunOnStart: true,
},
},
Auth: &proto.Agent_Token{},
ConnectionTimeoutSeconds: 120,
DisplayApps: &displayApps,
}},
}, {
Name: "dev2",
Type: "null_resource",
Agents: []*proto.Agent{{
Name: "dev2",
OperatingSystem: "linux",
Architecture: "amd64",
Scripts: []*proto.Script{
{
DisplayName: "Foobar Script 3",
Script: "echo foobar 3",
RunOnStart: true,
},
},
Auth: &proto.Agent_Token{},
ConnectionTimeoutSeconds: 120,
DisplayApps: &displayApps,
}},
}},
},
// Tests fetching metadata about workspace resources.
"resource-metadata": {
resources: []*proto.Resource{{
@ -565,6 +709,18 @@ func TestConvertResources(t *testing.T) {
sortResources(state.Resources)
sortExternalAuthProviders(state.ExternalAuthProviders)
for _, resource := range state.Resources {
for _, agent := range resource.Agents {
agent.Id = ""
if agent.GetToken() != "" {
agent.Auth = &proto.Agent_Token{}
}
if agent.GetInstanceId() != "" {
agent.Auth = &proto.Agent_InstanceId{}
}
}
}
expectedNoMetadata := make([]*proto.Resource, 0)
for _, resource := range expected.resources {
resourceCopy, _ := protobuf.Clone(resource).(*proto.Resource)
@ -642,7 +798,6 @@ func TestConvertResources(t *testing.T) {
var resourcesMap []map[string]interface{}
err = json.Unmarshal(data, &resourcesMap)
require.NoError(t, err)
require.Equal(t, expectedMap, resourcesMap)
require.ElementsMatch(t, expected.externalAuthProviders, state.ExternalAuthProviders)
})
@ -911,6 +1066,12 @@ func sortResources(resources []*proto.Resource) {
sort.Slice(agent.Apps, func(i, j int) bool {
return agent.Apps[i].Slug < agent.Apps[j].Slug
})
sort.Slice(agent.ExtraEnvs, func(i, j int) bool {
return agent.ExtraEnvs[i].Name < agent.ExtraEnvs[j].Name
})
sort.Slice(agent.Scripts, func(i, j int) bool {
return agent.Scripts[i].DisplayName < agent.Scripts[j].DisplayName
})
}
sort.Slice(resource.Agents, func(i, j int) bool {
return resource.Agents[i].Name < resource.Agents[j].Name

View File

@ -0,0 +1,57 @@
terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.22.0"
}
}
}
resource "coder_agent" "dev1" {
os = "linux"
arch = "amd64"
}
resource "coder_agent" "dev2" {
os = "linux"
arch = "amd64"
}
# app1 is for testing subdomain default.
resource "coder_app" "app1" {
agent_id = coder_agent.dev1.id
slug = "app1"
# subdomain should default to false.
# subdomain = false
}
# app2 tests that subdomaincan be true, and that healthchecks work.
resource "coder_app" "app2" {
agent_id = coder_agent.dev1.id
slug = "app2"
subdomain = true
healthcheck {
url = "http://localhost:13337/healthz"
interval = 5
threshold = 6
}
}
# app3 tests that subdomain can explicitly be false.
resource "coder_app" "app3" {
agent_id = coder_agent.dev2.id
slug = "app3"
subdomain = false
}
resource "null_resource" "dev1" {
depends_on = [
coder_agent.dev1
]
}
resource "null_resource" "dev2" {
depends_on = [
coder_agent.dev2
]
}

View File

@ -0,0 +1,31 @@
digraph {
compound = "true"
newrank = "true"
subgraph "root" {
"[root] coder_agent.dev1 (expand)" [label = "coder_agent.dev1", shape = "box"]
"[root] coder_agent.dev2 (expand)" [label = "coder_agent.dev2", shape = "box"]
"[root] coder_app.app1 (expand)" [label = "coder_app.app1", shape = "box"]
"[root] coder_app.app2 (expand)" [label = "coder_app.app2", shape = "box"]
"[root] coder_app.app3 (expand)" [label = "coder_app.app3", shape = "box"]
"[root] null_resource.dev1 (expand)" [label = "null_resource.dev1", shape = "box"]
"[root] null_resource.dev2 (expand)" [label = "null_resource.dev2", shape = "box"]
"[root] provider[\"registry.terraform.io/coder/coder\"]" [label = "provider[\"registry.terraform.io/coder/coder\"]", shape = "diamond"]
"[root] provider[\"registry.terraform.io/hashicorp/null\"]" [label = "provider[\"registry.terraform.io/hashicorp/null\"]", shape = "diamond"]
"[root] coder_agent.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_agent.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_app.app1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_app.app2 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_app.app3 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] null_resource.dev2 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_app.app1 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_app.app2 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_app.app3 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev1 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev2 (expand)"
"[root] root" -> "[root] provider[\"registry.terraform.io/coder/coder\"] (close)"
"[root] root" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)"
}
}

View File

@ -0,0 +1,594 @@
{
"format_version": "1.2",
"terraform_version": "1.8.5",
"planned_values": {
"root_module": {
"resources": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [],
"metadata": [],
"token": true
}
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [],
"metadata": [],
"token": true
}
},
{
"address": "coder_app.app1",
"mode": "managed",
"type": "coder_app",
"name": "app1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"command": null,
"display_name": null,
"external": false,
"healthcheck": [],
"icon": null,
"name": null,
"order": null,
"relative_path": null,
"share": "owner",
"slug": "app1",
"subdomain": null,
"url": null
},
"sensitive_values": {
"healthcheck": []
}
},
{
"address": "coder_app.app2",
"mode": "managed",
"type": "coder_app",
"name": "app2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"command": null,
"display_name": null,
"external": false,
"healthcheck": [
{
"interval": 5,
"threshold": 6,
"url": "http://localhost:13337/healthz"
}
],
"icon": null,
"name": null,
"order": null,
"relative_path": null,
"share": "owner",
"slug": "app2",
"subdomain": true,
"url": null
},
"sensitive_values": {
"healthcheck": [
{}
]
}
},
{
"address": "coder_app.app3",
"mode": "managed",
"type": "coder_app",
"name": "app3",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"command": null,
"display_name": null,
"external": false,
"healthcheck": [],
"icon": null,
"name": null,
"order": null,
"relative_path": null,
"share": "owner",
"slug": "app3",
"subdomain": false,
"url": null
},
"sensitive_values": {
"healthcheck": []
}
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"triggers": null
},
"sensitive_values": {}
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"triggers": null
},
"sensitive_values": {}
}
]
}
},
"resource_changes": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"after_unknown": {
"display_apps": true,
"id": true,
"init_script": true,
"metadata": [],
"token": true
},
"before_sensitive": false,
"after_sensitive": {
"display_apps": [],
"metadata": [],
"token": true
}
}
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"after_unknown": {
"display_apps": true,
"id": true,
"init_script": true,
"metadata": [],
"token": true
},
"before_sensitive": false,
"after_sensitive": {
"display_apps": [],
"metadata": [],
"token": true
}
}
},
{
"address": "coder_app.app1",
"mode": "managed",
"type": "coder_app",
"name": "app1",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"command": null,
"display_name": null,
"external": false,
"healthcheck": [],
"icon": null,
"name": null,
"order": null,
"relative_path": null,
"share": "owner",
"slug": "app1",
"subdomain": null,
"url": null
},
"after_unknown": {
"agent_id": true,
"healthcheck": [],
"id": true
},
"before_sensitive": false,
"after_sensitive": {
"healthcheck": []
}
}
},
{
"address": "coder_app.app2",
"mode": "managed",
"type": "coder_app",
"name": "app2",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"command": null,
"display_name": null,
"external": false,
"healthcheck": [
{
"interval": 5,
"threshold": 6,
"url": "http://localhost:13337/healthz"
}
],
"icon": null,
"name": null,
"order": null,
"relative_path": null,
"share": "owner",
"slug": "app2",
"subdomain": true,
"url": null
},
"after_unknown": {
"agent_id": true,
"healthcheck": [
{}
],
"id": true
},
"before_sensitive": false,
"after_sensitive": {
"healthcheck": [
{}
]
}
}
},
{
"address": "coder_app.app3",
"mode": "managed",
"type": "coder_app",
"name": "app3",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"command": null,
"display_name": null,
"external": false,
"healthcheck": [],
"icon": null,
"name": null,
"order": null,
"relative_path": null,
"share": "owner",
"slug": "app3",
"subdomain": false,
"url": null
},
"after_unknown": {
"agent_id": true,
"healthcheck": [],
"id": true
},
"before_sensitive": false,
"after_sensitive": {
"healthcheck": []
}
}
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_name": "registry.terraform.io/hashicorp/null",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"triggers": null
},
"after_unknown": {
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_name": "registry.terraform.io/hashicorp/null",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"triggers": null
},
"after_unknown": {
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
}
],
"configuration": {
"provider_config": {
"coder": {
"name": "coder",
"full_name": "registry.terraform.io/coder/coder",
"version_constraint": "0.22.0"
},
"null": {
"name": "null",
"full_name": "registry.terraform.io/hashicorp/null"
}
},
"root_module": {
"resources": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_config_key": "coder",
"expressions": {
"arch": {
"constant_value": "amd64"
},
"os": {
"constant_value": "linux"
}
},
"schema_version": 0
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_config_key": "coder",
"expressions": {
"arch": {
"constant_value": "amd64"
},
"os": {
"constant_value": "linux"
}
},
"schema_version": 0
},
{
"address": "coder_app.app1",
"mode": "managed",
"type": "coder_app",
"name": "app1",
"provider_config_key": "coder",
"expressions": {
"agent_id": {
"references": [
"coder_agent.dev1.id",
"coder_agent.dev1"
]
},
"slug": {
"constant_value": "app1"
}
},
"schema_version": 0
},
{
"address": "coder_app.app2",
"mode": "managed",
"type": "coder_app",
"name": "app2",
"provider_config_key": "coder",
"expressions": {
"agent_id": {
"references": [
"coder_agent.dev1.id",
"coder_agent.dev1"
]
},
"healthcheck": [
{
"interval": {
"constant_value": 5
},
"threshold": {
"constant_value": 6
},
"url": {
"constant_value": "http://localhost:13337/healthz"
}
}
],
"slug": {
"constant_value": "app2"
},
"subdomain": {
"constant_value": true
}
},
"schema_version": 0
},
{
"address": "coder_app.app3",
"mode": "managed",
"type": "coder_app",
"name": "app3",
"provider_config_key": "coder",
"expressions": {
"agent_id": {
"references": [
"coder_agent.dev2.id",
"coder_agent.dev2"
]
},
"slug": {
"constant_value": "app3"
},
"subdomain": {
"constant_value": false
}
},
"schema_version": 0
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_config_key": "null",
"schema_version": 0,
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_config_key": "null",
"schema_version": 0,
"depends_on": [
"coder_agent.dev2"
]
}
]
}
},
"relevant_attributes": [
{
"resource": "coder_agent.dev1",
"attribute": [
"id"
]
},
{
"resource": "coder_agent.dev2",
"attribute": [
"id"
]
}
],
"timestamp": "2024-07-01T14:04:52Z",
"applyable": true,
"complete": true,
"errored": false
}

View File

@ -0,0 +1,31 @@
digraph {
compound = "true"
newrank = "true"
subgraph "root" {
"[root] coder_agent.dev1 (expand)" [label = "coder_agent.dev1", shape = "box"]
"[root] coder_agent.dev2 (expand)" [label = "coder_agent.dev2", shape = "box"]
"[root] coder_app.app1 (expand)" [label = "coder_app.app1", shape = "box"]
"[root] coder_app.app2 (expand)" [label = "coder_app.app2", shape = "box"]
"[root] coder_app.app3 (expand)" [label = "coder_app.app3", shape = "box"]
"[root] null_resource.dev1 (expand)" [label = "null_resource.dev1", shape = "box"]
"[root] null_resource.dev2 (expand)" [label = "null_resource.dev2", shape = "box"]
"[root] provider[\"registry.terraform.io/coder/coder\"]" [label = "provider[\"registry.terraform.io/coder/coder\"]", shape = "diamond"]
"[root] provider[\"registry.terraform.io/hashicorp/null\"]" [label = "provider[\"registry.terraform.io/hashicorp/null\"]", shape = "diamond"]
"[root] coder_agent.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_agent.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_app.app1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_app.app2 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_app.app3 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] null_resource.dev2 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_app.app1 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_app.app2 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_app.app3 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev1 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev2 (expand)"
"[root] root" -> "[root] provider[\"registry.terraform.io/coder/coder\"] (close)"
"[root] root" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)"
}
}

View File

@ -0,0 +1,230 @@
{
"format_version": "1.0",
"terraform_version": "1.8.5",
"values": {
"root_module": {
"resources": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"display_apps": [
{
"port_forwarding_helper": true,
"ssh_helper": true,
"vscode": true,
"vscode_insiders": false,
"web_terminal": true
}
],
"env": null,
"id": "f70d5406-a47c-43f5-bc9f-303754927057",
"init_script": "",
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"token": "ca4bb419-556c-4e05-9ff1-9770f374da4e",
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [
{}
],
"metadata": [],
"token": true
}
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"display_apps": [
{
"port_forwarding_helper": true,
"ssh_helper": true,
"vscode": true,
"vscode_insiders": false,
"web_terminal": true
}
],
"env": null,
"id": "ad49af97-8978-4464-a33a-7a078384292f",
"init_script": "",
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"token": "f6570798-baae-48a3-991c-a8560ce89d4f",
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [
{}
],
"metadata": [],
"token": true
}
},
{
"address": "coder_app.app1",
"mode": "managed",
"type": "coder_app",
"name": "app1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"agent_id": "f70d5406-a47c-43f5-bc9f-303754927057",
"command": null,
"display_name": null,
"external": false,
"healthcheck": [],
"icon": null,
"id": "64cda2f9-04da-42bc-9354-da760d063e59",
"name": null,
"order": null,
"relative_path": null,
"share": "owner",
"slug": "app1",
"subdomain": null,
"url": null
},
"sensitive_values": {
"healthcheck": []
},
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "coder_app.app2",
"mode": "managed",
"type": "coder_app",
"name": "app2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"agent_id": "f70d5406-a47c-43f5-bc9f-303754927057",
"command": null,
"display_name": null,
"external": false,
"healthcheck": [
{
"interval": 5,
"threshold": 6,
"url": "http://localhost:13337/healthz"
}
],
"icon": null,
"id": "6ff03bae-cb3a-4b32-a475-05a4e104755d",
"name": null,
"order": null,
"relative_path": null,
"share": "owner",
"slug": "app2",
"subdomain": true,
"url": null
},
"sensitive_values": {
"healthcheck": [
{}
]
},
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "coder_app.app3",
"mode": "managed",
"type": "coder_app",
"name": "app3",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"agent_id": "ad49af97-8978-4464-a33a-7a078384292f",
"command": null,
"display_name": null,
"external": false,
"healthcheck": [],
"icon": null,
"id": "59a1c0f0-21fb-4867-a7db-33a4d8a3d18e",
"name": null,
"order": null,
"relative_path": null,
"share": "owner",
"slug": "app3",
"subdomain": false,
"url": null
},
"sensitive_values": {
"healthcheck": []
},
"depends_on": [
"coder_agent.dev2"
]
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"id": "3152137311613337201",
"triggers": null
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"id": "4927717367839364271",
"triggers": null
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev2"
]
}
]
}
}
}

View File

@ -0,0 +1,48 @@
terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.22.0"
}
}
}
resource "coder_agent" "dev1" {
os = "linux"
arch = "amd64"
}
resource "coder_agent" "dev2" {
os = "linux"
arch = "amd64"
}
resource "coder_env" "env1" {
agent_id = coder_agent.dev1.id
name = "ENV_1"
value = "Env 1"
}
resource "coder_env" "env2" {
agent_id = coder_agent.dev1.id
name = "ENV_2"
value = "Env 2"
}
resource "coder_env" "env3" {
agent_id = coder_agent.dev2.id
name = "ENV_3"
value = "Env 3"
}
resource "null_resource" "dev1" {
depends_on = [
coder_agent.dev1
]
}
resource "null_resource" "dev2" {
depends_on = [
coder_agent.dev2
]
}

View File

@ -0,0 +1,31 @@
digraph {
compound = "true"
newrank = "true"
subgraph "root" {
"[root] coder_agent.dev1 (expand)" [label = "coder_agent.dev1", shape = "box"]
"[root] coder_agent.dev2 (expand)" [label = "coder_agent.dev2", shape = "box"]
"[root] coder_env.env1 (expand)" [label = "coder_env.env1", shape = "box"]
"[root] coder_env.env2 (expand)" [label = "coder_env.env2", shape = "box"]
"[root] coder_env.env3 (expand)" [label = "coder_env.env3", shape = "box"]
"[root] null_resource.dev1 (expand)" [label = "null_resource.dev1", shape = "box"]
"[root] null_resource.dev2 (expand)" [label = "null_resource.dev2", shape = "box"]
"[root] provider[\"registry.terraform.io/coder/coder\"]" [label = "provider[\"registry.terraform.io/coder/coder\"]", shape = "diamond"]
"[root] provider[\"registry.terraform.io/hashicorp/null\"]" [label = "provider[\"registry.terraform.io/hashicorp/null\"]", shape = "diamond"]
"[root] coder_agent.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_agent.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_env.env1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_env.env2 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_env.env3 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] null_resource.dev2 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_env.env1 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_env.env2 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_env.env3 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev1 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev2 (expand)"
"[root] root" -> "[root] provider[\"registry.terraform.io/coder/coder\"] (close)"
"[root] root" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)"
}
}

View File

@ -0,0 +1,491 @@
{
"format_version": "1.2",
"terraform_version": "1.8.5",
"planned_values": {
"root_module": {
"resources": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [],
"metadata": [],
"token": true
}
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [],
"metadata": [],
"token": true
}
},
{
"address": "coder_env.env1",
"mode": "managed",
"type": "coder_env",
"name": "env1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"name": "ENV_1",
"value": "Env 1"
},
"sensitive_values": {}
},
{
"address": "coder_env.env2",
"mode": "managed",
"type": "coder_env",
"name": "env2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"name": "ENV_2",
"value": "Env 2"
},
"sensitive_values": {}
},
{
"address": "coder_env.env3",
"mode": "managed",
"type": "coder_env",
"name": "env3",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"name": "ENV_3",
"value": "Env 3"
},
"sensitive_values": {}
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"triggers": null
},
"sensitive_values": {}
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"triggers": null
},
"sensitive_values": {}
}
]
}
},
"resource_changes": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"after_unknown": {
"display_apps": true,
"id": true,
"init_script": true,
"metadata": [],
"token": true
},
"before_sensitive": false,
"after_sensitive": {
"display_apps": [],
"metadata": [],
"token": true
}
}
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"after_unknown": {
"display_apps": true,
"id": true,
"init_script": true,
"metadata": [],
"token": true
},
"before_sensitive": false,
"after_sensitive": {
"display_apps": [],
"metadata": [],
"token": true
}
}
},
{
"address": "coder_env.env1",
"mode": "managed",
"type": "coder_env",
"name": "env1",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"name": "ENV_1",
"value": "Env 1"
},
"after_unknown": {
"agent_id": true,
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
},
{
"address": "coder_env.env2",
"mode": "managed",
"type": "coder_env",
"name": "env2",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"name": "ENV_2",
"value": "Env 2"
},
"after_unknown": {
"agent_id": true,
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
},
{
"address": "coder_env.env3",
"mode": "managed",
"type": "coder_env",
"name": "env3",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"name": "ENV_3",
"value": "Env 3"
},
"after_unknown": {
"agent_id": true,
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_name": "registry.terraform.io/hashicorp/null",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"triggers": null
},
"after_unknown": {
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_name": "registry.terraform.io/hashicorp/null",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"triggers": null
},
"after_unknown": {
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
}
],
"configuration": {
"provider_config": {
"coder": {
"name": "coder",
"full_name": "registry.terraform.io/coder/coder",
"version_constraint": "0.22.0"
},
"null": {
"name": "null",
"full_name": "registry.terraform.io/hashicorp/null"
}
},
"root_module": {
"resources": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_config_key": "coder",
"expressions": {
"arch": {
"constant_value": "amd64"
},
"os": {
"constant_value": "linux"
}
},
"schema_version": 0
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_config_key": "coder",
"expressions": {
"arch": {
"constant_value": "amd64"
},
"os": {
"constant_value": "linux"
}
},
"schema_version": 0
},
{
"address": "coder_env.env1",
"mode": "managed",
"type": "coder_env",
"name": "env1",
"provider_config_key": "coder",
"expressions": {
"agent_id": {
"references": [
"coder_agent.dev1.id",
"coder_agent.dev1"
]
},
"name": {
"constant_value": "ENV_1"
},
"value": {
"constant_value": "Env 1"
}
},
"schema_version": 0
},
{
"address": "coder_env.env2",
"mode": "managed",
"type": "coder_env",
"name": "env2",
"provider_config_key": "coder",
"expressions": {
"agent_id": {
"references": [
"coder_agent.dev1.id",
"coder_agent.dev1"
]
},
"name": {
"constant_value": "ENV_2"
},
"value": {
"constant_value": "Env 2"
}
},
"schema_version": 0
},
{
"address": "coder_env.env3",
"mode": "managed",
"type": "coder_env",
"name": "env3",
"provider_config_key": "coder",
"expressions": {
"agent_id": {
"references": [
"coder_agent.dev2.id",
"coder_agent.dev2"
]
},
"name": {
"constant_value": "ENV_3"
},
"value": {
"constant_value": "Env 3"
}
},
"schema_version": 0
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_config_key": "null",
"schema_version": 0,
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_config_key": "null",
"schema_version": 0,
"depends_on": [
"coder_agent.dev2"
]
}
]
}
},
"relevant_attributes": [
{
"resource": "coder_agent.dev1",
"attribute": [
"id"
]
},
{
"resource": "coder_agent.dev2",
"attribute": [
"id"
]
}
],
"timestamp": "2024-07-02T13:02:20Z",
"applyable": true,
"complete": true,
"errored": false
}

View File

@ -0,0 +1,31 @@
digraph {
compound = "true"
newrank = "true"
subgraph "root" {
"[root] coder_agent.dev1 (expand)" [label = "coder_agent.dev1", shape = "box"]
"[root] coder_agent.dev2 (expand)" [label = "coder_agent.dev2", shape = "box"]
"[root] coder_env.env1 (expand)" [label = "coder_env.env1", shape = "box"]
"[root] coder_env.env2 (expand)" [label = "coder_env.env2", shape = "box"]
"[root] coder_env.env3 (expand)" [label = "coder_env.env3", shape = "box"]
"[root] null_resource.dev1 (expand)" [label = "null_resource.dev1", shape = "box"]
"[root] null_resource.dev2 (expand)" [label = "null_resource.dev2", shape = "box"]
"[root] provider[\"registry.terraform.io/coder/coder\"]" [label = "provider[\"registry.terraform.io/coder/coder\"]", shape = "diamond"]
"[root] provider[\"registry.terraform.io/hashicorp/null\"]" [label = "provider[\"registry.terraform.io/hashicorp/null\"]", shape = "diamond"]
"[root] coder_agent.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_agent.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_env.env1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_env.env2 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_env.env3 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] null_resource.dev2 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_env.env1 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_env.env2 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_env.env3 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev1 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev2 (expand)"
"[root] root" -> "[root] provider[\"registry.terraform.io/coder/coder\"] (close)"
"[root] root" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)"
}
}

View File

@ -0,0 +1,186 @@
{
"format_version": "1.0",
"terraform_version": "1.8.5",
"values": {
"root_module": {
"resources": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"display_apps": [
{
"port_forwarding_helper": true,
"ssh_helper": true,
"vscode": true,
"vscode_insiders": false,
"web_terminal": true
}
],
"env": null,
"id": "20f30173-700b-48fa-954a-3303ea0ea62f",
"init_script": "",
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"token": "0efed72e-b582-4573-beca-5bba2aff1a71",
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [
{}
],
"metadata": [],
"token": true
}
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"display_apps": [
{
"port_forwarding_helper": true,
"ssh_helper": true,
"vscode": true,
"vscode_insiders": false,
"web_terminal": true
}
],
"env": null,
"id": "71dec38a-0885-48c3-834a-1c3455a01e43",
"init_script": "",
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"token": "cec160ae-dbab-44d9-99ba-dd4525448de7",
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [
{}
],
"metadata": [],
"token": true
}
},
{
"address": "coder_env.env1",
"mode": "managed",
"type": "coder_env",
"name": "env1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"agent_id": "20f30173-700b-48fa-954a-3303ea0ea62f",
"id": "ad9d0cba-ace3-4257-a0e9-8521354c6eac",
"name": "ENV_1",
"value": "Env 1"
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "coder_env.env2",
"mode": "managed",
"type": "coder_env",
"name": "env2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"agent_id": "20f30173-700b-48fa-954a-3303ea0ea62f",
"id": "da1c5415-4e5e-4bd4-bb6a-2848dfe751e8",
"name": "ENV_2",
"value": "Env 2"
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "coder_env.env3",
"mode": "managed",
"type": "coder_env",
"name": "env3",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"agent_id": "71dec38a-0885-48c3-834a-1c3455a01e43",
"id": "06a07733-acb6-4be4-852f-ba4689230d3b",
"name": "ENV_3",
"value": "Env 3"
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev2"
]
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"id": "4158512646691730095",
"triggers": null
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"id": "8795184716221619179",
"triggers": null
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev2"
]
}
]
}
}
}

View File

@ -0,0 +1,54 @@
terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.22.0"
}
}
}
resource "coder_agent" "dev1" {
os = "linux"
arch = "amd64"
}
resource "coder_agent" "dev2" {
os = "linux"
arch = "amd64"
}
resource "coder_script" "script1" {
agent_id = coder_agent.dev1.id
display_name = "Foobar Script 1"
script = "echo foobar 1"
run_on_start = true
}
resource "coder_script" "script2" {
agent_id = coder_agent.dev1.id
display_name = "Foobar Script 2"
script = "echo foobar 2"
run_on_start = true
}
resource "coder_script" "script3" {
agent_id = coder_agent.dev2.id
display_name = "Foobar Script 3"
script = "echo foobar 3"
run_on_start = true
}
resource "null_resource" "dev1" {
depends_on = [
coder_agent.dev1
]
}
resource "null_resource" "dev2" {
depends_on = [
coder_agent.dev2
]
}

View File

@ -0,0 +1,31 @@
digraph {
compound = "true"
newrank = "true"
subgraph "root" {
"[root] coder_agent.dev1 (expand)" [label = "coder_agent.dev1", shape = "box"]
"[root] coder_agent.dev2 (expand)" [label = "coder_agent.dev2", shape = "box"]
"[root] coder_script.script1 (expand)" [label = "coder_script.script1", shape = "box"]
"[root] coder_script.script2 (expand)" [label = "coder_script.script2", shape = "box"]
"[root] coder_script.script3 (expand)" [label = "coder_script.script3", shape = "box"]
"[root] null_resource.dev1 (expand)" [label = "null_resource.dev1", shape = "box"]
"[root] null_resource.dev2 (expand)" [label = "null_resource.dev2", shape = "box"]
"[root] provider[\"registry.terraform.io/coder/coder\"]" [label = "provider[\"registry.terraform.io/coder/coder\"]", shape = "diamond"]
"[root] provider[\"registry.terraform.io/hashicorp/null\"]" [label = "provider[\"registry.terraform.io/hashicorp/null\"]", shape = "diamond"]
"[root] coder_agent.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_agent.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_script.script1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_script.script2 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_script.script3 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] null_resource.dev2 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_script.script1 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_script.script2 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_script.script3 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev1 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev2 (expand)"
"[root] root" -> "[root] provider[\"registry.terraform.io/coder/coder\"] (close)"
"[root] root" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)"
}
}

View File

@ -0,0 +1,542 @@
{
"format_version": "1.2",
"terraform_version": "1.8.4",
"planned_values": {
"root_module": {
"resources": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [],
"metadata": [],
"token": true
}
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [],
"metadata": [],
"token": true
}
},
{
"address": "coder_script.script1",
"mode": "managed",
"type": "coder_script",
"name": "script1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"cron": null,
"display_name": "Foobar Script 1",
"icon": null,
"log_path": null,
"run_on_start": true,
"run_on_stop": false,
"script": "echo foobar 1",
"start_blocks_login": false,
"timeout": 0
},
"sensitive_values": {}
},
{
"address": "coder_script.script2",
"mode": "managed",
"type": "coder_script",
"name": "script2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"cron": null,
"display_name": "Foobar Script 2",
"icon": null,
"log_path": null,
"run_on_start": true,
"run_on_stop": false,
"script": "echo foobar 2",
"start_blocks_login": false,
"timeout": 0
},
"sensitive_values": {}
},
{
"address": "coder_script.script3",
"mode": "managed",
"type": "coder_script",
"name": "script3",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"cron": null,
"display_name": "Foobar Script 3",
"icon": null,
"log_path": null,
"run_on_start": true,
"run_on_stop": false,
"script": "echo foobar 3",
"start_blocks_login": false,
"timeout": 0
},
"sensitive_values": {}
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"triggers": null
},
"sensitive_values": {}
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"triggers": null
},
"sensitive_values": {}
}
]
}
},
"resource_changes": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"after_unknown": {
"display_apps": true,
"id": true,
"init_script": true,
"metadata": [],
"token": true
},
"before_sensitive": false,
"after_sensitive": {
"display_apps": [],
"metadata": [],
"token": true
}
}
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"env": null,
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"troubleshooting_url": null
},
"after_unknown": {
"display_apps": true,
"id": true,
"init_script": true,
"metadata": [],
"token": true
},
"before_sensitive": false,
"after_sensitive": {
"display_apps": [],
"metadata": [],
"token": true
}
}
},
{
"address": "coder_script.script1",
"mode": "managed",
"type": "coder_script",
"name": "script1",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"cron": null,
"display_name": "Foobar Script 1",
"icon": null,
"log_path": null,
"run_on_start": true,
"run_on_stop": false,
"script": "echo foobar 1",
"start_blocks_login": false,
"timeout": 0
},
"after_unknown": {
"agent_id": true,
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
},
{
"address": "coder_script.script2",
"mode": "managed",
"type": "coder_script",
"name": "script2",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"cron": null,
"display_name": "Foobar Script 2",
"icon": null,
"log_path": null,
"run_on_start": true,
"run_on_stop": false,
"script": "echo foobar 2",
"start_blocks_login": false,
"timeout": 0
},
"after_unknown": {
"agent_id": true,
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
},
{
"address": "coder_script.script3",
"mode": "managed",
"type": "coder_script",
"name": "script3",
"provider_name": "registry.terraform.io/coder/coder",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"cron": null,
"display_name": "Foobar Script 3",
"icon": null,
"log_path": null,
"run_on_start": true,
"run_on_stop": false,
"script": "echo foobar 3",
"start_blocks_login": false,
"timeout": 0
},
"after_unknown": {
"agent_id": true,
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_name": "registry.terraform.io/hashicorp/null",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"triggers": null
},
"after_unknown": {
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_name": "registry.terraform.io/hashicorp/null",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"triggers": null
},
"after_unknown": {
"id": true
},
"before_sensitive": false,
"after_sensitive": {}
}
}
],
"configuration": {
"provider_config": {
"coder": {
"name": "coder",
"full_name": "registry.terraform.io/coder/coder",
"version_constraint": "0.22.0"
},
"null": {
"name": "null",
"full_name": "registry.terraform.io/hashicorp/null"
}
},
"root_module": {
"resources": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_config_key": "coder",
"expressions": {
"arch": {
"constant_value": "amd64"
},
"os": {
"constant_value": "linux"
}
},
"schema_version": 0
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_config_key": "coder",
"expressions": {
"arch": {
"constant_value": "amd64"
},
"os": {
"constant_value": "linux"
}
},
"schema_version": 0
},
{
"address": "coder_script.script1",
"mode": "managed",
"type": "coder_script",
"name": "script1",
"provider_config_key": "coder",
"expressions": {
"agent_id": {
"references": [
"coder_agent.dev1.id",
"coder_agent.dev1"
]
},
"display_name": {
"constant_value": "Foobar Script 1"
},
"run_on_start": {
"constant_value": true
},
"script": {
"constant_value": "echo foobar 1"
}
},
"schema_version": 0
},
{
"address": "coder_script.script2",
"mode": "managed",
"type": "coder_script",
"name": "script2",
"provider_config_key": "coder",
"expressions": {
"agent_id": {
"references": [
"coder_agent.dev1.id",
"coder_agent.dev1"
]
},
"display_name": {
"constant_value": "Foobar Script 2"
},
"run_on_start": {
"constant_value": true
},
"script": {
"constant_value": "echo foobar 2"
}
},
"schema_version": 0
},
{
"address": "coder_script.script3",
"mode": "managed",
"type": "coder_script",
"name": "script3",
"provider_config_key": "coder",
"expressions": {
"agent_id": {
"references": [
"coder_agent.dev2.id",
"coder_agent.dev2"
]
},
"display_name": {
"constant_value": "Foobar Script 3"
},
"run_on_start": {
"constant_value": true
},
"script": {
"constant_value": "echo foobar 3"
}
},
"schema_version": 0
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_config_key": "null",
"schema_version": 0,
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_config_key": "null",
"schema_version": 0,
"depends_on": [
"coder_agent.dev2"
]
}
]
}
},
"relevant_attributes": [
{
"resource": "coder_agent.dev2",
"attribute": [
"id"
]
},
{
"resource": "coder_agent.dev1",
"attribute": [
"id"
]
}
],
"timestamp": "2024-07-03T10:58:35Z",
"applyable": true,
"complete": true,
"errored": false
}

View File

@ -0,0 +1,31 @@
digraph {
compound = "true"
newrank = "true"
subgraph "root" {
"[root] coder_agent.dev1 (expand)" [label = "coder_agent.dev1", shape = "box"]
"[root] coder_agent.dev2 (expand)" [label = "coder_agent.dev2", shape = "box"]
"[root] coder_script.script1 (expand)" [label = "coder_script.script1", shape = "box"]
"[root] coder_script.script2 (expand)" [label = "coder_script.script2", shape = "box"]
"[root] coder_script.script3 (expand)" [label = "coder_script.script3", shape = "box"]
"[root] null_resource.dev1 (expand)" [label = "null_resource.dev1", shape = "box"]
"[root] null_resource.dev2 (expand)" [label = "null_resource.dev2", shape = "box"]
"[root] provider[\"registry.terraform.io/coder/coder\"]" [label = "provider[\"registry.terraform.io/coder/coder\"]", shape = "diamond"]
"[root] provider[\"registry.terraform.io/hashicorp/null\"]" [label = "provider[\"registry.terraform.io/hashicorp/null\"]", shape = "diamond"]
"[root] coder_agent.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_agent.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] coder_script.script1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_script.script2 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] coder_script.script3 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] coder_agent.dev1 (expand)"
"[root] null_resource.dev1 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] null_resource.dev2 (expand)" -> "[root] coder_agent.dev2 (expand)"
"[root] null_resource.dev2 (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_script.script1 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_script.script2 (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_script.script3 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev1 (expand)"
"[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)" -> "[root] null_resource.dev2 (expand)"
"[root] root" -> "[root] provider[\"registry.terraform.io/coder/coder\"] (close)"
"[root] root" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"] (close)"
}
}

View File

@ -0,0 +1,207 @@
{
"format_version": "1.0",
"terraform_version": "1.8.4",
"values": {
"root_module": {
"resources": [
{
"address": "coder_agent.dev1",
"mode": "managed",
"type": "coder_agent",
"name": "dev1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"display_apps": [
{
"port_forwarding_helper": true,
"ssh_helper": true,
"vscode": true,
"vscode_insiders": false,
"web_terminal": true
}
],
"env": null,
"id": "26676b01-8c32-4fe2-af05-8409004c2132",
"init_script": "",
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"token": "4d98aa2e-1b27-4a22-9658-0ccde329415c",
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [
{}
],
"metadata": [],
"token": true
}
},
{
"address": "coder_agent.dev2",
"mode": "managed",
"type": "coder_agent",
"name": "dev2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"arch": "amd64",
"auth": "token",
"connection_timeout": 120,
"dir": null,
"display_apps": [
{
"port_forwarding_helper": true,
"ssh_helper": true,
"vscode": true,
"vscode_insiders": false,
"web_terminal": true
}
],
"env": null,
"id": "ad10d725-ec7d-45f4-8b83-d67f94878f3c",
"init_script": "",
"login_before_ready": true,
"metadata": [],
"motd_file": null,
"order": null,
"os": "linux",
"shutdown_script": null,
"shutdown_script_timeout": 300,
"startup_script": null,
"startup_script_behavior": null,
"startup_script_timeout": 300,
"token": "de109669-b8e5-479d-82d0-2d0471f9a2cf",
"troubleshooting_url": null
},
"sensitive_values": {
"display_apps": [
{}
],
"metadata": [],
"token": true
}
},
{
"address": "coder_script.script1",
"mode": "managed",
"type": "coder_script",
"name": "script1",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"agent_id": "26676b01-8c32-4fe2-af05-8409004c2132",
"cron": null,
"display_name": "Foobar Script 1",
"icon": null,
"id": "3083dd1d-67a0-46eb-a8c1-8d3d83a411c1",
"log_path": null,
"run_on_start": true,
"run_on_stop": false,
"script": "echo foobar 1",
"start_blocks_login": false,
"timeout": 0
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "coder_script.script2",
"mode": "managed",
"type": "coder_script",
"name": "script2",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"agent_id": "26676b01-8c32-4fe2-af05-8409004c2132",
"cron": null,
"display_name": "Foobar Script 2",
"icon": null,
"id": "ddb41617-27e2-43c8-b735-99d8567f46ca",
"log_path": null,
"run_on_start": true,
"run_on_stop": false,
"script": "echo foobar 2",
"start_blocks_login": false,
"timeout": 0
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "coder_script.script3",
"mode": "managed",
"type": "coder_script",
"name": "script3",
"provider_name": "registry.terraform.io/coder/coder",
"schema_version": 0,
"values": {
"agent_id": "ad10d725-ec7d-45f4-8b83-d67f94878f3c",
"cron": null,
"display_name": "Foobar Script 3",
"icon": null,
"id": "d793afab-f40a-4ae2-99d5-eae9e3d0d45f",
"log_path": null,
"run_on_start": true,
"run_on_stop": false,
"script": "echo foobar 3",
"start_blocks_login": false,
"timeout": 0
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev2"
]
},
{
"address": "null_resource.dev1",
"mode": "managed",
"type": "null_resource",
"name": "dev1",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"id": "4183830202442917773",
"triggers": null
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev1"
]
},
{
"address": "null_resource.dev2",
"mode": "managed",
"type": "null_resource",
"name": "dev2",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"id": "6920808379078063017",
"triggers": null
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev2"
]
}
]
}
}
}