Open
Description
Current State
Currently, if a user wants to perform an action like a db migration where you:
- Require the roles, privileges, and secrets of the application's main service(s)
- Need to run code or scripts separate from your jobs or services - e.g. management code you don't want to ship in a production image or which needs to run once before deploying
- Want to clean up the resources used for the action after completion
Then the intended flows appears to be either
Using tasks:
- Use
copilot task run --generate-cmd ...
to create a template command from their service's manifest (which may be thousands of characters long depending on the number of secrets - my project's output is nearly 7k characters) - Manually override the correct points of the generated command - most likely the
dockerfile
flag in this case, though possibly also thecommand
flag. - Copy the generated-and-modified command back into your shell and execute.
Using jobs:
- Define a job manifest with
copilot job init
- Set the job's schedule to
none
- Deploy the job with
copilot job deploy
- Run the job with
copilot job run
- Destroy the job resources with
copilot job delete
Proposal
I propose that a more ideal flow would be a job-like manifest that can be executed in a one-off manner like a task. This could work in the following way:
- Define a
manifest.yml
file (perhaps withcopilot task init
orcopilot job init
depending on which concept the team thinks this more closely aligns to). It should have the same variables and secrets as the service but a differenttype
to indicate its one-off nature, such as "Transient Job" or "Task". (Relatedly - this could be further enhanced if [Feature Request] Ability to extend other manifests #3850 were implemented as the task manifest could extend the service manifest and inherit directly the secrets.) - Run with a variation of
copilot task run -a application -e environment taskname
(or maybe-t taskname
to indicate that a task manifest is being used? I would suggest-n taskname
but that flag is already taken by the task group name.)
This has the advantage of keeping the task definition living in a structured yml
format rather than as a shell command that must either be regenerated live or preserved in a script file, while preserving the tidiness and control that you get from the task
concept.
Activity