doctorray117 / minecraft-ondemand

Templates to deploy a serverless Minecraft Server on demand in AWS
Apache License 2.0
1.71k stars 118 forks source link

Reusing Hosted Zone #51

Open DeltaScratchpad opened 2 years ago

DeltaScratchpad commented 2 years ago

Hello, Can you advise on how the hosted zone could be reused for multiple instances (i.e. define in a outer stack and share to multiple sub-stacks) or how an existing HZ should be used in it's place (via lookup).

I would like to run multiple servers and would like to avoid paying HZ fees for every instance, when it may be possible to have them all under different sub-sub domains under a common HZ.

Thank you for any guidance you can give

doctorray117 commented 2 years ago

At first glance, I think you could accomplish this in cdk/lib/domain-stack.ts by commenting out the subdomainHostedZone creation (line 71-78, line 82-89) and swapping out the further references to subdomainHostedZone with rootHostedZone (line 81, 106, 110, 154). It's unclear to me exactly if the cloudwatch policy would apply correctly (line 81) with the rootHostedZone, but it probably would.

@ryansonshine would this be the right approach for running multiple stacks without multiple hosted subzones?

ryansonshine commented 2 years ago

At first glance it looks like you might be able to get away with doing a lookup instead of creating new by changing this to something like:

    const subdomainHostedZone = route53.HostedZone.fromHostedZoneId(
      this,
      'SubdomainHostedZone',
      '<your hosted zone id here>'
    );

I ended up taking an entirely different approach for handling multi-instance in the library I'm working on that resulted in shuffling quite a bit around so I'm not sure if @DeltaScratchpad will run into any issues but its worth a shot.