Skip to content

Commit

Permalink
fix(aws_s3 sink): allow the usage of region and endpoint (#11578)
Browse files Browse the repository at this point in the history
This patch allows to use both the `region` and `endpoint` field for the
aws_s3 sink.
This is necessary when using a different S3 provider than AWS
since the region is derived from the endpoint and mapped against a known
map of AWS region [1], which will result in the use of the default AWS
region.

[1] https://github.com/vectordotdev/vector/blob/1d9a34e24c416501c3f6377b8400253a3ad538f6/src/aws/rusoto/region.rs#L64

Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
  • Loading branch information
Sh4d1 authored Feb 25, 2022
1 parent 9855ea6 commit a1b72e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/aws/rusoto/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ pub enum ParseError {
EndpointParseError { source: InvalidUri },
#[snafu(display("Failed to parse region: {}", source))]
RegionParseError { source: ParseRegionError },
#[snafu(display("Only one of 'region' or 'endpoint' can be specified"))]
BothRegionAndEndpoint,
#[snafu(display("Must set either 'region' or 'endpoint'"))]
MissingRegionAndEndpoint,
}
Expand All @@ -25,7 +23,10 @@ impl TryFrom<&RegionOrEndpoint> for Region {
match (&r.region, &r.endpoint) {
(Some(region), None) => region.parse().context(RegionParseSnafu),
(None, Some(endpoint)) => region_from_endpoint(endpoint),
(Some(_), Some(_)) => Err(ParseError::BothRegionAndEndpoint),
(Some(region), Some(endpoint)) => Ok(Region::Custom {
name: region.to_string(),
endpoint: endpoint.to_string(),
}),
(None, None) => Err(ParseError::MissingRegionAndEndpoint),
}
}
Expand Down
2 changes: 1 addition & 1 deletion website/cue/reference/components/aws.cue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ components: _aws: {

endpoint: {
common: false
description: "Custom endpoint for use with AWS-compatible services. Providing a value for this option will make `region` moot."
description: "Custom endpoint for use with AWS-compatible services."
relevant_when: "region = null"
required: false
type: string: {
Expand Down

0 comments on commit a1b72e2

Please sign in to comment.