How to inject environment variables into appsettings.json when deploying .Net application to AWS

How do I inject different environment variables like api keys and etc that are stored on appsettings.json based on environment?

i.e. can I use context environment variables to inject/replace them based on which environment we are using into the appsettings.json file? please help