def METHOD_NAME(self, cluster_type, instance_name):
    if cluster_type == 'ecs':
        from mage_ai.cluster_manager.aws.ecs_task_manager import EcsTaskManager
        instance_payload = self.get_payload().get('instance')
        task_arn = instance_payload.get('task_arn')
        cluster_name = instance_payload.get('cluster_name', os.getenv(ECS_CLUSTER_NAME))
        task_definition = instance_payload.get(
            'task_definition',
            os.getenv(ECS_TASK_DEFINITION),
        )
        container_name = instance_payload.get('container_name', os.getenv(ECS_CONTAINER_NAME))
        action = instance_payload.get('action')
        ecs_instance_manager = EcsTaskManager(cluster_name)
        instance = None
        if action == 'stop':
            instance = ecs_instance_manager.stop_task(task_arn)
        elif action == 'resume':
            instance = ecs_instance_manager.create_task(
                instance_name,
                task_definition,
                container_name,
            )
    self.write(dict(
        instance=instance,
        success=True,
    ))