Skip to content

Commit 0c2b8f4

Browse files
authored
Merge pull request #1131 from narengogi/fix/inference-profile-assumed-role
assumed role support for bedrock application inference profile
2 parents c0b6f38 + 0049749 commit 0c2b8f4

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

src/providers/bedrock/utils.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,26 @@ export const populateHyperParameters = (value: FinetuneRequest) => {
407407

408408
export 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

Comments
 (0)