-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteInactiveTaskDefs.mjs
More file actions
51 lines (44 loc) · 1.02 KB
/
deleteInactiveTaskDefs.mjs
File metadata and controls
51 lines (44 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import {
ECSClient,
ListTaskDefinitionsCommand,
paginateListTaskDefinitions,
DescribeTaskDefinitionCommand,
DeleteTaskDefinitionsCommand,
} from "@aws-sdk/client-ecs";
import { fromSSO } from "@aws-sdk/credential-providers";
const awsRegion = "us-west-2";
const client = new ECSClient({
region: awsRegion,
credentials: fromSSO({ profile: "legacy-stage" }),
maxAttempts: 100,
});
async function main() {
let defs = new Set();
const fList = await client.send(
new ListTaskDefinitionsCommand({
status: "INACTIVE",
}),
);
// console.log(fList);
for await (const data of paginateListTaskDefinitions(
{ client },
{
nextToken: fList.nextToken,
status: "INACTIVE",
},
)) {
for (const def of data.taskDefinitionArns) {
console.log("removing:", def);
await client.send(
new DeleteTaskDefinitionsCommand({
taskDefinitions: [def],
}),
);
}
}
}
main()
.then(() => process.exit(0))
.catch((e) => {
console.error(e);
});