When I use AWS CloudFormation to launch an Amazon ECS service resource (AWS::ECS::Service), I get this error message:

12:21:48 UTC+0100 CREATE_FAILED AWS::ECS::Service ECSService Unable to assume role and validate the listeners configured on your load balancer. Please verify the role being passed has the proper permissions.

The policy associated with the ECS service role lacks sufficient permissions to execute the operation.

If you are using a CloudFormation template to create a ECS service via the “AWS::IAM::Policy” and “AWS::ECS::Service” resource types, the dependency of the service on the policy has not been declared by using the DependsOn attribute. Because CloudFormation creates, updates, and deletes resources in parallel, creating “AWS::ECS::Service” without specifying the dependency on “AWS::IAM::Policy” can cause CloudFormation to attempt to create “AWS::ECS::Service” before the “AWS::IAM::Policy” is ready.