@@ -56,22 +56,13 @@ pub struct S3ConnectionSpec {
56
56
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
57
57
pub port : Option < u16 > ,
58
58
59
- /// AWS service API region used by the AWS SDK when using AWS S3 buckets .
59
+ /// Bucket region used for signing headers (sigv4) .
60
60
///
61
- /// This defaults to `us-east-1` and can be ignored if not using AWS S3
62
- /// buckets.
61
+ /// This defaults to `us-east-1` which is compatible with other implementations such as Minio.
63
62
///
64
- /// NOTE: This is not the bucket region, and is used by the AWS SDK to
65
- /// construct endpoints for various AWS service APIs. It is only useful when
66
- /// using AWS S3 buckets.
67
- ///
68
- /// When using AWS S3 buckets, you can configure optimal AWS service API
69
- /// connections in the following ways:
70
- /// - From **inside** AWS: Use an auto-discovery source (eg: AWS IMDS).
71
- /// - From **outside** AWS, or when IMDS is disabled, explicity set the
72
- /// region name nearest to where the client application is running from.
63
+ /// WARNING: Some products use the Hadoop S3 implementation which falls back to us-east-2.
73
64
#[ serde( default ) ]
74
- pub region : AwsRegion ,
65
+ pub region : Region ,
75
66
76
67
/// Which access style to use.
77
68
/// Defaults to virtual hosted-style as most of the data products out there.
@@ -103,56 +94,22 @@ pub enum S3AccessStyle {
103
94
VirtualHosted ,
104
95
}
105
96
106
- /// Set a named AWS region, or defer to an auto-discovery mechanism .
97
+ /// Set a named S3 Bucket region .
107
98
#[ derive( Clone , Debug , Deserialize , Eq , JsonSchema , PartialEq , Serialize ) ]
108
99
#[ serde( rename_all = "camelCase" ) ]
109
- pub enum AwsRegion {
110
- /// Defer region detection to an auto-discovery mechanism.
111
- Source ( AwsRegionAutoDiscovery ) ,
112
-
113
- /// An explicit region, eg: eu-central-1
114
- Name ( String ) ,
115
- }
116
-
117
- impl AwsRegion {
118
- /// Get the AWS region name.
119
- ///
120
- /// Returns `None` if an auto-discovery source has been selected. Otherwise,
121
- /// it returns the configured region name.
122
- ///
123
- /// Example usage:
124
- ///
125
- /// ```
126
- /// # use stackable_operator::commons::s3::AwsRegion;
127
- /// # fn set_property(key: &str, value: &str) {}
128
- /// # fn example(aws_region: AwsRegion) {
129
- /// if let Some(region_name) = aws_region.name() {
130
- /// // set some property if the region is set, or is the default.
131
- /// set_property("aws.region", region_name);
132
- /// };
133
- /// # }
134
- /// ```
135
- pub fn name ( & self ) -> Option < & str > {
136
- match self {
137
- AwsRegion :: Name ( name) => Some ( name) ,
138
- AwsRegion :: Source ( _) => None ,
139
- }
140
- }
100
+ pub struct Region {
101
+ #[ serde( default = "default_region_name" ) ]
102
+ pub name : String ,
141
103
}
142
104
143
- impl Default for AwsRegion {
105
+ impl Default for Region {
144
106
fn default ( ) -> Self {
145
- Self :: Name ( "us-east-1" . to_owned ( ) )
107
+ Self {
108
+ name : default_region_name ( ) ,
109
+ }
146
110
}
147
111
}
148
112
149
- /// AWS region auto-discovery mechanism.
150
- #[ derive( Clone , Debug , Deserialize , Eq , JsonSchema , PartialEq , Serialize ) ]
151
- #[ serde( rename_all = "PascalCase" ) ]
152
- pub enum AwsRegionAutoDiscovery {
153
- /// AWS Instance Meta Data Service.
154
- ///
155
- /// This variant should result in no region being given to the AWS SDK,
156
- /// which should, in turn, query the AWS IMDS.
157
- AwsImds ,
113
+ fn default_region_name ( ) -> String {
114
+ "us-east-1" . into ( )
158
115
}
0 commit comments