-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathget-rate-limits.ts
63 lines (56 loc) · 1.63 KB
/
get-rate-limits.ts
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
52
53
54
55
56
57
58
59
60
61
62
63
import {getAwsClient, getRegions} from '@remotion/lambda';
import {LAMBDA_CONCURRENCY_LIMIT_QUOTA} from '@remotion/lambda/dist/defaults';
import dotenv from 'dotenv';
import {getAccountCount} from './src/get-account-count';
import {setEnvForKey} from './src/set-env-for-key';
dotenv.config();
const count = getAccountCount();
console.log(`Found ${count} accounts. Getting service quota...`);
const execute = async () => {
for (let i = 1; i <= count; i++) {
for (const region of getRegions()) {
setEnvForKey(i);
const {client, sdk} = getAwsClient({
region,
service: 'servicequotas',
});
const quota = await client.send(
new sdk.GetServiceQuotaCommand({
QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,
ServiceCode: 'lambda',
})
);
console.log(i, region, quota.Quota?.Value);
if ((quota.Quota?.Value ?? 0) < 1000) {
console.log(`Quota for ${i} ${region} is not 1000!`);
const openCases = await client.send(
new sdk.ListRequestedServiceQuotaChangeHistoryByQuotaCommand({
QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,
ServiceCode: 'lambda',
})
);
const openCase = openCases.RequestedQuotas?.find(
(r) => r.Status === 'CASE_OPENED'
);
if (openCase) {
console.log('already requested, skipping');
continue;
}
await client.send(
new sdk.RequestServiceQuotaIncreaseCommand({
QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,
DesiredValue: 1000,
ServiceCode: 'lambda',
})
);
console.log('requested increase to 1000');
}
}
}
};
execute()
.then(() => process.exit(0))
.catch((err) => {
console.error(err);
process.exit(1);
});