fix: Use explicit resource order when assocating agents (#2219)

This cleans up agent association code to explicitly map a single
agent to a single resource. This will fix #1884, and unblock
a prospect from beginning a POC.
This commit is contained in:
Kyle Carberry
2022-06-10 15:47:36 +00:00
committed by GitHub
parent 6bee180bb3
commit f9290b016e
21 changed files with 729 additions and 222 deletions
+4 -2
View File
@@ -3,13 +3,15 @@ digraph {
newrank = "true"
subgraph "root" {
"[root] coder_agent.dev (expand)" [label = "coder_agent.dev", shape = "box"]
"[root] module.module.data.null_data_source.script (expand)" [label = "module.module.data.null_data_source.script", shape = "box"]
"[root] module.module.null_resource.example (expand)" [label = "module.module.null_resource.example", 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.dev (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] module.module (close)" -> "[root] module.module.null_resource.example (expand)"
"[root] module.module.null_resource.example (expand)" -> "[root] module.module.var.script (expand)"
"[root] module.module.null_resource.example (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] module.module.data.null_data_source.script (expand)" -> "[root] module.module.var.script (expand)"
"[root] module.module.data.null_data_source.script (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] module.module.null_resource.example (expand)" -> "[root] module.module.data.null_data_source.script (expand)"
"[root] module.module.var.script (expand)" -> "[root] coder_agent.dev (expand)"
"[root] module.module.var.script (expand)" -> "[root] module.module (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_agent.dev (expand)"
+72 -2
View File
@@ -25,6 +25,21 @@
"child_modules": [
{
"resources": [
{
"address": "module.module.data.null_data_source.script",
"mode": "data",
"type": "null_data_source",
"name": "script",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"inputs": {}
},
"sensitive_values": {
"inputs": {},
"outputs": {}
}
},
{
"address": "module.module.null_resource.example",
"mode": "managed",
@@ -72,6 +87,38 @@
"after_sensitive": {}
}
},
{
"address": "module.module.data.null_data_source.script",
"module_address": "module.module",
"mode": "data",
"type": "null_data_source",
"name": "script",
"provider_name": "registry.terraform.io/hashicorp/null",
"change": {
"actions": [
"read"
],
"before": null,
"after": {
"inputs": {}
},
"after_unknown": {
"has_computed_default": true,
"id": true,
"inputs": {
"script": true
},
"outputs": true,
"random": true
},
"before_sensitive": false,
"after_sensitive": {
"inputs": {},
"outputs": {}
}
},
"action_reason": "read_because_config_unknown"
},
{
"address": "module.module.null_resource.example",
"module_address": "module.module",
@@ -148,8 +195,23 @@
"provider_config_key": "module.module:null",
"schema_version": 0,
"depends_on": [
"var.script"
"data.null_data_source.script"
]
},
{
"address": "data.null_data_source.script",
"mode": "data",
"type": "null_data_source",
"name": "script",
"provider_config_key": "module.module:null",
"expressions": {
"inputs": {
"references": [
"var.script"
]
}
},
"schema_version": 0
}
],
"variables": {
@@ -159,5 +221,13 @@
}
}
}
}
},
"relevant_attributes": [
{
"resource": "coder_agent.dev",
"attribute": [
"init_script"
]
}
]
}
+4 -2
View File
@@ -3,13 +3,15 @@ digraph {
newrank = "true"
subgraph "root" {
"[root] coder_agent.dev (expand)" [label = "coder_agent.dev", shape = "box"]
"[root] module.module.data.null_data_source.script (expand)" [label = "module.module.data.null_data_source.script", shape = "box"]
"[root] module.module.null_resource.example (expand)" [label = "module.module.null_resource.example", 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.dev (expand)" -> "[root] provider[\"registry.terraform.io/coder/coder\"]"
"[root] module.module (close)" -> "[root] module.module.null_resource.example (expand)"
"[root] module.module.null_resource.example (expand)" -> "[root] module.module.var.script (expand)"
"[root] module.module.null_resource.example (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] module.module.data.null_data_source.script (expand)" -> "[root] module.module.var.script (expand)"
"[root] module.module.data.null_data_source.script (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/null\"]"
"[root] module.module.null_resource.example (expand)" -> "[root] module.module.data.null_data_source.script (expand)"
"[root] module.module.var.script (expand)" -> "[root] coder_agent.dev (expand)"
"[root] module.module.var.script (expand)" -> "[root] module.module (expand)"
"[root] provider[\"registry.terraform.io/coder/coder\"] (close)" -> "[root] coder_agent.dev (expand)"
+28 -4
View File
@@ -16,11 +16,11 @@
"auth": "token",
"dir": null,
"env": null,
"id": "0f0b7be8-9d82-4b01-b5e5-88279ae4f977",
"id": "66fed4b4-2246-4c0f-8e55-74e109ee0603",
"init_script": "",
"os": "linux",
"startup_script": null,
"token": "0144998d-4154-495a-902b-0cece2800d76"
"token": "c7f7d527-3eab-4f77-8c0f-05f543bce5c1"
},
"sensitive_values": {}
}
@@ -28,6 +28,29 @@
"child_modules": [
{
"resources": [
{
"address": "module.module.data.null_data_source.script",
"mode": "data",
"type": "null_data_source",
"name": "script",
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"has_computed_default": "default",
"id": "static",
"inputs": {
"script": ""
},
"outputs": {
"script": ""
},
"random": "2465369318401710566"
},
"sensitive_values": {
"inputs": {},
"outputs": {}
}
},
{
"address": "module.module.null_resource.example",
"mode": "managed",
@@ -36,12 +59,13 @@
"provider_name": "registry.terraform.io/hashicorp/null",
"schema_version": 0,
"values": {
"id": "4090647596312392999",
"id": "354396519773748320",
"triggers": null
},
"sensitive_values": {},
"depends_on": [
"coder_agent.dev"
"coder_agent.dev",
"module.module.data.null_data_source.script"
]
}
],
@@ -2,8 +2,14 @@ variable "script" {
type = string
}
data "null_data_source" "script" {
inputs = {
script = var.script
}
}
resource "null_resource" "example" {
depends_on = [
var.script
data.null_data_source.script
]
}