@@ -145,9 +145,18 @@ object AwsClient {
145
145
}
146
146
147
147
inline def initializeWithProperties (
148
- map : Map [String , String ]
148
+ map : Map [String , String ],
149
+ includeEnvironmentVariables : Boolean = true
149
150
): AwsClient =
150
- initializeWithProperties(map.get)
151
+ initializeWithProperties { key =>
152
+ map
153
+ .get(key)
154
+ .orElse(
155
+ if (includeEnvironmentVariables)
156
+ then scala.util.Try (System .getenv(key)).toOption
157
+ else None
158
+ )
159
+ }
151
160
152
161
/** Creates new instance of the AwsClient for the given region using a function to retrieve system properties
153
162
*/
@@ -160,8 +169,8 @@ object AwsClient {
160
169
161
170
if (isDebugMode)
162
171
then
163
- println (
164
- s " ${AnsiColor .YELLOW }[AwsClient] ${AnsiColor .RESET }${AnsiColor .CYAN } Starting ... ${ AnsiColor . RESET } "
172
+ print (
173
+ s " ${AnsiColor .YELLOW }[AwsClient] ${AnsiColor .RESET }${AnsiColor .CYAN } Starting "
165
174
)
166
175
167
176
val httpClientBuilder : UrlConnectionHttpClient .Builder =
@@ -173,11 +182,6 @@ object AwsClient {
173
182
secretAccessKey <- maybeProperty(" AWS_SECRET_ACCESS_KEY" )
174
183
sessionToken <- maybeProperty(" AWS_SESSION_TOKEN" )
175
184
} yield {
176
- if (isDebugMode)
177
- then
178
- println(
179
- s " ${AnsiColor .YELLOW }[AwsClient] ${AnsiColor .RESET }${AnsiColor .CYAN } Credentials has been initialized ${AnsiColor .RESET }"
180
- )
181
185
new AwsCredentialsProvider {
182
186
override def resolveCredentials (): AwsCredentials =
183
187
AwsSessionCredentials .create(
@@ -193,9 +197,14 @@ object AwsClient {
193
197
194
198
if (isDebugMode)
195
199
then
196
- println(
197
- s " ${AnsiColor .YELLOW }[AwsClient] ${AnsiColor .RESET }${AnsiColor .CYAN } Running in region $currentRegion${AnsiColor .RESET }"
198
- )
200
+ if (maybeCredentialsProvider.isDefined)
201
+ println(
202
+ s " , ${AnsiColor .CYAN }credentials set up. ${AnsiColor .RESET }${AnsiColor .CYAN } Default region $currentRegion. ${AnsiColor .RESET }"
203
+ )
204
+ else
205
+ println(
206
+ s " , ${AnsiColor .RED }credentials NOT found! ${AnsiColor .RED }${AnsiColor .CYAN } Default region $currentRegion. ${AnsiColor .RESET }"
207
+ )
199
208
200
209
final lazy val iam : IamClient =
201
210
createIamClient(currentRegion, httpClientBuilder, maybeCredentialsProvider)
0 commit comments