diff --git a/backend/remote-state/azure/backend.go b/backend/remote-state/azure/backend.go index a2135c44196a..ebb5247e922f 100644 --- a/backend/remote-state/azure/backend.go +++ b/backend/remote-state/azure/backend.go @@ -16,18 +16,21 @@ func New() backend.Backend { Type: schema.TypeString, Required: true, Description: "The name of the storage account.", + DefaultFunc: schema.EnvDefaultFunc("ARM_STORAGE_ACCOUNT_NAME", nil), }, "container_name": { Type: schema.TypeString, Required: true, Description: "The container name.", + DefaultFunc: schema.EnvDefaultFunc("ARM_STORAGE_CONTAINER_NAME", nil), }, "key": { Type: schema.TypeString, Required: true, Description: "The blob key.", + DefaultFunc: schema.EnvDefaultFunc("ARM_STORAGE_BLOB_KEY", nil), }, "environment": { diff --git a/backend/remote-state/s3/backend.go b/backend/remote-state/s3/backend.go index ae9bf1fbc9b2..2bf1d97a102e 100644 --- a/backend/remote-state/s3/backend.go +++ b/backend/remote-state/s3/backend.go @@ -21,12 +21,14 @@ func New() backend.Backend { Type: schema.TypeString, Required: true, Description: "The name of the S3 bucket", + DefaultFunc: schema.EnvDefaultFunc("AWS_S3_BUCKET", nil), }, "key": { Type: schema.TypeString, Required: true, Description: "The path to the state file inside the bucket", + DefaultFunc: schema.EnvDefaultFunc("AWS_S3_KEY", nil), ValidateFunc: func(v interface{}, s string) ([]string, []error) { // s3 will strip leading slashes from an object, so while this will // technically be accepted by s3, it will break our workspace hierarchy. diff --git a/website/docs/backends/types/azurerm.html.md b/website/docs/backends/types/azurerm.html.md index 76caa26b7a5c..48bc8724cd1c 100644 --- a/website/docs/backends/types/azurerm.html.md +++ b/website/docs/backends/types/azurerm.html.md @@ -145,11 +145,11 @@ data "terraform_remote_state" "foo" { The following configuration options are supported: -* `storage_account_name` - (Required) The Name of [the Storage Account](https://www.terraform.io/docs/providers/azurerm/r/storage_account.html). +* `storage_account_name` - (Required) The Name of [the Storage Account](https://www.terraform.io/docs/providers/azurerm/r/storage_account.html). This can also be sourced from the `ARM_STORAGE_ACCOUNT_NAME` environment variable. -* `container_name` - (Required) The Name of [the Storage Container](https://www.terraform.io/docs/providers/azurerm/r/storage_container.html) within the Storage Account. +* `container_name` - (Required) The Name of [the Storage Container](https://www.terraform.io/docs/providers/azurerm/r/storage_container.html) within the Storage Account. This can also be sourced from the `ARM_STORAGE_CONTAINER_NAME` environment variable. -* `key` - (Required) The name of the Blob used to retrieve/store Terraform's State file inside the Storage Container. +* `key` - (Required) The name of the Blob used to retrieve/store Terraform's State file inside the Storage Container. When using workspaces, the workspace state blob key will be prefixed with this value. This can also be sourced from the `ARM_STORAGE_BLOB_KEY` environment variable. * `environment` - (Optional) The Azure Environment which should be used. This can also be sourced from the `ARM_ENVIRONMENT` environment variable. Possible values are `public`, `china`, `german`, `stack` and `usgovernment`. Defaults to `public`. diff --git a/website/docs/backends/types/s3.html.md b/website/docs/backends/types/s3.html.md index 5868b10f9aec..4e7a06407d40 100644 --- a/website/docs/backends/types/s3.html.md +++ b/website/docs/backends/types/s3.html.md @@ -136,8 +136,8 @@ data.terraform_remote_state.network: The following configuration options or environment variables are supported: - * `bucket` - (Required) The name of the S3 bucket. - * `key` - (Required) The path to the state file inside the bucket. When using + * `bucket` / `AWS_S3_BUCKET` - (Required) The name of the S3 bucket. + * `key` / `AWS_S3_KEY` - (Required) The path to the state file inside the bucket. When using a non-default [workspace](/docs/state/workspaces.html), the state path will be `/workspace_key_prefix/workspace_name/key` * `region` / `AWS_DEFAULT_REGION` - (Optional) The region of the S3 @@ -163,8 +163,7 @@ The following configuration options or environment variables are supported: * `shared_credentials_file` - (Optional) This is the path to the shared credentials file. If this is not set and a profile is specified, `~/.aws/credentials` will be used. - * `token` - (Optional) Use this to set an MFA token. It can also be - sourced from the `AWS_SESSION_TOKEN` environment variable. + * `token` / `AWS_SESSION_TOKEN` - (Optional) Use this to set an MFA token. * `role_arn` - (Optional) The role to be assumed. * `assume_role_policy` - (Optional) The permissions applied when assuming a role. * `external_id` - (Optional) The external ID to use when assuming the role.