question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to tag tasks?

See original GitHub issue

Looking at the code, I see you use codedeploy.createDeployment function which doesn’t doesn’t allow for tagging task that’ll be created like we can do with ecs.runTask…is there a possible approach?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
karanpratapsinghcommented, Oct 1, 2021

Thanks for the detailed answer @Lou1415926 , I ended up doing it with cli. Here’s the script

#!/bin/bash

CLUSTER="$1"
SERVICE="$2"

PLATFORM_TAG="key=platform,value=Fargate"

# Tag new ECS tasks
for ARN in $(aws ecs list-tasks --cluster $CLUSTER --output text --query 'taskArns[*]' --service $SERVICE --no-cli-pager);
do
  echo "Tagging ARN: $ARN with $PLATFORM_TAG"
  aws ecs tag-resource --resource-arn $ARN --tags $PLATFORM_TAG --no-cli-pager;
done
usage: ./tag.sh staging-cluster svc-abc
0reactions
Lou1415926commented, Oct 1, 2021

Hello @karanpratapsingh ! Sorry for the late check-in 🙇🏼‍♀️ !

This action helps you update an existing ECS service with a task definition. As the starting and stopping of a task is controlled by the ECS service that it runs under, the action itself does not have the ability or permission to tag the tasks.

Here are a few suggestions that I have to achieve your goal:

Propagate Tags From Service Or Task Definition

If you specify PropagateTags at the time of your service creation, your tasks can be automatically tagged when it is spun up. This option is available in the AWS console experience, aws-cli, sdk, etc. However, it is only configurable at service creation time.

Tagging The Service

You can also just tag the service, and not the individual tasks. In order to reach the tasks spun up by that service, you can use the ListTasks API. You can tag the service through console, aws-cli, sdk, etc.

Tag Resources Manually

Finally, you can still opt to tag your individual tasks using the tag-resources API. Again, in aws-cli, from AWS console, whichever tools you like to use. This requires you to know the resource ARN, so it might be a bit of churn if you are looking to tag your tasks individually every time they are spun up 😦

You can find more information about tagging ECS resources here as well.

Hope this helps!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add steps, importance, notes, tags, and categories to your tasks
You can quickly see all the tasks, notes, and steps that share a tag by selecting that tag or searching for it in...
Read more >
Evernote Tasks with Tags. Is it possible? (with Brittany Naylor)
Have you ever wished you could add a tag to a task in #Evernote? In today's video, we discuss a great idea that...
Read more >
ClickUp™ | Tags
ClickUp makes adding Tags to tasks as simple as possible, and managing them even easier. Tags are localized to each Space - meaning...
Read more >
Need ability to add tags to tasks - Evernote Forum
In order to be able to view tasks by context without removing it from the project (= note) it would be great to...
Read more >
Add a tag to a task – Asana
Tasks can be multi-homed as subtasks. For example, task A can be in project B and the same task A can also be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found