Skip to content

Instantly share code, notes, and snippets.

@LMnet
Created January 14, 2024 19:59
Show Gist options
  • Save LMnet/1bcbaba0e00f55c40f0b4e05b2312fae to your computer and use it in GitHub Desktop.
Save LMnet/1bcbaba0e00f55c40f0b4e05b2312fae to your computer and use it in GitHub Desktop.
@dataclass
class InstanceGroups:
master_nodes: Ec2InstancesGroup
core_nodes: Ec2InstancesGroup
@dataclass
class InstanceFleets:
config: list[dict[str, any]]
subnets: set[KnownEc2Subnets]
Instances = InstanceGroups | InstanceFleets
match instances:
case InstanceGroups(master_nodes, core_nodes):
instances_config = common_instances_config | {
'InstanceGroups': [
{
'Name': "Master nodes",
'InstanceRole': 'MASTER',
} | master_nodes,
{
'Name': "Slave nodes",
'InstanceRole': 'CORE',
} | core_nodes,
],
'Ec2SubnetId': KnownEc2Subnets.InternalPrivateSubnet1a.value,
}
case InstanceFleets(config, subnets):
instances_config = common_instances_config | {
'InstanceFleets': config,
'Ec2SubnetIds': [subnet.value for subnet in subnets],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment