Reading connect secrets from environment variables


I saw this great blog post on how to read connect sensitive information from a file.
Is there any way to read this info from environment variables?
I want to fetch the information from AWS SSM that has a great integration with AWS ECS for injecting the information as environment variables.
If I can’t use environment variables, do I need to add the secrets file into the docker image?