Skip to content

Commit

Permalink
cloud/aws: exposed additional options to config;
Browse files Browse the repository at this point in the history
This exposes additional options for AWS clients to the config files.
These include:

- Disabling request compression and min compression request size for cloudwatch
- Disabling response checksum validation and accepting gzip compression for dynamodb
- The usePathStyle setting was documented for S3 (but it was already exposed before)

These settings are needed when talking to services implementing the AWS
API like localstack or ScyllaDB as these services sometimes can't map
all features exactly.
  • Loading branch information
ajscholl committed Feb 18, 2025
1 parent 1a348da commit 1fab80b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/cloud/aws/cloudwatch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ type Client interface {

type ClientSettings struct {
gosoAws.ClientSettings
// Whether to disable automatic request compression for supported operations.
DisableRequestCompression bool `cfg:"disable_request_compression" default:"false"`
// The minimum request body size, in bytes, at which compression should occur. The
// default value is 10 KiB. Values must fall within [0, 1MiB].
RequestMinCompressSizeBytes int64 `cfg:"request_min_compress_size_bytes" default:"0"`
}

type ClientConfig struct {
Expand Down Expand Up @@ -68,6 +73,8 @@ func NewClient(ctx context.Context, config cfg.Config, logger log.Logger, name s

client := cloudwatch.NewFromConfig(awsConfig, func(options *cloudwatch.Options) {
options.BaseEndpoint = gosoAws.NilIfEmpty(clientCfg.Settings.Endpoint)
options.DisableRequestCompression = clientCfg.Settings.DisableRequestCompression
options.RequestMinCompressSizeBytes = clientCfg.Settings.RequestMinCompressSizeBytes
})

gosoAws.LogNewClientCreated(ctx, logger, "cloudwatch", name, clientCfg.Settings.ClientSettings)
Expand Down
8 changes: 8 additions & 0 deletions pkg/cloud/aws/dynamodb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type Client interface {

type ClientSettings struct {
gosoAws.ClientSettings
// Allows you to disable the client's validation of response integrity using CRC32
// checksum. Enabled by default.
DisableValidateResponseChecksum bool `cfg:"disable_validate_response_checksum" default:"false"`
// Allows you to enable the client's support for compressed gzip responses.
// Disabled by default.
EnableAcceptEncodingGzip bool `cfg:"enable_accept_encoding_gzip" default:"false"`
}

type ClientConfig struct {
Expand Down Expand Up @@ -89,6 +95,8 @@ func NewClient(ctx context.Context, config cfg.Config, logger log.Logger, name s

client := dynamodb.NewFromConfig(awsConfig, func(options *dynamodb.Options) {
options.BaseEndpoint = gosoAws.NilIfEmpty(clientCfg.Settings.Endpoint)
options.DisableValidateResponseChecksum = clientCfg.Settings.DisableValidateResponseChecksum
options.EnableAcceptEncodingGzip = clientCfg.Settings.EnableAcceptEncodingGzip
})

gosoAws.LogNewClientCreated(ctx, logger, "dynamodb", name, clientCfg.Settings.ClientSettings)
Expand Down
3 changes: 3 additions & 0 deletions pkg/cloud/aws/s3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type Client interface {

type ClientSettings struct {
gosoAws.ClientSettings
// Allows you to enable the client to use path-style addressing, i.e.,
// https://s3.amazonaws.com/BUCKET/KEY . By default, the S3 client will use virtual
// hosted bucket addressing when possible( https://BUCKET.s3.amazonaws.com/KEY ).
UsePathStyle bool `cfg:"usePathStyle" default:"true"`
}

Expand Down

0 comments on commit 1fab80b

Please sign in to comment.