ECS backend

Træfɪk can be configured to use Amazon ECS as a backend configuration:

  1. ################################################################
  2. # ECS configuration backend
  3. ################################################################
  4. # Enable ECS configuration backend
  5. #
  6. # Optional
  7. #
  8. [ecs]
  9. # ECS Cluster Name
  10. #
  11. # Optional
  12. # Default: "default"
  13. #
  14. Cluster = "default"
  15. # Enable watch ECS changes
  16. #
  17. # Optional
  18. # Default: true
  19. #
  20. Watch = true
  21. # Polling interval (in seconds)
  22. #
  23. # Optional
  24. # Default: 15
  25. #
  26. RefreshSeconds = 15
  27. # Expose ECS services by default in traefik
  28. #
  29. # Optional
  30. # Default: true
  31. #
  32. ExposedByDefault = false
  33. # Region to use when connecting to AWS
  34. #
  35. # Optional
  36. #
  37. # Region = "us-east-1"
  38. # AccessKeyID to use when connecting to AWS
  39. #
  40. # Optional
  41. #
  42. # AccessKeyID = "abc"
  43. # SecretAccessKey to use when connecting to AWS
  44. #
  45. # Optional
  46. #
  47. # SecretAccessKey = "123"

Labels can be used on task containers to override default behaviour:

  • traefik.protocol=https: override the default http protocol
  • traefik.weight=10: assign this weight to the container
  • traefik.enable=false: disable this container in Træfɪk
  • traefik.frontend.rule=Host:test.traefik.io: override the default frontend rule (Default: Host:{containerName}.{domain}).
  • traefik.frontend.passHostHeader=true: forward client Host header to the backend.
  • traefik.frontend.priority=10: override default frontend priority
  • traefik.frontend.entryPoints=http,https: assign this frontend to entry points http and https. Overrides defaultEntryPoints.
    If AccessKeyID/SecretAccessKey is not given credentials will be resolved in the following order:

  • From environment variables; AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN.

  • Shared credentials, determined by AWS_PROFILE and AWS_SHARED_CREDENTIALS_FILE, defaults to default and ~/.aws/credentials.
  • EC2 instance role or ECS task role
    Træfɪk needs the following policy to read ECS information:
  1. {
  2. "Version": "2012-10-17",
  3. "Statement": [
  4. {
  5. "Sid": "Traefik ECS read access",
  6. "Effect": "Allow",
  7. "Action": [
  8. "ecs:ListTasks",
  9. "ecs:DescribeTasks",
  10. "ecs:DescribeContainerInstances",
  11. "ecs:DescribeTaskDefinition",
  12. "ec2:DescribeInstances"
  13. ],
  14. "Resource": [
  15. "*"
  16. ]
  17. }
  18. ]
  19. }