Skip to content

Commit

Permalink
fix: Move force_path_style to use_path_style
Browse files Browse the repository at this point in the history
As per the documentation linked below the force_path_style option is now
deprecated and should be changed to use_path_style.

https://developer.hashicorp.com/terraform/language/backend/s3#force_path_style

It may be better to add both to allow people to migrate from one to the
other but given this is only in one place in the docs I expect there
isn't a lot of use and highlighting as a breaking change will make
future migration easier and stop being using the now deprecated option.
  • Loading branch information
lazzurs committed Oct 12, 2024
1 parent af89a98 commit a7fbe0c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ remote_state {
shared_credentials_file = "/path/to/credentials/file"
skip_metadata_api_check = true
force_path_style = true
use_path_style = true
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions remote/remote_state_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ type RemoteStateConfigS3 struct {
LockTable string `mapstructure:"lock_table"` // Deprecated in Terraform version 0.13 or newer.
DynamoDBTable string `mapstructure:"dynamodb_table"`
CredsFilename string `mapstructure:"shared_credentials_file"`
S3ForcePathStyle bool `mapstructure:"force_path_style"`
S3UsePathStyle bool `mapstructure:"use_path_style"`
AssumeRole RemoteStateConfigS3AssumeRole `mapstructure:"assume_role"`
}

Expand All @@ -131,7 +131,7 @@ func (c *ExtendedRemoteStateConfigS3) GetAwsSessionConfig() *awshelper.AwsSessio
ExternalID: c.RemoteStateConfigS3.GetExternalID(),
SessionName: c.RemoteStateConfigS3.GetSessionName(),
CredsFilename: c.RemoteStateConfigS3.CredsFilename,
S3ForcePathStyle: c.RemoteStateConfigS3.S3ForcePathStyle,
S3UsePathStyle: c.RemoteStateConfigS3.S3UsePathStyle,
DisableComputeChecksums: c.DisableAWSClientChecksums,
}
}
Expand Down
14 changes: 7 additions & 7 deletions remote/remote_state_s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func TestAwsConfigValuesEqual(t *testing.T) {
}
}

func TestAwsForcePathStyleClientSession(t *testing.T) {
func TestAwsUsePathStyleClientSession(t *testing.T) {
t.Parallel()

terragruntOptions, err := options.NewTerragruntOptionsForTest("s3_client_test")
Expand All @@ -258,12 +258,12 @@ func TestAwsForcePathStyleClientSession(t *testing.T) {
}{
{
"path-style-true",
map[string]interface{}{"force_path_style": true},
map[string]interface{}{"use_path_style": true},
true,
},
{
"path-style-false",
map[string]interface{}{"force_path_style": false},
map[string]interface{}{"use_path_style": false},
false,
},
{
Expand All @@ -287,7 +287,7 @@ func TestAwsForcePathStyleClientSession(t *testing.T) {
s3Client, err := remote.CreateS3Client(s3ConfigExtended.GetAwsSessionConfig(), terragruntOptions)
require.NoError(t, err, "Unexpected error creating client for test: %v", err)

actual := aws.BoolValue(s3Client.Config.S3ForcePathStyle)
actual := aws.BoolValue(s3Client.Config.S3UsePathStyle)
assert.Equal(t, testCase.expected, actual)
})
}
Expand All @@ -302,15 +302,15 @@ func TestAwsGetAwsSessionConfig(t *testing.T) {
}{
{
"all-values",
map[string]interface{}{"region": "foo", "endpoint": "bar", "profile": "baz", "role_arn": "arn::it", "shared_credentials_file": "my-file", "force_path_style": true},
map[string]interface{}{"region": "foo", "endpoint": "bar", "profile": "baz", "role_arn": "arn::it", "shared_credentials_file": "my-file", "use_path_style": true},
},
{
"no-values",
map[string]interface{}{},
},
{
"extra-values",
map[string]interface{}{"something": "unexpected", "region": "foo", "endpoint": "bar", "dynamodb_endpoint": "foobar", "profile": "baz", "role_arn": "arn::it", "shared_credentials_file": "my-file", "force_path_style": false},
map[string]interface{}{"something": "unexpected", "region": "foo", "endpoint": "bar", "dynamodb_endpoint": "foobar", "profile": "baz", "role_arn": "arn::it", "shared_credentials_file": "my-file", "use_path_style": false},
},
}

Expand All @@ -332,7 +332,7 @@ func TestAwsGetAwsSessionConfig(t *testing.T) {
Profile: s3ConfigExtended.RemoteStateConfigS3.Profile,
RoleArn: s3ConfigExtended.RemoteStateConfigS3.RoleArn,
CredsFilename: s3ConfigExtended.RemoteStateConfigS3.CredsFilename,
S3ForcePathStyle: s3ConfigExtended.RemoteStateConfigS3.S3ForcePathStyle,
S3UsePathStyle: s3ConfigExtended.RemoteStateConfigS3.S3UsePathStyle,
DisableComputeChecksums: s3ConfigExtended.DisableAWSClientChecksums,
}

Expand Down
4 changes: 2 additions & 2 deletions remote/remote_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ func TestToTerraformInitArgs(t *testing.T) {
"skip_bucket_versioning": true,

"shared_credentials_file": "my-file",
"force_path_style": true,
"use_path_style": true,
},
}
args := remoteState.ToTerraformInitArgs()

// must not contain s3_bucket_tags or dynamodb_table_tags or accesslogging_bucket_tags or skip_bucket_versioning
assertTerraformInitArgsEqual(t, args, "-backend-config=encrypt=true -backend-config=bucket=my-bucket -backend-config=key=terraform.tfstate -backend-config=region=us-east-1 -backend-config=force_path_style=true -backend-config=shared_credentials_file=my-file")
assertTerraformInitArgsEqual(t, args, "-backend-config=encrypt=true -backend-config=bucket=my-bucket -backend-config=key=terraform.tfstate -backend-config=region=us-east-1 -backend-config=use_path_style=true -backend-config=shared_credentials_file=my-file")
}

func TestToTerraformInitArgsForGCS(t *testing.T) {
Expand Down

0 comments on commit a7fbe0c

Please sign in to comment.