@@ -407,11 +407,26 @@ export const populateHyperParameters = (value: FinetuneRequest) => {
407407
408408export const getInferenceProfile = async (
409409 inferenceProfileIdentifier : string ,
410- awsRegion : string ,
411- awsAccessKeyId : string ,
412- awsSecretAccessKey : string ,
413- awsSessionToken ?: string
410+ providerOptions : Options ,
411+ c : Context
414412) => {
413+ if ( providerOptions . awsAuthType === 'assumedRole' ) {
414+ const { accessKeyId, secretAccessKey, sessionToken } =
415+ ( await getAssumedRoleCredentials (
416+ c ,
417+ providerOptions . awsRoleArn || '' ,
418+ providerOptions . awsExternalId || '' ,
419+ providerOptions . awsRegion || ''
420+ ) ) || { } ;
421+ providerOptions . awsAccessKeyId = accessKeyId ;
422+ providerOptions . awsSecretAccessKey = secretAccessKey ;
423+ providerOptions . awsSessionToken = sessionToken ;
424+ }
425+
426+ const awsRegion = providerOptions . awsRegion || 'us-east-1' ;
427+ const awsAccessKeyId = providerOptions . awsAccessKeyId || '' ;
428+ const awsSecretAccessKey = providerOptions . awsSecretAccessKey || '' ;
429+ const awsSessionToken = providerOptions . awsSessionToken || '' ;
415430 const url = `https://bedrock.${ awsRegion } .amazonaws.com/inference-profiles/${ encodeURIComponent ( decodeURIComponent ( inferenceProfileIdentifier ) ) } ` ;
416431
417432 const headers = await generateAWSHeaders (
@@ -463,10 +478,8 @@ export const getFoundationModelFromInferenceProfile = async (
463478
464479 const inferenceProfile = await getInferenceProfile (
465480 inferenceProfileIdentifier || '' ,
466- providerOptions . awsRegion || '' ,
467- providerOptions . awsAccessKeyId || '' ,
468- providerOptions . awsSecretAccessKey || '' ,
469- providerOptions . awsSessionToken || ''
481+ { ...providerOptions } ,
482+ c
470483 ) ;
471484
472485 // modelArn is always like arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-v2:1
0 commit comments