Merge pull request #18642 from hashicorp/f-remote-backend

backend/remote: do not use the TFE_TOKEN env variable
This commit is contained in:
Sander van Harmelen 2018-08-10 20:32:07 +02:00 committed by GitHub
commit bb37637a13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View File

@ -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" +

View File

@ -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.