@@ -8,25 +8,33 @@ import AwsCommonRuntimeKit
88import ClientRuntime
99
1010public struct ProfileRegionProvider : RegionProvider {
11- let profileCollection : ProfileCollection
11+ let profileCollection : ProfileCollection ?
1212 let profileName : String
13+ let path : String
1314 let logger : SwiftLogger
1415
15- init ( profileCollection: ProfileCollection , profileName: String ) {
16+ init ( profileCollection: ProfileCollection ? , profileName: String , path : String ) {
1617 self . profileCollection = profileCollection
1718 self . profileName = profileName
1819 self . logger = SwiftLogger ( label: " ProfileRegionResolver " )
20+ self . path = path
1921 }
2022
2123 // TODO: expose these config fields up to the sdk so customer can override path and profile name
2224 public init ( path: String = " ~/.aws/config " , profileName: String = " default " ) {
23- let profileCollection = CRTAWSProfileCollection ( fromFile: path, source: . config)
24-
25- self . init ( profileCollection: profileCollection, profileName: profileName)
25+ self . init ( profileCollection: nil , profileName: profileName, path: path)
2626 }
2727
2828 public func resolveRegion( ) -> Future < String ? > {
2929 let future = Future < String ? > ( )
30+
31+ let profileCollection = profileCollection ?? CRTAWSProfileCollection ( fromFile: path, source: . config)
32+ guard let profileCollection = profileCollection else {
33+ logger. info ( " No default profile collection was found at the path of \( path) " )
34+ future. fulfill ( nil )
35+ return future
36+ }
37+
3038 guard let profile = profileCollection. profile ( for: profileName) else {
3139 future. fulfill ( nil )
3240 return future
0 commit comments