Tag Archives: Fargate

Remove unneeded characters from ECS / PowerShell cloudwatch logs output

After updating a docker container running on AWS ECS / Fargate, I encountered some erroneous characters in the cloudwatch logs output of the ECS task. When I originally created the dockerfile, the latest version of PowerShell being installed from the Microsoft repo was version 7. The latest container update was running PowerShell 7.2. The amazonlinux container was also updated to the latest version so one of these recent updates within the container had added some leading and trailing characters to the logging output.

Google came up totally empty for me with this one so I am posting this to help out anyone who ends up in the same boat.

The characters showing up in the cloudwatch logs looked like this for the verbose output stream:

[33;1m VERBOSE: Output [0m

And the characters in the standard output stream looked like this:

[32;1m Regular StdOut Output [0m

This line of code added to the top of the script removed all the erroneous characters from the log output.

Fargate / ECS Container Overrides with PowerShell

The other day I needed to launch some one-off Fargate / ECS container tasks with PowerShell. The documentation covered most of what I needed but I could not find any examples on how to override environment variables sent to the container task.

I only needed to change one environment variable so creating a whole new task definition seemed overkill for this purpose. After some trial and error the below code helped me get the job done.

If this helped you out please let me know in the comments. Feedback will motivate me to share solutions on this site more often.