From 7049d973a97f9e77fba20d9037063e0fb5fb0cb1 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Thu, 9 Aug 2018 13:15:33 +0200 Subject: [PATCH] Do not use the TFE_TOKEN env variable Instead promote the use of shared credentials using the CLI Config File --- backend/remote/backend.go | 16 ++++++++++------ website/docs/backends/types/remote.html.md | 10 +++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/backend/remote/backend.go b/backend/remote/backend.go index 5be38464b..59ba777f2 100644 --- a/backend/remote/backend.go +++ b/backend/remote/backend.go @@ -91,7 +91,6 @@ func New(services *disco.Disco) *Remote { Type: schema.TypeString, Optional: true, Description: schemaDescriptions["token"], - DefaultFunc: schema.EnvDefaultFunc("TFE_TOKEN", ""), }, "workspaces": &schema.Schema{ @@ -260,9 +259,15 @@ func (b *Remote) State(workspace string) (state.State, error) { if !exists { options := tfe.WorkspaceCreateOptions{ - Name: tfe.String(workspace), - TerraformVersion: tfe.String(version.Version), + Name: tfe.String(workspace), } + + // We only set the Terraform Version for the new workspace if this is + // a release candidate or a final release. + if version.Prerelease == "" || strings.HasPrefix(version.Prerelease, "rc") { + options.TerraformVersion = tfe.String(version.String()) + } + _, err = b.client.Workspaces.Create(context.Background(), b.organization, options) if err != nil { return nil, fmt.Errorf("Error creating workspace %s: %v", workspace, err) @@ -434,9 +439,8 @@ persists please open a support ticket to get help resolving the problem. var schemaDescriptions = map[string]string{ "hostname": "The remote backend hostname to connect to (defaults to app.terraform.io).", "organization": "The name of the organization containing the targeted workspace(s).", - "token": "The token used to authenticate with the remote backend. If TFE_TOKEN is set\n" + - "or credentials for the host are configured in the CLI Config File, then this\n" + - "this will override any saved value for this.", + "token": "The token used to authenticate with the remote backend. If credentials for the\n" + + "host are configured in the CLI Config File, then those will be used instead.", "workspaces": "Workspaces contains arguments used to filter down to a set of workspaces\n" + "to work on.", "name": "A workspace name used to map the default workspace to a named remote workspace.\n" + diff --git a/website/docs/backends/types/remote.html.md b/website/docs/backends/types/remote.html.md index 5429c2d62..ea011a747 100644 --- a/website/docs/backends/types/remote.html.md +++ b/website/docs/backends/types/remote.html.md @@ -65,7 +65,6 @@ terraform { backend "remote" { hostname = "app.terraform.io" organization = "company" - token = "" workspaces { name = "workspace" @@ -75,9 +74,6 @@ terraform { } ``` -We recommend omitting the token which can be provided as an environment -variable or set as [credentials in the CLI Config File](/docs/commands/cli-config.html#credentials). - ## Example Reference ```hcl @@ -98,13 +94,13 @@ data "terraform_remote_state" "foo" { The following configuration options are supported: -* `hostname` - (Optional) The remote backend hostname to connect to. Default +* `hostname` - (Optional) The remote backend hostname to connect to. Defaults to app.terraform.io. * `organization` - (Required) The name of the organization containing the targeted workspace(s). * `token` - (Optional) The token used to authenticate with the remote backend. - If `TFE_TOKEN` is set or credentials for the host are configured in the CLI - Config File, then this this will override any saved value for this. + We recommend omitting the token which can be set as `credentials` in the + [CLI config file](/docs/commands/cli-config.html#credentials). * `workspaces` - (Required) Workspaces contains arguments used to filter down to a set of workspaces to work on. Parameters defined below.