rileydakota/valheim-ecs-fargate-cdk

include target group and load balancer at service creation?

blysik opened this issue · 3 comments

Hi! It looks like if you want to use an application load balancer for a fargate service, it needs to be created when you create the service.

After you create a service, the target group ARN or load balancer name, container name, and container port specified in the service definition are immutable. You cannot add, remove, or change the load balancer configuration of an existing service. If you update the task definition for the service, the container name and container port that were specified when the service was created must remain in the task definition.

Should this be added in some way? Thanks!

Hi @blysik We're working on getting this added right now as an option for you to specify when building out.

Awesome! You all are great. I'll hang tight and wait for it. Bonus points if there's a process to follow from getting to where we are now (no load balancer), to destroying/re-creating with an ALB without losing out data. :)

@blysik we will add that in - the nice thing about the CDK L2 constructs for things that store data is they typically add a DeletionPolicy that will not delete said resource when the stack is deleted. See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html for more info on that. It can easily be done by replacing our code for creating a FileSystem

const serverFileSystem = new efs.FileSystem(this, "valheimServerStorage", {
with something like:

const serverFileSystem = new efs.FileSystem.fromFileSystemAttributes(this, "valheimServerStorage", {
      fileSystemId: 'YOUR_EXISTING_FILESYSTEM_ID,
      securityGroup: fsSecurityGroup,  // will need rewire a few things for this part
    });

We will ideally add some logic to grab this stuff for you if an old template created it