Skip to content

Commit 661d7f0

Browse files
authored
fix(bug578): fix issue when not providing guardrails through agent constructor (#579)
1 parent e2b1589 commit 661d7f0

File tree

3 files changed

+750
-1416
lines changed

3 files changed

+750
-1416
lines changed

src/cdk-lib/bedrock/agent.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,17 +455,20 @@ export class Agent extends Construct {
455455
tags: props.tags,
456456
promptOverrideConfiguration: props.promptOverrideConfiguration,
457457
autoPrepare: props.shouldPrepareAgent,
458-
guardrailConfiguration: {
459-
guardrailIdentifier: props.guardrailConfiguration?.guardrailId,
460-
guardrailVersion: props.guardrailConfiguration?.guardrailVersion,
461-
},
462458
});
463459

464460
this.agentInstance = agent;
465461
this.agentId = agent.attrAgentId;
466462
this.agentArn = agent.attrAgentArn;
467463
this.agentversion = agent.attrAgentVersion;
468464

465+
if (props.guardrailConfiguration) {
466+
this.agentInstance.guardrailConfiguration = {
467+
guardrailIdentifier: props.guardrailConfiguration?.guardrailId,
468+
guardrailVersion: props.guardrailConfiguration?.guardrailVersion,
469+
};
470+
}
471+
469472
this._addAliasDependency(agent.attrUpdatedAt);
470473

471474
if (props.aliasName) {

0 commit comments

Comments
 (0)