-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
65 lines (57 loc) · 3 KB
/
index.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
64
65
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import { McEcsOptions, McEcs } from "./ecs";
import { McLambda, LambdaOptions } from "./lambda";
import { local } from "@pulumi/command";
const config = new pulumi.Config();
const appName = config.require("deploymentId"); // This must be unique in your AWS account
const mcEcsOptions: McEcsOptions = {
image: config.require("image"),
cpu: config.getNumber("cpu"),
memory: config.getNumber("memory"),
useSpotInstance: config.requireBoolean("useSpotInstance"),
serverProperties: {
MODT: config.get("modt") || undefined,
DIFFICULTY: config.require("difficulty") || undefined,
GAME_MODE: config.get("gameMode") || undefined,
ONLINE_MODE: config.get("onlineMode"),
SERVER_NAME: config.get("serverName") || undefined,
MAX_PLAYERS: config.get("maxPlayers") || undefined,
VERSION: config.get("version") || undefined,
RCON: config.get("rcon") || undefined,
ICON: config.get("icon") || undefined,
MAX_WORLD_SIZE: config.get("maxWorldSize") || undefined,
ALLOW_NETHER: config.get("allowNether") || undefined,
ANNOUNCE_PLAYER_ACHIEVEMENTS: config.get("announcePlayerAchievements") || undefined,
ENABLE_COMMAND_BLOCK: config.get("enableCommandBlock") || undefined,
FORCE_GAMEMODE: config.get("forceGamemode") || undefined,
GENERATE_STRUCTURES: config.get("generateStructures") || undefined,
SNOOPER_ENABLED: config.get("snooperEnabled") || undefined,
MAX_BUILD_HEIGHT: config.get("maxBuildHeight") || undefined,
SPAWN_ANIMALS: config.get("spawnAnimals") || undefined,
SPAWN_MONSTERS: config.get("spawnMonsters") || undefined,
SPAWN_NPCS: config.get("spawnNpcs") || undefined,
VIEW_DISTANCE: config.get("viewDistance") || undefined,
LEVEL_SEED: config.get("levelSeed") || undefined,
PVP: config.get("pvp") || undefined,
LEVEL_TYPE: config.get("levelType") || undefined,
RESOURCE_PACK: config.get("resourcePack") || undefined,
RESOURCE_PACK_SHA1: config.get("resourcePackSha1") || undefined,
RESOURCE_PACK_ENFORCE: config.get("resourcePackEnforce") || undefined,
ALLOW_FLIGHT: config.get("allowFlight") || undefined,
CUSTOM_SERVER_PROPERTIES: config.get("customServerProperties") || undefined,
}
}
const mcEcs = new McEcs(appName, mcEcsOptions, {});
const mcTelegramBotOptions: LambdaOptions = {
readinessLogGroup: mcEcs.ecsLogGroup.name.apply(name => name),
ecsClusterName: mcEcs.cluster.name.apply(name => name),
ecsServiceName: mcEcs.service.name.apply(name => name),
}
const mcTelegramBot = new McLambda(appName, mcTelegramBotOptions, {dependsOn: [mcEcs]});
const telegramWebhook = new local.Command("telegram-webhook", {
triggers: [mcTelegramBot.commandHandlerFunctionUrl.functionUrl],
create: pulumi.interpolate `curl --data \"url=${mcTelegramBot.commandHandlerFunctionUrl.functionUrl}\" https://api.telegram.org/bot${process.env.TELEGRAM_API_TOKEN}/setWebhook`
});
export const webhookResult = telegramWebhook.stdout;