From 5a5c3a9917937b5051f710919bd49629ca891f83 Mon Sep 17 00:00:00 2001 From: Ryan Sonshine Date: Wed, 15 Mar 2023 10:08:09 -0400 Subject: [PATCH] feat(eip): add option for adding elastic ip --- server-hosting/config.sample.ts | 2 ++ server-hosting/server-hosting-stack.ts | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/server-hosting/config.sample.ts b/server-hosting/config.sample.ts index b59bac3..78ea8dc 100644 --- a/server-hosting/config.sample.ts +++ b/server-hosting/config.sample.ts @@ -12,6 +12,8 @@ export const Config = { restartApi: true, // Set to true if you want to use Satisfactory Experimental useExperimentalBuild: false, + // Set to true if you want to assign an elastic IP address (EIP) + useEip: false, // optional parameters diff --git a/server-hosting/server-hosting-stack.ts b/server-hosting/server-hosting-stack.ts index d19355b..b588a8a 100644 --- a/server-hosting/server-hosting-stack.ts +++ b/server-hosting/server-hosting-stack.ts @@ -85,6 +85,16 @@ export class ServerHostingStack extends Stack { securityGroup, }) + if (Config.useEip) { + const eip = new ec2.CfnEIP(this, 'IP') + + // Elastic IP reference + new ec2.CfnEIPAssociation(this, 'Association', { + eip: eip.ref, + instanceId: server.instanceId, + }) + } + // Add Base SSM Permissions, so we can use AWS Session Manager to connect to our server, rather than external SSH. server.role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSSMManagedInstanceCore'));