Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws: Add support for 'requiresAttributes' in aws_ecs_task_definition #6439

Closed
jeekajoo opened this issue May 2, 2016 · 5 comments
Closed

Comments

@jeekajoo
Copy link

jeekajoo commented May 2, 2016

Terraform Version

v0.6.15

Affected Resource

  • aws_ecs_task_definition

Problem

aws_ecs_task_definition documentation does not tell how to configure requiresAttributes

Example:

  "requiresAttributes": [
    {
      "value": null,
      "name": "com.amazonaws.ecs.capability.logging-driver.fluentd"
    },
    {
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
    }
]

Is it a matter of documentation that is not up-to-date, or is it missing in the api code also?

Thanks

@radeksimko radeksimko changed the title [aws] define "requiresAttributes" in "aws_ecs_task_definition" aws: Add support for 'requiresAttributes' in aws_ecs_task_definition May 3, 2016
@radeksimko
Copy link
Member

Hi,
this field is currently not supported by Terraform - hence it's not documented either.

We'd welcome PRs for adding that field though. It looks like the best way to implement this currently would be via TypeSet rather than TypeMap due to this bug.

@devshorts
Copy link

devshorts commented Jan 5, 2017

@radeksimko does this mean that terraform is strictly bound to docker remote api 1.19? There is a newer ecs version out there and containers placed with terraform won't run on hosts that have a mismatched remote api

Unless I'm misunderstanding what the requires attribute really means, which may be the case. Is it saying it needs a host that has 1.19+?

@radeksimko
Copy link
Member

@devshorts I'm not sure how it's related to this issue exactly, but the ecs_* resources that are part of the AWS provider never talk Docker Remote API - they talk to AWS ECS API which may under the hood use certain version(s) of Docker Remote API, but that's defined on the host/ecs-agent level, not here.

@radeksimko
Copy link
Member

👋 @jeekajoo

I looked into this more deeply to find out that there's no way to specify custom requireAttributes - this was also confirmed by AWS support.

These attributes are for internal use only and they are inferred from some other attributes, e.g. the whole task definition will automatically require com.amazonaws.ecs.capability.logging-driver.awslogs & com.amazonaws.ecs.capability.docker-remote-api.1.19 if you specify the given log driver in any of your container definitions:

[
  {
    "cpu": 256,
    "essential": true,
    "image": "ghost:latest",
    "memory": 512,
    "name": "blablah",
    "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
            "awslogs-group": "myLogGroup",
            "awslogs-region": "eu-west-2"
        }
    }
  }
]

Custom attributes

The only way to assign custom attributes is to use ecs:PutAttributes/ecs:DeleteAttributes which I looked at too. These custom attributes can only be assigned to container instances, which are identifiable via special IDs assigned by ECS agent.

e.g.

arn:aws:ecs:eu-west-2:123456789012:container-instance/3661d311-b286-450f-b42b-98cd6f73d3b0

These IDs vary from the EC2 instance IDs, which is the main reason I decided not to implement hypothetical aws_ecs_attribute resource. ecs:ListContainerInstances doesn't provide a way to look up specific instances via EC2 instance IDs (i-...), so it would not work out of the box even in static (not autoscaled) environments.

Filtering

If you decide to assign custom attributes in user-data/cloud-config scripts or different way, you should be then able to use placement_constraints to restrict where the given TD may run which is supported in the latest release already. See http://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-query-language.html for full syntax.

resource "aws_ecs_task_definition" "service" {
  family = "service"
  container_definitions = "${file("task-definitions/service.json")}"

  placement_constraints {
    type = "memberOf"
    expression = "attribute:stack == prod"
  }
}

I hope it all makes sense - if not, let me know! 😃

@ghost
Copy link

ghost commented Apr 17, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants