Is it possible at all to use Cloudwatch?Eventbridge rules to schedule an ECS Task passing environment variables for my task definition? I can find multiple examples of those rules calling ecs tasks, but none of them passing environment variables. While on the ECS console we can pass environment variables for our task.
I don’t think it’s doable. At least off the top of my head. As all env vars are set in a task definition. So you’d need to probably write something like a lambda to create/update a task definition and then launch the task from said task definition.
I’ve had good results using (AWS Systems Manager) Parameter Store.
We set an environment variable in the Docker image with the name of the parameter… at run-time, the container gets the current value from Parameter Store.
An alternative that works well for multiple environments is Dotenv-vault.
The set of variables for each environment is encrypted and committed to git. Each environment has a key that allows it to decrypt its own set of variables.
That could work actually I forgot that’s a thing!