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.

ECS PlacementConstraint TypeError

See original GitHub issue

I am running troposphere from the latest commit on master. When trying to use ECS PlacementConstraint in a TaskDefinition I get the following error:

TypeError:` <class 'troposphere.ecs.TaskDefinition'>: taskDefinition.PlacementConstraints is <class 'troposphere.ecs.PlacementConstraint'>, expected [<class 'troposphere.ecs.PlacementConstraint'>]

My TaskDefinition looks similar to:

taskDefinition = t.add_resource(TaskDefinition(
    'taskDefinition',
    TaskRoleArn=GetAtt(role, 'Arn'),
    NetworkMode='bridge',
    PlacementConstraints=PlacementConstraint(Type='distinctInstance'),

    ContainerDefinitions=[
        ContainerDefinition(
            Name='service',
            Image=Ref(serviceImage),
            Essential=True,
            MemoryReservation=256,
            PortMappings=[
                PortMapping(
                    ContainerPort=8080,
                    HostPort=80,
                    Protocol='tcp',
                ),
            ],
        ),

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
markpeekcommented, May 8, 2017

There is a comment here that “distinctInstance is not supported in task definitions”. Which might imply it only works with AWS::ECS::Service.

1reaction
markpeekcommented, May 8, 2017

I implemented this today and noticed a discrepancy on whether this is a single PlacementConstraint or a list of PlacementConstraint. I implemented it as a list given the other usage in Service. Also, I have a discussion going with the CF team to verify. Try using:

PlacementConstraints=[PlacementConstraint(Type='distinctInstance')],
Read more comments on GitHub >

github_iconTop Results From Across the Web

Amazon ECS task placement constraints - AWS Documentation
A task placement constraint is a rule that's considered during task placement. ... Amazon ECS supports the following types of task placement constraints:....
Read more >
Unable to import VPC in AWS cdk - python - Stack Overflow
I am trying to create few resources like ECS, SG,LB etc. I want to use default VPC in the resources. Below is my...
Read more >
rusoto_ecs::TaskDefinition - Rust
The IPC resource namespace to use for the containers in the task. The valid values are host , task , or none ....
Read more >
TypeError: ecs.tagResource is not a function | AWS re:Post
Hi, Trying to work out why I cant tag a Running ECS Task via Lambda. I've enabled the new ARNs in ECS. Using...
Read more >
awslabs/aws-cdk - Gitter
__init__(scope, id, **kwargs) task_definition = ecs.Ec2TaskDefinition(self, "API Task", placement_constraints=[ ecs.PlacementConstraint.distinct_instances() ]) ...
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