@@ -64,9 +64,6 @@ mod checksum;
6464mod client;
6565mod credential;
6666
67- #[ cfg( feature = "aws_profile" ) ]
68- mod profile;
69-
7067// http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html
7168//
7269// Do not URI-encode any of the unreserved characters that RFC 3986 defines:
@@ -106,9 +103,6 @@ enum Error {
106103 #[ snafu( display( "Missing SecretAccessKey" ) ) ]
107104 MissingSecretAccessKey ,
108105
109- #[ snafu( display( "Profile support requires aws_profile feature" ) ) ]
110- MissingProfileFeature ,
111-
112106 #[ snafu( display( "ETag Header missing from response" ) ) ]
113107 MissingEtag ,
114108
@@ -427,8 +421,6 @@ pub struct AmazonS3Builder {
427421 checksum_algorithm : Option < ConfigValue < Checksum > > ,
428422 /// Metadata endpoint, see <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html>
429423 metadata_endpoint : Option < String > ,
430- /// Profile name, see <https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html>
431- profile : Option < String > ,
432424 /// Client options
433425 client_options : ClientOptions ,
434426 /// Credentials
@@ -559,13 +551,6 @@ pub enum AmazonS3ConfigKey {
559551 /// - `metadata_endpoint`
560552 MetadataEndpoint ,
561553
562- /// AWS profile name
563- ///
564- /// Supported keys:
565- /// - `aws_profile`
566- /// - `profile`
567- Profile ,
568-
569554 /// Client options
570555 Client ( ClientConfigKey ) ,
571556}
@@ -583,7 +568,6 @@ impl AsRef<str> for AmazonS3ConfigKey {
583568 Self :: VirtualHostedStyleRequest => "aws_virtual_hosted_style_request" ,
584569 Self :: DefaultRegion => "aws_default_region" ,
585570 Self :: MetadataEndpoint => "aws_metadata_endpoint" ,
586- Self :: Profile => "aws_profile" ,
587571 Self :: UnsignedPayload => "aws_unsigned_payload" ,
588572 Self :: Checksum => "aws_checksum_algorithm" ,
589573 Self :: Client ( opt) => opt. as_ref ( ) ,
@@ -612,7 +596,6 @@ impl FromStr for AmazonS3ConfigKey {
612596 "aws_virtual_hosted_style_request" | "virtual_hosted_style_request" => {
613597 Ok ( Self :: VirtualHostedStyleRequest )
614598 }
615- "aws_profile" | "profile" => Ok ( Self :: Profile ) ,
616599 "aws_imdsv1_fallback" | "imdsv1_fallback" => Ok ( Self :: ImdsV1Fallback ) ,
617600 "aws_metadata_endpoint" | "metadata_endpoint" => Ok ( Self :: MetadataEndpoint ) ,
618601 "aws_unsigned_payload" | "unsigned_payload" => Ok ( Self :: UnsignedPayload ) ,
@@ -643,7 +626,6 @@ impl AmazonS3Builder {
643626 /// * `AWS_SESSION_TOKEN` -> token
644627 /// * `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI` -> <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html>
645628 /// * `AWS_ALLOW_HTTP` -> set to "true" to permit HTTP connections without TLS
646- /// * `AWS_PROFILE` -> set profile name, requires `aws_profile` feature enabled
647629 /// # Example
648630 /// ```
649631 /// use object_store::aws::AmazonS3Builder;
@@ -727,7 +709,6 @@ impl AmazonS3Builder {
727709 AmazonS3ConfigKey :: MetadataEndpoint => {
728710 self . metadata_endpoint = Some ( value. into ( ) )
729711 }
730- AmazonS3ConfigKey :: Profile => self . profile = Some ( value. into ( ) ) ,
731712 AmazonS3ConfigKey :: UnsignedPayload => self . unsigned_payload . parse ( value) ,
732713 AmazonS3ConfigKey :: Checksum => {
733714 self . checksum_algorithm = Some ( ConfigValue :: Deferred ( value. into ( ) ) )
@@ -794,7 +775,6 @@ impl AmazonS3Builder {
794775 Some ( self . virtual_hosted_style_request . to_string ( ) )
795776 }
796777 AmazonS3ConfigKey :: MetadataEndpoint => self . metadata_endpoint . clone ( ) ,
797- AmazonS3ConfigKey :: Profile => self . profile . clone ( ) ,
798778 AmazonS3ConfigKey :: UnsignedPayload => Some ( self . unsigned_payload . to_string ( ) ) ,
799779 AmazonS3ConfigKey :: Checksum => {
800780 self . checksum_algorithm . as_ref ( ) . map ( ToString :: to_string)
@@ -982,39 +962,15 @@ impl AmazonS3Builder {
982962 self
983963 }
984964
985- /// Set the AWS profile name, see <https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html>
986- ///
987- /// This makes use of [aws-config] to provide credentials and therefore requires
988- /// the `aws-profile` feature to be enabled
989- ///
990- /// It is strongly encouraged that users instead make use of a credential manager
991- /// such as [aws-vault] not only to avoid the significant additional dependencies,
992- /// but also to avoid storing credentials in [plain text on disk]
993- ///
994- /// [aws-config]: https://docs.rs/aws-config
995- /// [aws-vault]: https://github.com/99designs/aws-vault
996- /// [plain text on disk]: https://99designs.com.au/blog/engineering/aws-vault/
997- #[ cfg( feature = "aws_profile" ) ]
998- pub fn with_profile ( mut self , profile : impl Into < String > ) -> Self {
999- self . profile = Some ( profile. into ( ) ) ;
1000- self
1001- }
1002-
1003965 /// Create a [`AmazonS3`] instance from the provided values,
1004966 /// consuming `self`.
1005967 pub fn build ( mut self ) -> Result < AmazonS3 > {
1006968 if let Some ( url) = self . url . take ( ) {
1007969 self . parse_url ( & url) ?;
1008970 }
1009971
1010- let region = match ( self . region , self . profile . clone ( ) ) {
1011- ( Some ( region) , _) => Some ( region) ,
1012- ( None , Some ( profile) ) => profile_region ( profile) ,
1013- ( None , None ) => None ,
1014- } ;
1015-
1016972 let bucket = self . bucket_name . context ( MissingBucketNameSnafu ) ?;
1017- let region = region. context ( MissingRegionSnafu ) ?;
973+ let region = self . region . context ( MissingRegionSnafu ) ?;
1018974 let checksum = self . checksum_algorithm . map ( |x| x. get ( ) ) . transpose ( ) ?;
1019975
1020976 let credentials = if let Some ( credentials) = self . credentials {
@@ -1065,9 +1021,6 @@ impl AmazonS3Builder {
10651021 client,
10661022 self . retry_config . clone ( ) ,
10671023 ) ) as _
1068- } else if let Some ( profile) = self . profile {
1069- info ! ( "Using profile \" {}\" credential provider" , profile) ;
1070- profile_credentials ( profile, region. clone ( ) ) ?
10711024 } else {
10721025 info ! ( "Using Instance credential provider" ) ;
10731026
@@ -1123,37 +1076,6 @@ impl AmazonS3Builder {
11231076 }
11241077}
11251078
1126- #[ cfg( feature = "aws_profile" ) ]
1127- fn profile_region ( profile : String ) -> Option < String > {
1128- use tokio:: runtime:: Handle ;
1129-
1130- let handle = Handle :: current ( ) ;
1131- let provider = profile:: ProfileProvider :: new ( profile, None ) ;
1132-
1133- handle. block_on ( provider. get_region ( ) )
1134- }
1135-
1136- #[ cfg( feature = "aws_profile" ) ]
1137- fn profile_credentials ( profile : String , region : String ) -> Result < AwsCredentialProvider > {
1138- Ok ( Arc :: new ( profile:: ProfileProvider :: new (
1139- profile,
1140- Some ( region) ,
1141- ) ) )
1142- }
1143-
1144- #[ cfg( not( feature = "aws_profile" ) ) ]
1145- fn profile_region ( _profile : String ) -> Option < String > {
1146- None
1147- }
1148-
1149- #[ cfg( not( feature = "aws_profile" ) ) ]
1150- fn profile_credentials (
1151- _profile : String ,
1152- _region : String ,
1153- ) -> Result < AwsCredentialProvider > {
1154- Err ( Error :: MissingProfileFeature . into ( ) )
1155- }
1156-
11571079#[ cfg( test) ]
11581080mod tests {
11591081 use super :: * ;
@@ -1638,50 +1560,3 @@ mod s3_resolve_bucket_region_tests {
16381560 assert ! ( result. is_err( ) ) ;
16391561 }
16401562}
1641-
1642- #[ cfg( all( test, feature = "aws_profile" ) ) ]
1643- mod profile_tests {
1644- use super :: * ;
1645- use std:: env;
1646-
1647- use super :: profile:: { TEST_PROFILE_NAME , TEST_PROFILE_REGION } ;
1648-
1649- #[ tokio:: test]
1650- async fn s3_test_region_from_profile ( ) {
1651- let s3_url = "s3://bucket/prefix" . to_owned ( ) ;
1652-
1653- let s3 = AmazonS3Builder :: new ( )
1654- . with_url ( s3_url)
1655- . with_profile ( TEST_PROFILE_NAME )
1656- . build ( )
1657- . unwrap ( ) ;
1658-
1659- let region = & s3. client . config ( ) . region ;
1660-
1661- assert_eq ! ( region, TEST_PROFILE_REGION ) ;
1662- }
1663-
1664- #[ test]
1665- fn s3_test_region_override ( ) {
1666- let s3_url = "s3://bucket/prefix" . to_owned ( ) ;
1667-
1668- let aws_profile =
1669- env:: var ( "AWS_PROFILE" ) . unwrap_or_else ( |_| TEST_PROFILE_NAME . into ( ) ) ;
1670-
1671- let aws_region =
1672- env:: var ( "AWS_REGION" ) . unwrap_or_else ( |_| "object_store:fake_region" . into ( ) ) ;
1673-
1674- env:: set_var ( "AWS_PROFILE" , aws_profile) ;
1675-
1676- let s3 = AmazonS3Builder :: from_env ( )
1677- . with_url ( s3_url)
1678- . with_region ( aws_region. clone ( ) )
1679- . build ( )
1680- . unwrap ( ) ;
1681-
1682- let actual = & s3. client . config ( ) . region ;
1683- let expected = & aws_region;
1684-
1685- assert_eq ! ( actual, expected) ;
1686- }
1687- }
0 commit comments