Skip to content

Commit

Permalink
chore(agent): update adddependency to higher lvl cdk method
Browse files Browse the repository at this point in the history
  • Loading branch information
krokoko committed Jan 24, 2025
1 parent 4e1da7c commit 95b44ef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cdk-lib/bedrock/agents/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,6 @@ export class Agent extends AgentBase {
},
}),
});
// add the appropriate permissions to use the FM
this.foundationModel.grantInvoke(this.role);
}
// ------------------------------------------------------
// Set Lazy Props initial values
Expand Down Expand Up @@ -441,7 +439,9 @@ export class Agent extends AgentBase {
// Add explicit dependency between the agent resource and the agent's role default policy
// See https://github.com/awslabs/generative-ai-cdk-constructs/issues/899
if (!props.existingRole) {
this.__resource.node.addDependency(this.role.node.findChild('DefaultPolicy'));
// add the appropriate permissions to use the FM
const grant = this.foundationModel.grantInvoke(this.role);
grant.applyBefore(this.__resource);
}

this.testAlias = AgentAlias.fromAttributes(this, 'DefaultAlias', {
Expand Down

0 comments on commit 95b44ef

Please sign in to comment.