Skip to content

Commit

Permalink
Merge pull request #23055 from hashicorp/s3-use-pathname-parameter
Browse files Browse the repository at this point in the history
provider: Adds `s3_use_path_style` and deprecates `s3_force_path_style`
  • Loading branch information
gdavison authored Feb 9, 2022
2 parents 1cd3073 + afa9420 commit eb9db5d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/23055.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
provider: Adds `s3_use_path_style` parameter and deprecates `s3_force_path_style`.
```
4 changes: 2 additions & 2 deletions internal/conns/conns.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ type Config struct {
MaxRetries int
Profile string
Region string
S3ForcePathStyle bool
S3UsePathStyle bool
SecretKey string
SharedConfigFile string
SharedCredentialsFile string
Expand Down Expand Up @@ -1576,7 +1576,7 @@ func (c *Config) Client() (interface{}, error) {
// Services that require multiple client configurations
s3Config := &aws.Config{
Endpoint: aws.String(c.Endpoints[S3]),
S3ForcePathStyle: aws.Bool(c.S3ForcePathStyle),
S3ForcePathStyle: aws.Bool(c.S3UsePathStyle),
}

client.S3Conn = s3.New(sess.Copy(s3Config))
Expand Down
18 changes: 14 additions & 4 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,23 @@ func Provider() *schema.Provider {
InputDefault: "us-east-1", // lintignore:AWSAT003
},
"s3_force_path_style": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Deprecated: "Use s3_use_path_style instead.",
Description: "Set this to true to enable the request to use path-style addressing,\n" +
"i.e., https://s3.amazonaws.com/BUCKET/KEY. By default, the S3 client will\n" +
"use virtual hosted bucket addressing when possible\n" +
"(https://BUCKET.s3.amazonaws.com/KEY). Specific to the Amazon S3 service.",
},
"s3_use_path_style": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Set this to true to force the request to use path-style addressing,\n" +
"i.e., http://s3.amazonaws.com/BUCKET/KEY. By default, the S3 client will\n" +
Description: "Set this to true to enable the request to use path-style addressing,\n" +
"i.e., https://s3.amazonaws.com/BUCKET/KEY. By default, the S3 client will\n" +
"use virtual hosted bucket addressing when possible\n" +
"(http://BUCKET.s3.amazonaws.com/KEY). Specific to the Amazon S3 service.",
"(https://BUCKET.s3.amazonaws.com/KEY). Specific to the Amazon S3 service.",
},
"secret_key": {
Type: schema.TypeString,
Expand Down Expand Up @@ -1879,7 +1889,7 @@ func providerConfigure(d *schema.ResourceData, terraformVersion string) (interfa
MaxRetries: d.Get("max_retries").(int),
Profile: d.Get("profile").(string),
Region: d.Get("region").(string),
S3ForcePathStyle: d.Get("s3_force_path_style").(bool),
S3UsePathStyle: d.Get("s3_use_path_style").(bool) || d.Get("s3_force_path_style").(bool),
SecretKey: d.Get("secret_key").(string),
SharedConfigFile: d.Get("shared_config_file").(string),
SharedCredentialsFile: d.Get("shared_credentials_file").(string),
Expand Down
1 change: 1 addition & 0 deletions website/docs/guides/version-4-upgrade.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Version 4.0.0 adds these new provider arguments:

* `ec2_metadata_service_endpoint` - Address of the EC2 metadata service (IMDS) endpoint to use. Can also be set with the `AWS_EC2_METADATA_SERVICE_ENDPOINT` environment variable.
* `ec2_metadata_service_endpoint_mode` - Mode to use in communicating with the metadata service. Valid values are `IPv4` and `IPv6`. Can also be set with the `AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE` environment variable.
* `s3_use_path_style` - Replaces `s3_force_path_style`, which has been deprecated in Terraform AWS Provider v4.0.0 and support will be removed in a future version.
* `use_dualstack_endpoint` - Force the provider to resolve endpoints with DualStack capability. Can also be set with the `AWS_USE_DUALSTACK_ENDPOINT` environment variable or in a shared config file (`use_dualstack_endpoint`).
* `use_fips_endpoint` - Force the provider to resolve endpoints with FIPS capability. Can also be set with the `AWS_USE_FIPS_ENDPOINT` environment variable or in a shared config file (`use_fips_endpoint`).

Expand Down
3 changes: 2 additions & 1 deletion website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ In addition to [generic `provider` arguments](https://www.terraform.io/docs/conf
* `max_retries` - (Optional) Maximum number of times an API call is retried when AWS throttles requests or you experience transient failures. The delay between the subsequent API calls increases exponentially. If omitted, the default value is `25`.
* `profile` - (Optional) AWS profile name as set in the shared credentials file.
* `region` - (Optional) AWS region. Can also be set with the `AWS_DEFAULT_REGION` environment variables, or via a shared credentials file if `profile` is used.
* `s3_force_path_style` - (Optional) Whether to force the request to use path-style addressing, i.e., `http://s3.amazonaws.com/BUCKET/KEY`. By default, the S3 client will use virtual hosted bucket addressing, `http://BUCKET.s3.amazonaws.com/KEY`, when possible. Specific to the Amazon S3 service.
* `s3_force_path_style` - (Optional, **Deprecated**) Whether to enable the request to use path-style addressing, i.e., `https://s3.amazonaws.com/BUCKET/KEY`. By default, the S3 client will use virtual hosted bucket addressing, `https://BUCKET.s3.amazonaws.com/KEY`, when possible. Specific to the Amazon S3 service.
* `s3_use_path_style` - (Optional) Whether to enable the request to use path-style addressing, i.e., `https://s3.amazonaws.com/BUCKET/KEY`. By default, the S3 client will use virtual hosted bucket addressing, `https://BUCKET.s3.amazonaws.com/KEY`, when possible. Specific to the Amazon S3 service.
* `secret_key` - (Optional) AWS secret key. Can also be set with the `AWS_SECRET_ACCESS_KEY` environment variable, or via a shared credentials file if `profile` is used. See also `access_key`.
* `shared_config_file` = (Optional) Path to the AWS shared config file. If not set, the default is `~/.aws/config`. Can also be set with the `AWS_CONFIG_FILE` environment variable.
* `shared_credentials_file` = (Optional) Path to the shared credentials file. If not set and a profile is used, the default value is `~/.aws/credentials`. Can also be set with the `AWS_SHARED_CREDENTIALS_FILE` environment variable.
Expand Down

0 comments on commit eb9db5d

Please sign in to comment.