Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Manually set terraform env variable prevents template creation #1359

Closed
Assignees
spikecurtis
Labels
apiArea: HTTP API
@mafredri

Description

@mafredri

OS Information

  • OS: Linux
  • coder --version: Coder v0.5.5-devel+2d3dc43 Tue May 10 07:44:09 UTC 2022

Steps to Reproduce

  1. Set a terraform environment variable:export TF_LOG=1
  2. Runcoder server
  3. Create first template:coder templates create docker-local -d ~/src/cdr/coder/examples/docker-local

There should be no issue creating the template, or detailed hints on how to fix the problem (e.g. coder server is running with these environment variables set, please restart it without).

Actual

Template creation fails:

>Create and upload"~/src/cdr/coder/examples/docker-local"? (yes/no) yes✔ Queued [139ms]✔ Setting up [6ms]✔ Parse parameters [17ms]✘ Detecting persistent resources [420ms]template import provision for start: recv import provision: set terraform env: manual setting of env var "TF_LOG" detected

Notes

Consideringthis comment I wanted to see if I can get more information out of terraform (a naive approach). I think it's fine the value can't be changed but I would have expected this value to either propagate to terraform or for the server to either inform of a way to fix it or filter out the variable.

We could for instance filter out some incompatibleTF_ env vars here, potentially logging the exclusion as a warning:

terraformEnv:=map[string]string{}
// Required for "terraform init" to find "git" to
// clone Terraform modules.
for_,env:=rangeos.Environ() {
parts:=strings.SplitN(env,"=",2)
iflen(parts)<2 {
continue
}
terraformEnv[parts[0]]=parts[1]
}
// Only Linux reliably works with the Terraform plugin
// cache directory. It's unknown why this is.
ift.cachePath!=""&&runtime.GOOS=="linux" {
terraformEnv["TF_PLUGIN_CACHE_DIR"]=t.cachePath
}
err=terraform.SetEnv(terraformEnv)
iferr!=nil {
returnxerrors.Errorf("set terraform env: %w",err)
}

AC

Replace the terraform exec command with directly executing terraform
Test for the steps to repro this bug to validate this case is covered
Expose in the logs that the env vars are set

Metadata

Metadata

Assignees

Labels

apiArea: HTTP API

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp