Skip to content

Commit 665f1c9

Browse files
authored
chore: improve developer experience with region resolver (#478)
1 parent b805129 commit 665f1c9

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

AWSClientRuntime/Sources/Regions/DefaultRegionResolver.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,32 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77
import AwsCommonRuntimeKit
8+
import ClientRuntime
89

910
public struct DefaultRegionResolver: RegionResolver {
1011
public let providers: [RegionProvider]
11-
12+
let logger: SwiftLogger
13+
1214
public init(providers: [RegionProvider] = [EnvironmentRegionProvider(), ProfileRegionProvider(), IMDSRegionProvider()]) {
1315
// TODO: add more region resolvers i.e. System Properties, etc
1416
self.providers = providers
17+
self.logger = SwiftLogger(label: "DefaultRegionProvider")
1518
}
1619

1720
public func resolveRegion() -> String? {
1821
for provider in providers {
1922
do {
2023
// TODO: Verify that this does not block calling thread. If it does, we need to solve this similar to the way we solve this for the credentials provider
24+
logger.debug("Attempting to resolve region with: \(String(describing: type(of: provider)))")
2125
if let region = try provider.resolveRegion().get() {
26+
logger.debug("Resolved region with: \(String(describing: type(of: provider)))")
2227
return region
2328
}
2429
} catch {
2530
return nil
2631
}
2732
}
33+
logger.debug("Unable to resolve region")
2834
return nil
2935
}
3036
}

AWSClientRuntime/Sources/Regions/ProfileRegionResolver.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@ public struct ProfileRegionProvider: RegionProvider {
3030

3131
let profileCollection = profileCollection ?? CRTAWSProfileCollection(fromFile: path, source: .config)
3232
guard let profileCollection = profileCollection else {
33-
logger.info("No default profile collection was found at the path of \(path)")
33+
logger.debug("No default profile collection was found at the path of \(path)")
3434
future.fulfill(nil)
3535
return future
3636
}
3737

3838
guard let profile = profileCollection.profile(for: profileName) else {
39+
logger.debug("Unable to find profile: \(profileName) in \(path)")
3940
future.fulfill(nil)
4041
return future
4142
}
4243
guard let region = profile.getProperty(name: "region") else {
43-
logger.info("Attempting to use \(profileName), but no region was found")
44+
logger.debug("Attempting to use \(profileName), but no region was found")
4445
future.fulfill(nil)
4546
return future
4647
}

0 commit comments

Comments
 (0)