coder / coder/terraform-provider-coder

`coder_agent.metadata` includes stderr

Open
#208 0 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
Go
Stars
60
Forks
27
Avg merge
1d 21h
Merged PRs (30d)
2

Description

This is more of an unfortunate circumstance, but one where I don't think there is a workaround.

### Terraform Version

```
Terraform v1.7.5
+ provider registry.terraform.io/coder/coder v0.20.1
```

### Affected Resource(s)

- `coder_agent`

### Terraform Configuration Files

```hcl
resource "coder_agent" "this" {
os = "linux"
arch = "amd64"
dir = "/home/coder"

metadata {
display_name = "CPU Usage"
key = "cpu_usage"
script = "coder stat cpu"
interval = 10
timeout = 1
order = 1
}

metadata {
display_name = "RAM Usage"
key = "ram_usage"
script = "coder stat mem"
interval = 10
timeout = 1
order = 2
}

metadata {
display_name = "Disk Usage"
key = "disk_usage"
script = "coder stat disk"
interval = 10
timeout = 1
order = 3
}

metadata {
display_name = "Uptime"
key = "uptime"
script = "uptime -p"
interval = 10
timeout = 1
order = 4
}

order = 1
}
```

### Expected Behavior

The metadata contains the expected output.

### Actual Behavior

If the `~/.bashrc` prints a message, for example an error message to `stderr`, that message is included in the metadata. This is unexpected because it isn't strictly expected IMO that `~/.bashrc` is even sourced for the script invokation.

As far as I can tell there's no workaround other than to fix the `~/.bashrc`, which is unfortunate for administrators of the Coder template who have no control over the user's rc-file.

![image](https://github.com/coder/terraform-provider-coder/assets/1318438/5ae8d724-99da-43d4-835d-ce53a11dce59)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.