Reputation: 1317
I have daily cron task in the ECS. Sometimes, I need to run it one-off
manually. Is it possible?
Upvotes: 8
Views: 4090
Reputation: 31
Yes, you can use the CLI to do this. For an ECS Fargate task, it looks like this:
> aws --profile YOUR_IAM_PROFILE ecs run-task --task-definition TASK_DEFINITION --cluster ECS_CLUSTER --network-configuration '{"awsvpcConfiguration":{"subnets":["subnet-SUBNET_ID"],"securityGroups":["sg-SECURITY_GROUP_ID"],"assignPublicIp":"ENABLED"}}' --launch-type FARGATE --propagate-tags TASK_DEFINITION --overrides '{"containerOverrides":[{"name":"YOUR_CONTAINER","command":["YOUR", "CMD", "OVERRIDE", "HERE"]}]}'
You can learn more about the CLI skeleton from here and see the JSON values available for "run-task" using
> aws ecs run-task --generate-cli-skeleton
Upvotes: 3