How can I update the option propagateTags on an already created ECS service

0 votes

I need to tag all the existing and coming task definitions for a given ECS service. The issue is that I realized that the "PropagateTags" property of the service is set to "NONE" and the tasks definitions do not have the required tags. I attempted to update that property in the console first, but it was not possible. Then, I used the next command:

aws ecs update-service --cluster my-cluster --service my-service --propagateTags  SERVICE --profile "my-profile"

But that didn't work either, because the argument "propagateTags" was not recognized.

My last attempt was using boto3 (API) using the next script:

import boto3

session = boto3.Session(profile_name = 'my-profile', region_name = 'us-east-1')
    
ecs_cluster= 'my-cluster'
ecs_service= 'my-service'

ecs_client=boto3.client('ecs')

response = ecs_client.update_service(
    cluster=ecs_cluster,
    service=ecs_service,
    propagateTags='SERVICE'
)

But, guess what? That didn't work because the API call didn't recognize the tags argument.

Traceback (most recent call last):
  File "./ecs_propagatetags.py", line 16, in <module>
    propagateTags='SERVICE'
  File "C:\Python37\lib\site-packages\botocore\client.py", line 388, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "C:\Python37\lib\site-packages\botocore\client.py", line 681, in _make_api_call
    api_params, operation_model, context=request_context)
  File "C:\Python37\lib\site-packages\botocore\client.py", line 729, in _convert_to_request_dict
    api_params, operation_model)
  File "C:\Python37\lib\site-packages\botocore\validate.py", line 360, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in input: "propagateTags", must be one of: cluster, service, desiredCount, taskDefinition, capacityProviderStrategy, deploymentConfiguration, networkConfiguration, placementConstraints, placementStrategy, platformVersion, forceNewDeployment, healthCheckGracePeriodSeconds, enableExecuteCommand

Any ideas on how I can resolve the issue? Recreating the service is the very last option.

Jan 19, 2023 in AWS by Tejashwini
• 3,820 points

edited 5 days ago 18 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP