I am making a call to ecs.create_service
like this:
createServiceResponse = ecs.create_service(
clientToken='abc123',
cluster=options.cluster,
serviceName=options.service,
desiredCount=1,
taskDefinition='relay:' + str(revision),
role='ecsServiceRole',
loadBalancers=[
{
'loadBalancerName': options.elb,
'containerName': 'relay',
'containerPort': 8080
}
]
)
Note that the value in clientToken is abc123
at the moment, but I've tried all sorts of different strings. This document says I need to supply it to ensure idempotency (http://boto3.readthedocs.org/en/latest/reference/services/ecs.html) however I keep getting this error:
Traceback (most recent call last):
File "./deploy.py", line 103, in <module>
'containerPort': 8080
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 301, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 386, in _make_api_call
raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidParameterException) when calling the CreateService operation: Creation of service was not idempotent.
Why ?
I figured it out.
It was because I was calling create_service
on an existing service. I should have been calling update_service
as follows:
ecs.update_service(
cluster=options.cluster,
service=options.service,
taskDefinition='relay:' + str(revision),
desiredCount=1)