generated from remotion-dev/template-next-app-dir
-
Notifications
You must be signed in to change notification settings - Fork 70
/
deploy.ts
63 lines (58 loc) · 1.73 KB
/
deploy.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 {
deployFunction,
deploySite,
getAwsClient,
getOrCreateBucket,
getRegions,
} from "@remotion/lambda";
import dotenv from "dotenv";
import path from "path";
import { RAM, SITE_NAME, TIMEOUT } from "./src/config";
import { getAccountCount } from "./src/helpers/get-account-count";
import { setEnvForKey } from "./src/helpers/set-env-for-key";
dotenv.config();
const count = getAccountCount();
console.log(`Found ${count} accounts. Deploying...`);
for (let i = 2; i <= count; i++) {
for (const region of getRegions()) {
setEnvForKey(i);
console.log(`Deploying to ${region} in account ${i}`);
const { functionName, alreadyExisted } = await deployFunction({
createCloudWatchLogGroup: true,
memorySizeInMb: RAM,
timeoutInSeconds: TIMEOUT,
region,
});
console.log(
` ${
alreadyExisted ? "Ensured" : "Deployed"
} function "${functionName}" to ${region} in account ${i}`,
);
const { bucketName } = await getOrCreateBucket({ region });
const { serveUrl } = await deploySite({
siteName: SITE_NAME,
bucketName,
entryPoint: path.join(process.cwd(), "remotion/index.ts"),
region,
});
const { sdk } = getAwsClient({ region, service: "s3" });
await getAwsClient({ region, service: "s3" }).client.send(
new sdk.PutBucketCorsCommand({
Bucket: bucketName,
CORSConfiguration: {
CORSRules: [
{
AllowedHeaders: ["*"],
AllowedMethods: ["GET", "HEAD"],
AllowedOrigins: ["*"],
MaxAgeSeconds: 3000,
},
],
},
}),
);
console.log(
` Deployed site to ${region} in account ${i} under ${serveUrl}`,
);
}
}