4

I have a Django instance running as a Load Balanced Web Service, deployed by AWS Copilot. I would like to run Django Migrations by running a task through Copilot.

I tried running a task like this:

copilot task run --command "python src/manage.py migrate"

However, it doesn't appear to run in my active container. I would expect to see the migrations run, and the service logs along with the updated migrations, but I only see the standard health checks.

copilot/core-api/22 20:07:02 web.1  | INFO:     10.0.1.100:59904 - "GET /healthcheck/ HTTP/1.1" 200 OK
copilot/core-api/22 20:07:17 web.1  | INFO:     10.0.0.117:29060 - "GET /healthcheck/ HTTP/1.1" 200 OK
copilot/core-api/22 20:07:37 web.1  | INFO:     10.0.1.100:59934 - "GET /healthcheck/ HTTP/1.1" 200 OK

Am I misunderstanding task run? I only have 1 app, 1 service, 1 env. I expect task run will be executed in the running service, but maybe it is not?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
drquinn
  • 467
  • 4
  • 16

1 Answers1

3

copilot task run creates a new container. What you are looking for is copilot task exec.

Mark B
  • 183,023
  • 24
  • 297
  • 295
  • Wow this tool is progressing rapidly. `exec` wasn't even in my Copilot CLI version from just a few weeks ago. Updated, this seems to be exactly what I was looking for. Thanks! – drquinn Mar 25 '21 at 21:16
  • 2
    Thanks @drquinn. I work at AWS with the Copilot team, and our goal is to have day one support in Copilot for all the latest ECS features, including the recently launched ECS exec feature. This official AWS blog goes into more detail on using Copilot and ECS exec (https://aws.amazon.com/blogs/containers/connecting-to-an-interactive-shell-on-your-containers-running-in-aws-fargate-using-aws-copilot/) – nathanpeck Mar 26 '21 at 16:27