MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / getAWSCredentialConfig

Function getAWSCredentialConfig

packages/components/src/awsToolsUtils.ts:76–115  ·  view source on GitHub ↗
(nodeData: INodeData, options: ICommonObject, region?: string)

Source from the content-addressed store, hash-verified

74 * External ID) — The full error is logged server-side.
75 */
76export async function getAWSCredentialConfig(nodeData: INodeData, options: ICommonObject, region?: string): Promise<AWSCredentialConfig> {
77 const credentialData = await getCredentialData(nodeData.credential ?? '', options)
78 const awsRegion = region || DEFAULT_AWS_REGION
79
80 const accessKeyId = getCredentialParam('awsKey', credentialData, nodeData)
81 const secretAccessKey = getCredentialParam('awsSecret', credentialData, nodeData)
82 const sessionToken = getCredentialParam('awsSession', credentialData, nodeData)
83 const roleArn = getCredentialParam('roleArn', credentialData, nodeData)
84 const externalId = getCredentialParam('externalId', credentialData, nodeData)
85
86 // --- AssumeRole flow ---
87 if (roleArn) {
88 if (!AWS_ROLE_ARN_REGEX.test(roleArn)) {
89 throw new Error('Invalid Role ARN format: Expected format: arn:aws:iam::<12-digit-account-id>:role/<role-name>')
90 }
91 const assumedCredentials = await assumeRole({
92 accessKeyId,
93 secretAccessKey,
94 sessionToken,
95 roleArn,
96 externalId,
97 region: awsRegion,
98 logger: options.logger
99 })
100 return { credentials: assumedCredentials, region: awsRegion }
101 }
102
103 // --- Static credentials flow (backward-compatible) ---
104 if (accessKeyId && secretAccessKey) {
105 const credentials: AWSCredentials = {
106 accessKeyId,
107 secretAccessKey,
108 ...(sessionToken && { sessionToken })
109 }
110 return { credentials, region: awsRegion }
111 }
112
113 // No explicit keys and no role — let SDK use default chain
114 return { credentials: undefined, region: awsRegion }
115}
116
117/**
118 * Assume an IAM role using AWS STS and return temporary session credentials.

Callers 10

initMethod · 0.90
initMethod · 0.90
initMethod · 0.90
initMethod · 0.90
initMethod · 0.90
initMethod · 0.90
upsertMethod · 0.90
deleteMethod · 0.90
initMethod · 0.90
getAWSCredentialsFunction · 0.85

Calls 4

getCredentialDataFunction · 0.90
getCredentialParamFunction · 0.90
assumeRoleFunction · 0.85
testMethod · 0.80

Tested by

no test coverage detected