To override environment variables via CLI we may use --overrides (structure) according to AWS ECS Commandline Reference.
How to pass name value pairs (structure or JSON) in command line?
[
{ "name" : "NAME", "value" : "123" },
{ "name" : "DATE", "value" : "1234-12-12" },
{ "name" : "SCRIPT", "value" : "123456" }
]
I'm looking for a way to override above environment variables using AWS ECS CLI. Something like:
aws ecs run-task --overrides <<just environment vars here>> --task-definition ...
Documentation is not clear. I googled but couldn't help.
You have to provide a JSON document as documented under the
--overridesoption.You have to specify the
nameof the container to get the environment override, and specify a list ofenvironmentkey-value pairs.You can specify the JSON document in-line with your argument or pass a file path argument to the task. I will show both ways.
Passing JSON in-line
Your command would look like this (fill in the value
CONTAINER_NAME_FROM_TASK).That does look rather ugly though, and would be annoying to edit. It also only works on Unix-y systems and would require quote escaping in Windows.
So alternatively, you can pass a file path to the AWS CLI and have it load your override JSON from a file.
Passing a file path argument
Create a file, let's call it
overrides.json, and put the same JSON into it:Then, assuming your file is in the current directory:
If your file is elsewhere in the filesystem and you're on a Linux/Unix-y system:
If your file is elsewhere in the filesystem and you're doing this in Windows: