uktrade / fargatespawner

Spawns JupyterHub single user servers in Docker containers running in AWS Fargate
MIT License
47 stars 21 forks source link

Add tag support #7

Closed jwclark closed 4 years ago

jwclark commented 5 years ago

Two new config options:

c.FargateSpawner.ecs_managed_tags = True

c.FargateSpawner.tags = {
    'environment': 'dev'
}

Similar to spawner.environment, tags can also be set in the Authenticator pre_spawn_start method

    @gen.coroutine
    def pre_spawn_start(self, user, spawner):
        spawner.tags['user'] = user.name

or by overriding the new get_tags method in a subclass of FargateSpawner

class MyFargateSpawner(FargateSpawner):
    def get_tags(self):
        task_tags = super().get_tags()
        task_tags['spawner'] = 'MyFargateSpawner'
        return task_tags

One caveat is that AWS only supports tags in ECS once you have opted in to the new ARN format.

michalc commented 5 years ago

Thanks for the PR! I have left a comment/requested changes.

michalc commented 4 years ago

Closing since I believe this is now possible using the latest API added in https://github.com/uktrade/fargatespawner/commit/72b20163825af557f401268a9f7108174e2dd83b