Migrate Existing Tasks

    Your tasks must first be specified in Terraform using the ecs_task_definition resource so that they can then be converted to use the .

    For example, your tasks should be defined with Terraform similar to the following:

    The mesh-task module uses inputs similar to your old ECS task definition but creates a new version of the task definition with additional containers.

    The mesh-task module is used as follows:

    1. module "my_task" {
    2. source = "hashicorp/consul/aws-ecs//modules/mesh-task"
    3. version = "<latest version>"
    4. family = "my_task"
    5. container_definitions = [
    6. {
    7. name = "example-client-app"
    8. essential = true
    9. {
    10. containerPort = 9090
    11. hostPort = 9090
    12. protocol = "tcp"
    13. }
    14. ]
    15. cpu = 0
    16. mountPoints = []
    17. volumesFrom = []
    18. ]
    19. port = "9090"
    20. }
    • You must remove the execution_role_arn and task_role_arn fields. The mesh-task module will create the task and execution roles.
    • You must set the port field to the port that your application listens on. If your application has no listening port, set outbound_only = true and remove the port field.
    • You must add the retry_join field. This specifies the location of your Consul servers so that your task can join the mesh.
    • You must remove the jsonencode() function from the container_definitions field.

    The mesh-task module will create a new version of your task definition with the necessary sidecar containers added so you can delete your existing aws_ecs_task_definition resource.

    Now that your task(s) are migrated to the mesh-task module,

    • Start at the ECS Service section of the Installation Guide to continue installing Consul on ECS.
    • Refer to the for all available inputs to your mesh tasks.