// Copyright Abridged, Inc. 2023,2024. All Rights Reserved. // Node module: @collabland/aws // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT import {loggers, isMain} from '@collabland/common'; import {ECSServiceClient} from '../aws-clients/ecs/ecs.client.js'; const {debug} = loggers('collabland:aws:ecs'); if (isMain(import.meta.url)) { const serverType = process.argv[2] ?? ''; const client = new ECSServiceClient(); const clusterArns = await client.listClusters(); const cluster = clusterArns.find(arn => arn.endsWith('cl-lve-aue1-ecs'))!; debug('Cluster: %O', cluster); const taskArns = await client.listTasks(cluster); const containers = await client.listContainers(cluster, taskArns, c => c.name?.startsWith(`collabland-${serverType}`), ); debug('Containers: %O', containers); const clusterName = cluster.split('/').pop(); const task = containers[0].task!.split('/').pop(); const container = containers[0].container!; console.log( `aws ecs execute-command --cluster ${clusterName} --task ${task} --container ${container} --interactive --command '/bin/bash' --region us-east-1`, ); }