@@ -23,8 +23,7 @@ import * as bedrock from '@aws-cdk/aws-bedrock-alpha';
2323import * as agentcoremixins from '@aws-cdk/mixins-preview/aws-bedrockagentcore' ;
2424import { ArnFormat , AspectPriority , Aspects , Stack , StackProps , RemovalPolicy , CfnOutput , CfnResource , Duration , Fn , Lazy } from 'aws-cdk-lib' ;
2525import * as ec2 from 'aws-cdk-lib/aws-ec2' ;
26- // ecr_assets import is only needed when the ECS block below is uncommented
27- // import * as ecr_assets from 'aws-cdk-lib/aws-ecr-assets';
26+ import * as ecr_assets from 'aws-cdk-lib/aws-ecr-assets' ;
2827import * as iam from 'aws-cdk-lib/aws-iam' ;
2928import * as logs from 'aws-cdk-lib/aws-logs' ;
3029import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager' ;
@@ -38,12 +37,12 @@ import { Blueprint } from '../constructs/blueprint';
3837import { CedarWasmLayer } from '../constructs/cedar-wasm-layer' ;
3938import { ConcurrencyReconciler } from '../constructs/concurrency-reconciler' ;
4039import { DnsFirewall } from '../constructs/dns-firewall' ;
40+ import { EcsAgentCluster } from '../constructs/ecs-agent-cluster' ;
4141import { FanOutConsumer } from '../constructs/fanout-consumer' ;
4242import { LinearIntegration } from '../constructs/linear-integration' ;
4343import { RepoTable } from '../constructs/repo-table' ;
4444import { SlackIntegration } from '../constructs/slack-integration' ;
4545import { StrandedTaskReconciler } from '../constructs/stranded-task-reconciler' ;
46- // import { EcsAgentCluster } from '../constructs/ecs-agent-cluster';
4746import { TaskApi } from '../constructs/task-api' ;
4847import { TaskApprovalsTable } from '../constructs/task-approvals-table' ;
4948import { TaskDashboard } from '../constructs/task-dashboard' ;
@@ -519,26 +518,25 @@ export class AgentStack extends Stack {
519518 description : 'Name of the S3 bucket storing --trace trajectory artifacts (design §10.1)' ,
520519 } ) ;
521520
522- // --- ECS Fargate compute backend (optional) ---
523- // To enable ECS as an alternative compute backend, uncomment the block below
524- // and the EcsAgentCluster import at the top of this file. Repos can then use
525- // compute_type: 'ecs' in their blueprint config to route tasks to ECS Fargate.
526- //
527- // const agentImageAsset = new ecr_assets.DockerImageAsset(this, 'AgentImage', {
528- // directory: repoRoot,
529- // file: 'agent/Dockerfile',
530- // platform: ecr_assets.Platform.LINUX_ARM64,
531- // });
532- //
533- // const ecsCluster = new EcsAgentCluster(this, 'EcsAgentCluster', {
534- // vpc: agentVpc.vpc,
535- // agentImageAsset,
536- // taskTable: taskTable.table,
537- // taskEventsTable: taskEventsTable.table,
538- // userConcurrencyTable: userConcurrencyTable.table,
539- // githubTokenSecret,
540- // memoryId: agentMemory.memory.memoryId,
541- // });
521+ // --- ECS Fargate compute backend (enabled when compute_type=ecs) ---
522+ const computeType = this . node . tryGetContext ( 'compute_type' ) ?? 'agentcore' ;
523+ if ( computeType === 'ecs' ) {
524+ const agentImageAsset = new ecr_assets . DockerImageAsset ( this , 'AgentImage' , {
525+ directory : repoRoot ,
526+ file : 'agent/Dockerfile' ,
527+ platform : ecr_assets . Platform . LINUX_ARM64 ,
528+ } ) ;
529+
530+ new EcsAgentCluster ( this , 'EcsAgentCluster' , {
531+ vpc : agentVpc . vpc ,
532+ agentImageAsset,
533+ taskTable : taskTable . table ,
534+ taskEventsTable : taskEventsTable . table ,
535+ userConcurrencyTable : userConcurrencyTable . table ,
536+ githubTokenSecret,
537+ memoryId : agentMemory . memory . memoryId ,
538+ } ) ;
539+ }
542540
543541 // --- Task Orchestrator (durable Lambda function) ---
544542 const orchestrator = new TaskOrchestrator ( this , 'TaskOrchestrator' , {
0 commit comments