Last active
March 6, 2025 19:24
-
-
Save trusek-amzn/18e53c2626c5adc7cff4e3a02f93cb52 to your computer and use it in GitHub Desktop.
CDK Fun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_task_definition(ecs_client, task_def_name_prefix): | |
paginator = ecs_client.get_paginator('list_task_definitions') | |
for page in paginator.paginate(): | |
for arn in page['taskDefinitionArns']: | |
if task_def_name_prefix in arn: | |
return arn.split('/')[-1] | |
raise ValueError(f"No task definition found with prefix: {task_def_name_prefix}") | |
with open(f'{sys.argv[1]}/config.yaml') as config_file: | |
config = yaml.safe_load(config_file) | |
ecs_client = boto3.client('ecs') | |
task_def_name_prefix = f"{sys.argv[1]}-task-def" | |
task_def_name = find_task_definition(ecs_client, task_def_name_prefix) | |
task_def = ecs_client.describe_task_definition( | |
taskDefinition=task_def_name | |
)['taskDefinition'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment