1

I'm deploying an express gateway to Amazon ECS container, I'm trying to figure out what is the best way to override the serviceEndpoint part if the gateway.config.yml since service URLs are obviously different.

I need to change this

serviceEndpoints:
  user:
    url: 'http://localhost:3001'
  auth:
    url: 'http://localhost:3004'
  customer:
    url: 'http://localhost:3002'

to this:

serviceEndpoints:
  user:
    url: 'http://user.service:3001'
  auth:
    url: 'http://auth.service:3004'
  customer:
    url: 'http://customer.sevice:3002'

and so forth.

I asume I could maintain 2 copies of the config file and swap them in Docker build but I asume this is not the best alternative, implementing service discovery, I asume, would be another choice.

Any ideas?

TIA!

FMQ
  • 418
  • 3
  • 14

1 Answers1

1

I found the solution, the config now uses ENVIRONMENT variables as:

serviceEndpoints: user: url: 'http://${USER_SERVICE:-localhost}:${USER_SERVICE_PORT:-3001}' auth: url: 'http://${AUTH_SERVICE:-localhost}:${AUTH_SERVICE_PORT:-3004}' customer: url: 'http://${CUSTIMER_SERVICE:-localhost}:${CUTOMER_SERVICE_PORT:-3002}'

and everything works.

Regards.

FMQ
  • 418
  • 3
  • 14
  • I don't know why, but I had to use dotenv for express-gateway to see my .env variables. ```import dotenv from 'dotenv';``` ```dotenv.config();``` – PAT-O-MATION Jun 15 '21 at 06:18