Skip to content

Commit

Permalink
user_id and wallet_id are passed to autoscsaling custom tags
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Dec 10, 2023
1 parent 3b1333e commit 5ae5e13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from aws_library.ec2.client import SimcoreEC2API
from aws_library.ec2.models import (
AWSTagKey,
AWSTagValue,
EC2InstanceBootSpecific,
EC2InstanceConfig,
EC2InstanceData,
Expand Down Expand Up @@ -69,10 +71,14 @@ async def create_cluster(
tags=creation_ec2_tags(app_settings, user_id=user_id, wallet_id=wallet_id),
startup_script=create_startup_script(
app_settings,
get_cluster_name(
cluster_machines_name_prefix=get_cluster_name(
app_settings, user_id=user_id, wallet_id=wallet_id, is_manager=False
),
ec2_instance_boot_specs,
ec2_boot_specific=ec2_instance_boot_specs,
additional_custom_tags={
AWSTagKey("user_id"): AWSTagValue(f"{user_id}"),
AWSTagKey("wallet_id"): AWSTagValue(f"{wallet_id}"),
},
),
ami_id=ec2_instance_boot_specs.ami_id,
key_name=app_settings.CLUSTERS_KEEPER_PRIMARY_EC2_INSTANCES.PRIMARY_EC2_INSTANCES_KEY_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
from typing import Any, Final

from aws_library.ec2.models import EC2InstanceBootSpecific, EC2InstanceData
from aws_library.ec2.models import EC2InstanceBootSpecific, EC2InstanceData, EC2Tags
from fastapi.encoders import jsonable_encoder
from models_library.api_schemas_clusters_keeper.clusters import (
ClusterState,
Expand Down Expand Up @@ -32,8 +32,10 @@ def _docker_compose_yml_base64_encoded() -> str:

def create_startup_script(
app_settings: ApplicationSettings,
*,
cluster_machines_name_prefix: str,
ec2_boot_specific: EC2InstanceBootSpecific,
additional_custom_tags: EC2Tags,
) -> str:
assert app_settings.CLUSTERS_KEEPER_EC2_ACCESS # nosec
assert app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES # nosec
Expand All @@ -58,7 +60,7 @@ def _convert_to_env_dict(entries: dict[str, Any]) -> str:
f"WORKERS_EC2_INSTANCES_SECURITY_GROUP_IDS={_convert_to_env_list(app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_SECURITY_GROUP_IDS)}",
f"WORKERS_EC2_INSTANCES_SUBNET_ID={app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_SUBNET_ID}",
f"WORKERS_EC2_INSTANCES_TIME_BEFORE_TERMINATION={app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_TIME_BEFORE_TERMINATION}",
f"WORKERS_EC2_INSTANCES_CUSTOM_TAGS={app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_CUSTOM_TAGS}",
f"WORKERS_EC2_INSTANCES_CUSTOM_TAGS={app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_CUSTOM_TAGS | additional_custom_tags}",
f"LOG_LEVEL={app_settings.LOG_LEVEL}",
]

Expand Down

0 comments on commit 5ae5e13

Please sign in to comment.