Skip to content

Commit

Permalink
Add multiple stack support (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
314pies committed May 22, 2023
1 parent cab372a commit 4bd7017
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions bin/mine-cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import * as cdk from 'aws-cdk-lib';
import { MineCloud } from '../lib/mine-cloud-stack';
import {
AWS_ACCOUNT_ID,
AWS_REGION
AWS_REGION,
STACK_NAME
} from '../minecloud_configs/MineCloud-Configs';

const app = new cdk.App();
new MineCloud(app, 'MineCloud', {
new MineCloud(app, STACK_NAME, {
env: {
account: AWS_ACCOUNT_ID,
region: AWS_REGION // or whatever region you use
Expand Down
3 changes: 2 additions & 1 deletion lambda/discord_interactions_endpoint/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Context } from 'aws-lambda';
import { sign } from 'tweetnacl';
import { Lambda } from 'aws-sdk';
import { STACK_PREFIX } from '../../lib/mine-cloud-stack';

exports.handler = async (event: any, context: Context) => {
const PUBLIC_KEY = process.env.PUBLIC_KEY!;
Expand Down Expand Up @@ -36,7 +37,7 @@ exports.handler = async (event: any, context: Context) => {
const lambda = new Lambda();
const res = await lambda
.invokeAsync({
FunctionName: 'discord_command_processor_lambda',
FunctionName: `${STACK_PREFIX}_discord_command_processor_lambda`,
InvokeArgs: JSON.stringify(event)
})
.promise();
Expand Down
4 changes: 2 additions & 2 deletions lib/discord-interactions-endpoint-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class DiscordInteractionsEndpointConstruct extends Construct {
this,
`${STACK_PREFIX}_discord_interactions_endpoint_lambda`,
{
functionName: `discord_interactions_endpoint_lambda`,
functionName: `${STACK_PREFIX}_discord_interactions_endpoint_lambda`,
runtime: Runtime.NODEJS_18_X,
handler: 'index.handler',
entry: path.join(
Expand All @@ -53,7 +53,7 @@ export class DiscordInteractionsEndpointConstruct extends Construct {
this,
`${STACK_PREFIX}_discord_command_processor_lambda`,
{
functionName: 'discord_command_processor_lambda',
functionName: `${STACK_PREFIX}_discord_command_processor_lambda`,
runtime: Runtime.NODEJS_18_X,
handler: 'index.handler',
entry: path.join(
Expand Down
5 changes: 3 additions & 2 deletions lib/mine-cloud-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ import {
EC2_INSTANCE_TYPE,
MAX_PRICE,
EC2_VOLUME,
EC2_INIT_TIMEOUT
EC2_INIT_TIMEOUT,
STACK_NAME
} from '../minecloud_configs/MineCloud-Configs';
import { Bucket } from 'aws-cdk-lib/aws-s3';
import { getInitConfig } from './instance-init';
import { v4 } from 'uuid';
import { PORT_CONFIGS } from '../minecloud_configs/advanced_configs/port-configs';
import { IGNORE_FAILURE_ON_INSTANCE_INIT } from '../minecloud_configs/advanced_configs/other-configs';

export const STACK_PREFIX = 'MineCloud';
export const STACK_PREFIX = STACK_NAME;

export class MineCloud extends Stack {
readonly ec2Instance;
Expand Down
3 changes: 3 additions & 0 deletions minecloud_configs/MineCloud-Configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export const DISCORD_PUBLIC_KEY = '';
export const DISCORD_BOT_TOKEN = '';
export const DISCORD_CHANNEL_WEB_HOOK = '';

// ------------- CloudFormation ------------- //
export const STACK_NAME = 'Minecraft';

// -------------- Server Executable ------------- //
// If set to true, /minecloud_configs/server/server.zip will be deployed
export const DEPLOY_LOCAL_SERVER_EXECUTABLE = false;
Expand Down

0 comments on commit 4bd7017

Please sign in to comment.