From 9b27db6feae60b94867bf83567a3391cb01c4070 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Mon, 11 Jan 2016 14:28:52 +0100 Subject: [PATCH] Add the option to specify a custom (AWS compatible) S3 endpoint Same fix/option as I added in Vault not too long ago: https://github.com/hashicorp/vault/pull/750 --- state/remote/s3.go | 6 ++++++ .../source/docs/commands/remote-config.html.markdown | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/state/remote/s3.go b/state/remote/s3.go index 28bb7b5f9..84663b0a1 100644 --- a/state/remote/s3.go +++ b/state/remote/s3.go @@ -29,6 +29,11 @@ func s3Factory(conf map[string]string) (Client, error) { return nil, fmt.Errorf("missing 'key' configuration") } + endpoint, ok := conf["endpoint"] + if !ok { + endpoint = os.Getenv("AWS_S3_ENDPOINT") + } + regionName, ok := conf["region"] if !ok { regionName = os.Getenv("AWS_DEFAULT_REGION") @@ -77,6 +82,7 @@ func s3Factory(conf map[string]string) (Client, error) { awsConfig := &aws.Config{ Credentials: credentialsProvider, + Endpoint: aws.String(endpoint), Region: aws.String(regionName), HTTPClient: cleanhttp.DefaultClient(), } diff --git a/website/source/docs/commands/remote-config.html.markdown b/website/source/docs/commands/remote-config.html.markdown index e7025d9d5..9d2ea25f2 100644 --- a/website/source/docs/commands/remote-config.html.markdown +++ b/website/source/docs/commands/remote-config.html.markdown @@ -69,11 +69,11 @@ The following backends are supported: * S3 - Stores the state as a given key in a given bucket on Amazon S3. Requires the `bucket` and `key` variables. Supports and honors the standard - AWS environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` - and `AWS_DEFAULT_REGION`. These can optionally be provided as parameters - in the `access_key`, `secret_key` and `region` variables - respectively, but passing credentials this way is not recommended since they - will be included in cleartext inside the persisted state. + AWS environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, + `AWS_S3_ENDPOINT` and `AWS_DEFAULT_REGION`. These can optionally be provided + as parameters in the `access_key`, `secret_key`, `endpoint` and `region` + variables respectively, but passing credentials this way is not recommended + since they will be included in cleartext inside the persisted state. Other supported parameters include: * `bucket` - the name of the S3 bucket * `key` - path where to place/look for state file inside the bucket