Merge pull request #18642 from hashicorp/f-remote-backend
backend/remote: do not use the TFE_TOKEN env variable
This commit is contained in:
commit
bb37637a13
|
@ -91,7 +91,6 @@ func New(services *disco.Disco) *Remote {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: schemaDescriptions["token"],
|
Description: schemaDescriptions["token"],
|
||||||
DefaultFunc: schema.EnvDefaultFunc("TFE_TOKEN", ""),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"workspaces": &schema.Schema{
|
"workspaces": &schema.Schema{
|
||||||
|
@ -260,9 +259,15 @@ func (b *Remote) State(workspace string) (state.State, error) {
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
options := tfe.WorkspaceCreateOptions{
|
options := tfe.WorkspaceCreateOptions{
|
||||||
Name: tfe.String(workspace),
|
Name: tfe.String(workspace),
|
||||||
TerraformVersion: tfe.String(version.Version),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)
|
_, err = b.client.Workspaces.Create(context.Background(), b.organization, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error creating workspace %s: %v", workspace, err)
|
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{
|
var schemaDescriptions = map[string]string{
|
||||||
"hostname": "The remote backend hostname to connect to (defaults to app.terraform.io).",
|
"hostname": "The remote backend hostname to connect to (defaults to app.terraform.io).",
|
||||||
"organization": "The name of the organization containing the targeted workspace(s).",
|
"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" +
|
"token": "The token used to authenticate with the remote backend. If credentials for the\n" +
|
||||||
"or credentials for the host are configured in the CLI Config File, then this\n" +
|
"host are configured in the CLI Config File, then those will be used instead.",
|
||||||
"this will override any saved value for this.",
|
|
||||||
"workspaces": "Workspaces contains arguments used to filter down to a set of workspaces\n" +
|
"workspaces": "Workspaces contains arguments used to filter down to a set of workspaces\n" +
|
||||||
"to work on.",
|
"to work on.",
|
||||||
"name": "A workspace name used to map the default workspace to a named remote workspace.\n" +
|
"name": "A workspace name used to map the default workspace to a named remote workspace.\n" +
|
||||||
|
|
|
@ -65,7 +65,6 @@ terraform {
|
||||||
backend "remote" {
|
backend "remote" {
|
||||||
hostname = "app.terraform.io"
|
hostname = "app.terraform.io"
|
||||||
organization = "company"
|
organization = "company"
|
||||||
token = ""
|
|
||||||
|
|
||||||
workspaces {
|
workspaces {
|
||||||
name = "workspace"
|
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
|
## Example Reference
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
|
@ -98,13 +94,13 @@ data "terraform_remote_state" "foo" {
|
||||||
|
|
||||||
The following configuration options are supported:
|
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.
|
to app.terraform.io.
|
||||||
* `organization` - (Required) The name of the organization containing the
|
* `organization` - (Required) The name of the organization containing the
|
||||||
targeted workspace(s).
|
targeted workspace(s).
|
||||||
* `token` - (Optional) The token used to authenticate with the remote backend.
|
* `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
|
We recommend omitting the token which can be set as `credentials` in the
|
||||||
Config File, then this this will override any saved value for this.
|
[CLI config file](/docs/commands/cli-config.html#credentials).
|
||||||
* `workspaces` - (Required) Workspaces contains arguments used to filter down
|
* `workspaces` - (Required) Workspaces contains arguments used to filter down
|
||||||
to a set of workspaces to work on. Parameters defined below.
|
to a set of workspaces to work on. Parameters defined below.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue