Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

backend (s3/azure): Source config from environment variables #20428

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/remote-state/azure/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions backend/remote-state/s3/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions website/docs/backends/types/azurerm.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
7 changes: 3 additions & 4 deletions website/docs/backends/types/s3.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the wording of how this is sourced to match the other values in this document.

* `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.
Expand Down