Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: remove CLI only S3 config options #1081

Merged
merged 4 commits into from
Oct 25, 2023
Merged
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
5 changes: 5 additions & 0 deletions .changes/5adb30dd-3a4f-4a3c-aa31-e6455785c9c4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "5adb30dd-3a4f-4a3c-aa31-e6455785c9c4",
"type": "misc",
"description": "**Breaking** Removed `enableAccelerate` & `forcePathStyle` from S3 config. As well as `use_accelerate_endpoint` & `addressing_style` from AWS profile configuration"
}
5 changes: 5 additions & 0 deletions .changes/86e02b43-e485-46be-ba3f-429c59e45078.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "86e02b43-e485-46be-ba3f-429c59e45078",
"type": "misc",
"description": "Added `s3_use_arn_region` & `s3_disable_multiregion_access_points` to AWS profile configuration"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,23 @@ class ClientConfigIntegration : KotlinIntegration {
model.expectShape<ServiceShape>(settings.service).isS3

companion object {
val EnableAccelerateProp: ConfigProperty = ConfigProperty {
name = "enableAccelerate"
val UseArnRegionProp: ConfigProperty = ConfigProperty {
name = "useArnRegion"
useSymbolWithNullableBuilder(KotlinTypes.Boolean, "false")
documentation = """
Flag to support [S3 transfer acceleration](https://docs.aws.amazon.com/AmazonS3/latest/userguide/transfer-acceleration.html)
with this client.
Flag to enforce using a bucket arn with a region matching the client config when making requests with
[S3 access points](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points.html).
""".trimIndent()
}

val ForcePathStyleProp: ConfigProperty = ConfigProperty {
name = "forcePathStyle"
useSymbolWithNullableBuilder(KotlinTypes.Boolean, "false")
// FIXME: default signer doesn't yet implement sigv4a, default to mrap OFF until it does
val DisableMrapProp: ConfigProperty = ConfigProperty {
name = "disableMrap"
useSymbolWithNullableBuilder(KotlinTypes.Boolean, "true")
documentation = """
Flag to use legacy path-style addressing when making requests.
Flag to disable [S3 multi-region access points](https://docs.aws.amazon.com/AmazonS3/latest/userguide/MultiRegionAccessPoints.html).
""".trimIndent()
}

val UseArnRegionProp: ConfigProperty = ConfigProperty.Boolean(
"useArnRegion",
defaultValue = false,
documentation = """
Flag to enforce using a bucket arn with a region matching the client config when making requests with
[S3 access points](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points.html).
""".trimIndent(),
)

// FUTURE: default signer doesn't yet implement sigv4a, default to mrap OFF until it does
Copy link
Member

Choose a reason for hiding this comment

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

Can we keep this comment as a FIXME?

val DisableMrapProp: ConfigProperty = ConfigProperty.Boolean(
"disableMrap",
defaultValue = true,
documentation = """
Flag to disable [S3 multi-region access points](https://docs.aws.amazon.com/AmazonS3/latest/userguide/MultiRegionAccessPoints.html).
""".trimIndent(),
)
}

override fun preprocessModel(model: Model, settings: KotlinSettings): Model {
Expand All @@ -83,8 +66,6 @@ class ClientConfigIntegration : KotlinIntegration {

override fun additionalServiceConfigProps(ctx: CodegenContext): List<ConfigProperty> =
listOf(
EnableAccelerateProp,
ForcePathStyleProp,
UseArnRegionProp,
DisableMrapProp,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ fun renderBindAwsBuiltins(ctx: ProtocolGenerator.GenerationContext, writer: Kotl
"AWS::UseFIPS" -> renderBasicConfigBinding(writer, it, AwsServiceConfigIntegration.UseFipsProp.propertyName)
"AWS::UseDualStack" -> renderBasicConfigBinding(writer, it, AwsServiceConfigIntegration.UseDualStackProp.propertyName)

"AWS::S3::Accelerate" -> renderBasicConfigBinding(writer, it, S3ClientConfigIntegration.EnableAccelerateProp.propertyName)
"AWS::S3::ForcePathStyle" -> renderBasicConfigBinding(writer, it, S3ClientConfigIntegration.ForcePathStyleProp.propertyName)
"AWS::S3::DisableMultiRegionAccessPoints" -> renderBasicConfigBinding(writer, it, S3ClientConfigIntegration.DisableMrapProp.propertyName)
"AWS::S3::UseArnRegion" -> renderBasicConfigBinding(writer, it, S3ClientConfigIntegration.DisableMrapProp.propertyName)
"AWS::S3Control::UseArnRegion" -> renderBasicConfigBinding(writer, it, S3ControlClientConfigIntegration.UseArnRegionProp.propertyName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package aws.sdk.kotlin.services.s3.internal

import aws.sdk.kotlin.runtime.ConfigurationException
import aws.sdk.kotlin.runtime.config.profile.AwsProfile
import aws.sdk.kotlin.runtime.config.profile.AwsSharedConfig
import aws.sdk.kotlin.runtime.config.profile.getBooleanOrNull
Expand All @@ -13,19 +12,13 @@ import aws.smithy.kotlin.runtime.util.LazyAsyncValue

internal suspend fun finalizeS3Config(builder: S3Client.Builder, sharedConfig: LazyAsyncValue<AwsSharedConfig>) {
sharedConfig.get().activeProfile.let {
builder.config.forcePathStyle = builder.config.forcePathStyle ?: it.forcePathStyle
builder.config.enableAccelerate = builder.config.enableAccelerate ?: it.enableAccelerate
builder.config.useArnRegion = builder.config.useArnRegion ?: it.useArnRegion
builder.config.disableMrap = builder.config.disableMrap ?: it.disableMrap
}
}

private val AwsProfile.forcePathStyle: Boolean?
get() = getOrNull("s3", "addressing_style")?.lowercase()?.let {
when (it) {
"virtual", "auto" -> false
"path" -> true
else -> throw ConfigurationException("invalid value '$it' for config property s3.addressing_style")
}
}
private val AwsProfile.useArnRegion: Boolean?
get() = getBooleanOrNull("s3_use_arn_region")

private val AwsProfile.enableAccelerate: Boolean?
get() = getBooleanOrNull("s3", "use_accelerate_endpoint")
private val AwsProfile.disableMrap: Boolean?
get() = getBooleanOrNull("s3_disable_multiregion_access_points")
Loading