@@ -168,6 +168,39 @@ public WorkshopStack(final Construct scope, final String id, final StackProps pr
168168
169169 // java-spring-ai-agents specific resources
170170 if (isSpringAi ) {
171+ // AI Agent Runtime role for AgentCore deployment
172+ software .amazon .awscdk .services .iam .Role aiAgentRuntimeRole = software .amazon .awscdk .services .iam .Role .Builder .create (this , "AiAgentRuntimeRole" )
173+ .roleName ("aiagent-agentcore-runtime-role" )
174+ .assumedBy (software .amazon .awscdk .services .iam .ServicePrincipal .Builder .create ("bedrock-agentcore.amazonaws.com" )
175+ .conditions (java .util .Map .of (
176+ "StringEquals" , java .util .Map .of ("aws:SourceAccount" , this .getAccount ()),
177+ "ArnLike" , java .util .Map .of ("aws:SourceArn" , "arn:aws:bedrock-agentcore:" + this .getRegion () + ":" + this .getAccount () + ":*" )
178+ ))
179+ .build ())
180+ .description ("Role for AI Agent AgentCore Runtime" )
181+ .inlinePolicies (java .util .Map .of ("AgentCoreExecutionPolicy" ,
182+ software .amazon .awscdk .services .iam .PolicyDocument .Builder .create ()
183+ .statements (java .util .List .of (
184+ software .amazon .awscdk .services .iam .PolicyStatement .Builder .create ()
185+ .effect (software .amazon .awscdk .services .iam .Effect .ALLOW )
186+ .actions (java .util .List .of ("bedrock:*" , "bedrock-agentcore:*" ))
187+ .resources (java .util .List .of ("*" ))
188+ .build (),
189+ software .amazon .awscdk .services .iam .PolicyStatement .Builder .create ()
190+ .effect (software .amazon .awscdk .services .iam .Effect .ALLOW )
191+ .actions (java .util .List .of ("ecr:*" , "logs:*" , "xray:*" , "cloudwatch:*" ))
192+ .resources (java .util .List .of ("*" ))
193+ .build (),
194+ software .amazon .awscdk .services .iam .PolicyStatement .Builder .create ()
195+ .effect (software .amazon .awscdk .services .iam .Effect .ALLOW )
196+ .actions (java .util .List .of ("aws-marketplace:Subscribe" , "aws-marketplace:Unsubscribe" , "aws-marketplace:ViewSubscriptions" ))
197+ .resources (java .util .List .of ("*" ))
198+ .build ()
199+ ))
200+ .build ()
201+ ))
202+ .build ();
203+
171204 // AI Agent EKS Pod Identity role with Bedrock access
172205 software .amazon .awscdk .services .iam .Role aiAgentEksRole = software .amazon .awscdk .services .iam .Role .Builder .create (this , "AiAgentEksRole" )
173206 .roleName ("ai-agent-eks-pod-role" )
0 commit comments