@@ -147,16 +147,17 @@ Document text:
147
147
const secretAccessKey = this . configService . get < string > ( 'aws.aws.secretAccessKey' ) ;
148
148
const sessionToken = this . configService . get < string > ( 'aws.aws.sessionToken' ) ;
149
149
150
- if ( ! region || ! accessKeyId || ! secretAccessKey ) {
151
- throw new Error ( 'Missing required AWS configuration' ) ;
150
+ const clientConfig : any = { region } ;
151
+
152
+ if ( accessKeyId && secretAccessKey ) {
153
+ clientConfig . credentials = {
154
+ accessKeyId,
155
+ secretAccessKey,
156
+ ...( sessionToken && { sessionToken } ) ,
157
+ } ;
152
158
}
153
159
154
- const credentials = this . createCredentialsObject ( accessKeyId , secretAccessKey , sessionToken ) ;
155
-
156
- const client = new BedrockRuntimeClient ( {
157
- region,
158
- credentials,
159
- } ) ;
160
+ const client = new BedrockRuntimeClient ( clientConfig ) ;
160
161
161
162
this . logger . log (
162
163
`AWS client initialized with region ${ region } and credentials ${ accessKeyId ? '(provided)' : '(missing)' } , session token ${ sessionToken ? '(provided)' : '(not provided)' } ` ,
@@ -165,30 +166,6 @@ Document text:
165
166
return client ;
166
167
}
167
168
168
- /**
169
- * Create AWS credentials object with proper typing
170
- */
171
- private createCredentialsObject (
172
- accessKeyId : string ,
173
- secretAccessKey : string ,
174
- sessionToken ?: string ,
175
- ) : {
176
- accessKeyId : string ;
177
- secretAccessKey : string ;
178
- sessionToken ?: string ;
179
- } {
180
- const credentials = {
181
- accessKeyId,
182
- secretAccessKey,
183
- } ;
184
-
185
- if ( sessionToken ) {
186
- return { ...credentials , sessionToken } ;
187
- }
188
-
189
- return credentials ;
190
- }
191
-
192
169
/**
193
170
* Configure the model ID from configuration with fallback
194
171
*/
0 commit comments