Skip to content

Commit db77bf8

Browse files
committed
Merge branch 'main' of github.com:ModusCreateOrg/app-med-ai-gen into ADE-174-backend
2 parents 1dac961 + dccdb97 commit db77bf8

File tree

4 files changed

+33
-40
lines changed

4 files changed

+33
-40
lines changed

.github/workflows/deploy-development.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ jobs:
5555
cd backend
5656
npm ci
5757
58+
- name: Install latest AWS CDK
59+
run: npm install -g aws-cdk
60+
5861
- name: Build application
5962
run: |
6063
cd backend

backend/src/document-processor/services/aws-bedrock.service.ts

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,17 @@ Document text:
147147
const secretAccessKey = this.configService.get<string>('aws.aws.secretAccessKey');
148148
const sessionToken = this.configService.get<string>('aws.aws.sessionToken');
149149

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+
};
152158
}
153159

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);
160161

161162
this.logger.log(
162163
`AWS client initialized with region ${region} and credentials ${accessKeyId ? '(provided)' : '(missing)'}, session token ${sessionToken ? '(provided)' : '(not provided)'}`,
@@ -165,30 +166,6 @@ Document text:
165166
return client;
166167
}
167168

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-
192169
/**
193170
* Configure the model ID from configuration with fallback
194171
*/

backend/src/iac/backend-stack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class BackendStack extends cdk.Stack {
3030
this,
3131
`${appName}UserPoolIdParam-${props.environment}`,
3232
{
33-
parameterName: `/${appName}/${props.environment}/cognito-user-pool-id`,
33+
parameterName: `${appName}UserPoolIdParam-${props.environment}`,
3434
},
3535
).stringValue;
3636

@@ -39,7 +39,7 @@ export class BackendStack extends cdk.Stack {
3939
this,
4040
`${appName}ClientIdParam-${props.environment}`,
4141
{
42-
parameterName: `/${appName}/${props.environment}/cognito-client-id`,
42+
parameterName: `${appName}ClientIdParam-${props.environment}`,
4343
},
4444
).stringValue;
4545

frontend/src/common/services/ai/bedrock.service.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,27 @@ class BedrockService {
100100
throw new Error('No credentials available');
101101
}
102102

103+
const bedrockCredentials: {
104+
accessKeyId: string;
105+
secretAccessKey: string;
106+
expiration?: Date;
107+
sessionToken?: string;
108+
} = {
109+
accessKeyId: credentials.accessKeyId,
110+
secretAccessKey: credentials.secretAccessKey,
111+
};
112+
113+
if (credentials.expiration) {
114+
bedrockCredentials.expiration = credentials.expiration;
115+
}
116+
117+
if (credentials.sessionToken) {
118+
bedrockCredentials.sessionToken = credentials.sessionToken;
119+
}
120+
103121
this.client = new BedrockRuntimeClient({
104122
region: REGION,
105-
credentials: {
106-
accessKeyId: credentials.accessKeyId,
107-
secretAccessKey: credentials.secretAccessKey,
108-
sessionToken: credentials.sessionToken,
109-
expiration: credentials.expiration
110-
}
123+
credentials: bedrockCredentials
111124
});
112125
} catch (error) {
113126
console.error('Error initializing Bedrock client:', error);

0 commit comments

Comments
 (0)