Search code examples
amazon-web-servicesasp.net-core.net-corecontinuous-integrationaws-code-deploy

How to perform a variable substitution for an appsettings.json file in AWS CodeDeploy?


I spent some time recently seeing if I could get my Azure Devops .NET Core-based pipelines "translated" to AWS CodeDeploy (our web infrastructure is in AWS), but for the life of me I cannot figure out how to update the appsettings.json files with any environment-specific values.

Azure Devops, Bamboo, Octopus, I think even Jenkins and TeamCity support variable substitution on JSON configuration files, but I just cannot figure out how to make that happen in AWS CodeDeploy.

Is there a way to do this? Is there some common workaround that people are using?


Solution

  • I ended up in a fairly lengthy discussion with AWS support (though I was trying to make a feature request) and what came out of it was... AWS CodeDeploy just doesn't support that.

    Now, IMO, this really demonstrates a lack of maturity in the product, and/ or an unwillingness to support traditional .NET Core code bases, but naturally it can't be left like that. So... I built a tool.

    Github now has an open-source project at https://github.com/jholovacs/varsub that allows you to perform a variable substitution on a JSON file using a secure parameter, specifying the path to the property value.

    I hope this saves someone else some headaches.