Skip to content

Commit 4bd7017

Browse files
committed
Add multiple stack support (#54)
1 parent cab372a commit 4bd7017

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

bin/mine-cloud.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import * as cdk from 'aws-cdk-lib';
44
import { MineCloud } from '../lib/mine-cloud-stack';
55
import {
66
AWS_ACCOUNT_ID,
7-
AWS_REGION
7+
AWS_REGION,
8+
STACK_NAME
89
} from '../minecloud_configs/MineCloud-Configs';
910

1011
const app = new cdk.App();
11-
new MineCloud(app, 'MineCloud', {
12+
new MineCloud(app, STACK_NAME, {
1213
env: {
1314
account: AWS_ACCOUNT_ID,
1415
region: AWS_REGION // or whatever region you use

lambda/discord_interactions_endpoint/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Context } from 'aws-lambda';
22
import { sign } from 'tweetnacl';
33
import { Lambda } from 'aws-sdk';
4+
import { STACK_PREFIX } from '../../lib/mine-cloud-stack';
45

56
exports.handler = async (event: any, context: Context) => {
67
const PUBLIC_KEY = process.env.PUBLIC_KEY!;
@@ -36,7 +37,7 @@ exports.handler = async (event: any, context: Context) => {
3637
const lambda = new Lambda();
3738
const res = await lambda
3839
.invokeAsync({
39-
FunctionName: 'discord_command_processor_lambda',
40+
FunctionName: `${STACK_PREFIX}_discord_command_processor_lambda`,
4041
InvokeArgs: JSON.stringify(event)
4142
})
4243
.promise();

lib/discord-interactions-endpoint-construct.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class DiscordInteractionsEndpointConstruct extends Construct {
3535
this,
3636
`${STACK_PREFIX}_discord_interactions_endpoint_lambda`,
3737
{
38-
functionName: `discord_interactions_endpoint_lambda`,
38+
functionName: `${STACK_PREFIX}_discord_interactions_endpoint_lambda`,
3939
runtime: Runtime.NODEJS_18_X,
4040
handler: 'index.handler',
4141
entry: path.join(
@@ -53,7 +53,7 @@ export class DiscordInteractionsEndpointConstruct extends Construct {
5353
this,
5454
`${STACK_PREFIX}_discord_command_processor_lambda`,
5555
{
56-
functionName: 'discord_command_processor_lambda',
56+
functionName: `${STACK_PREFIX}_discord_command_processor_lambda`,
5757
runtime: Runtime.NODEJS_18_X,
5858
handler: 'index.handler',
5959
entry: path.join(

lib/mine-cloud-stack.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@ import {
3939
EC2_INSTANCE_TYPE,
4040
MAX_PRICE,
4141
EC2_VOLUME,
42-
EC2_INIT_TIMEOUT
42+
EC2_INIT_TIMEOUT,
43+
STACK_NAME
4344
} from '../minecloud_configs/MineCloud-Configs';
4445
import { Bucket } from 'aws-cdk-lib/aws-s3';
4546
import { getInitConfig } from './instance-init';
4647
import { v4 } from 'uuid';
4748
import { PORT_CONFIGS } from '../minecloud_configs/advanced_configs/port-configs';
4849
import { IGNORE_FAILURE_ON_INSTANCE_INIT } from '../minecloud_configs/advanced_configs/other-configs';
4950

50-
export const STACK_PREFIX = 'MineCloud';
51+
export const STACK_PREFIX = STACK_NAME;
5152

5253
export class MineCloud extends Stack {
5354
readonly ec2Instance;

minecloud_configs/MineCloud-Configs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export const DISCORD_PUBLIC_KEY = '';
77
export const DISCORD_BOT_TOKEN = '';
88
export const DISCORD_CHANNEL_WEB_HOOK = '';
99

10+
// ------------- CloudFormation ------------- //
11+
export const STACK_NAME = 'Minecraft';
12+
1013
// -------------- Server Executable ------------- //
1114
// If set to true, /minecloud_configs/server/server.zip will be deployed
1215
export const DEPLOY_LOCAL_SERVER_EXECUTABLE = false;

0 commit comments

Comments
 (0)