consul/website/content/docs/ecs/deploy/configure-routes.mdx

79 lines
2.3 KiB
Plaintext
Raw Normal View History

Docs/ce 477 dataplanes on ecs (#19010) * updated architecture topic * fixed type in arch diagram filenames * fixed path to img file * updated index page - still need to add links * moved arch and tech specs to reference folder * moved other ref topics to ref folder * set up the Deploy folder and TF install topics * merged secure conf into TF deploy instructions * moved bind addr and route conf to their own topics * moved arch and tech specs back to main folder * update migrate-existing-tasks content * merged manual deploy content; added serv conf ref * fixed links * added procedure for upgrading to dataplanes * fixed linked reported by checker * added updates to dataplanes overview page * Apply suggestions from code review Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com> Co-authored-by: Ganesh S <ganesh.seetharaman@hashicorp.com> * Apply suggestions from code review Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com> Co-authored-by: Ganesh S <ganesh.seetharaman@hashicorp.com> * Apply suggestions from code review Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com> Co-authored-by: Ganesh S <ganesh.seetharaman@hashicorp.com> * Apply suggestions from code review Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com> Co-authored-by: Ganesh S <ganesh.seetharaman@hashicorp.com> * updated links and added redirects * removed old architecture content --------- Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com> Co-authored-by: Ganesh S <ganesh.seetharaman@hashicorp.com>
2023-10-05 14:33:44 +00:00
---
layout: docs
page_title: Configure routes between ECS tasks
description: >-
Learn how to configure routes between tasks after deploying Consul service mesh to your ECS workloads.
---
# Configure routes between ECS tasks
This topic describes how to configure routes between tasks after registering the tasks to Consul service mesh.
## Overview
To enable tasks to call through the service mesh, complete the following steps:
1. Configure the sidecar proxy to listen on a different port for each upstream service your application needs to call.
1. Modify your application to make requests to the sidecar proxy on the specified port.
## Requirements
Consul service mesh must be deployed to ECS before you can bind a network address. For more information, refer to the following topics:
- [Deploy Consul to ECS using the Terraform module](/consul/docs/ecs/deploy/install-terraform)
- [Deploy Consul to ECS manually](/consul/docs/ecs/deploy/install-manual)
## Configure the sidecar proxy
Add the `upstreams` block to your application configuration and specify the following fields:
- `destinationName`: Specifies the name of the upstream service as it is registered in the Consul service catalog.
- `localBindPort`: Specifies the port that the proxy forwards requests to. You must specify an unused port but it does not need to match the upstream service port.
In the following example, the route from an application named `web` to an application named `backend` goes through port `8080`:
```hcl
module "web" {
family = "web"
upstreams = [
{
destinationName = "backend"
localBindPort = 8080
}
]
}
```
You must include all upstream services in the `upstream` configuration.
## Configure your application
Use an appropriate environment variable in your container definition to configure your application to call the upstream service at the loopback address.
In the following example, the `web` application calls the `backend` service by sending requests to the
`BACKEND_URL` environment variable:
```hcl
module "web" {
family = "web"
upstreams = [
{
destinationName = "backend"
localBindPort = 8080
}
]
container_definitions = [
{
name = "web"
environment = [
{
name = "BACKEND_URL"
value = "http://localhost:8080"
}
]
...
}
]
...
}
```