@@ -244,37 +244,54 @@ impl AwsConfig {
244
244
id : GlobalId ,
245
245
connection_context : & ConnectionContext ,
246
246
) -> Result < ( ) , anyhow:: Error > {
247
- let external_id_prefix = connection_context
248
- . aws_external_id_prefix
249
- . as_ref ( )
250
- . ok_or_else ( || anyhow ! ( "external ID should have been provided!" ) ) ?;
251
- let external_id = format ! ( "{}_{}" , external_id_prefix, id) ;
252
247
let account_id = & connection_context. aws_principal ;
253
- let aws_config = self
254
- . load (
255
- Some ( external_id) ,
256
- account_id. clone ( ) ,
257
- connection_context. secrets_reader . as_ref ( ) ,
258
- )
259
- . await ?;
260
-
261
- let sts_client = aws_sdk_sts:: Client :: new ( & aws_config) ;
262
- let response = sts_client. get_caller_identity ( ) . send ( ) . await ?;
263
- println ! ( "{:?}" , response) ;
264
-
265
- let aws_config_without_external_id = self
266
- . load (
267
- None ,
268
- account_id. clone ( ) ,
269
- connection_context. secrets_reader . as_ref ( ) ,
270
- )
271
- . await ?;
272
-
273
- let sts_client = aws_sdk_sts:: Client :: new ( & aws_config_without_external_id) ;
274
- if sts_client. get_caller_identity ( ) . send ( ) . await . is_ok ( ) {
275
- Err ( anyhow ! ( "Validate succeeded without external_id!" ) )
276
- } else {
277
- Ok ( ( ) )
248
+ match & self . auth {
249
+ AwsAuth :: Credentials ( _) => {
250
+ let aws_config = self
251
+ . load (
252
+ None ,
253
+ account_id. clone ( ) ,
254
+ connection_context. secrets_reader . as_ref ( ) ,
255
+ )
256
+ . await ?;
257
+
258
+ let sts_client = aws_sdk_sts:: Client :: new ( & aws_config) ;
259
+ let _ = sts_client. get_caller_identity ( ) . send ( ) . await ?;
260
+ Ok ( ( ) )
261
+ }
262
+ AwsAuth :: AssumeRole ( _) => {
263
+ let external_id_prefix = connection_context
264
+ . aws_external_id_prefix
265
+ . as_ref ( )
266
+ . ok_or_else ( || anyhow ! ( "external ID should have been provided!" ) ) ?;
267
+ let external_id = format ! ( "{}_{}" , external_id_prefix, id) ;
268
+
269
+ let aws_config = self
270
+ . load (
271
+ Some ( external_id) ,
272
+ account_id. clone ( ) ,
273
+ connection_context. secrets_reader . as_ref ( ) ,
274
+ )
275
+ . await ?;
276
+
277
+ let sts_client = aws_sdk_sts:: Client :: new ( & aws_config) ;
278
+ let _ = sts_client. get_caller_identity ( ) . send ( ) . await ?;
279
+
280
+ let aws_config_without_external_id = self
281
+ . load (
282
+ None ,
283
+ account_id. clone ( ) ,
284
+ connection_context. secrets_reader . as_ref ( ) ,
285
+ )
286
+ . await ?;
287
+
288
+ let sts_client = aws_sdk_sts:: Client :: new ( & aws_config_without_external_id) ;
289
+ if sts_client. get_caller_identity ( ) . send ( ) . await . is_ok ( ) {
290
+ Err ( anyhow ! ( "Validate succeeded without external_id!" ) )
291
+ } else {
292
+ Ok ( ( ) )
293
+ }
294
+ }
278
295
}
279
296
}
280
297
0 commit comments