UNPKG

@stacksjs/cloud

Version:

The Stacks cloud/serverless integration & implementation.

20 lines (17 loc) 871 B
import type { Construct } from 'constructs'; import type { NestedCloudProps } from '../types'; export declare interface AiStackProps extends NestedCloudProps {} export declare class AiStack { constructor(scope: Construct, props: AiStackProps) { const bedrockAccessPolicy = new iam.PolicyStatement({ effect: iam.Effect.ALLOW, actions: ['bedrock:InvokeModel', 'bedrock:InvokeModelWithResponseStream'], resources: config.ai.models?.map((model: string) => `arn:aws:bedrock:us-east-1::foundation-model/${model}`), }) const bedrockAccessRole = new iam.Role(scope, 'BedrockAccessRole', { assumedBy: new iam.ServicePrincipal('ecs-tasks.amazonaws.com'), managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AmazonECSTaskExecutionRolePolicy')], }) bedrockAccessRole.addToPolicy(bedrockAccessPolicy) } }