Managing License files for environments

Not so much a PSU problem I don’t think - but interested to hear anyone’s thoughts/ideas.

Just got two shiny new licenses for PSU - intention is that we can have a Dev and Prod layer of our PSU service.

I’ve got a Terraform project which builds out the environments as App Services and configures the built-in Git Sync to point to a repo containing all my PSU source code.

In my head I was going to have the sync for Development go to the Develop branch of my Source repo, and Production go to Main then I can control Production releases with Pull Requests between the branches.

All working absolutely flawlessly with just Dev running at the moment, but I’m now a bit stumped as to how I can apply separate license files for each environment when they’re automatically syncing from git - PRing Develop into Main is going to copy the Development license key. At the moment I think I’m left with a manual step to reapply the correct license in Production after release - it then syncs back up to Git and should be fine until the next release, but it’s not exactly ideal when the rest of the deployment is 100% automated.

Maybe I’ve just got to have two separate source repos and do selective merges from the Development repo to Production with a .gitgnore or something to stop it overwriting the license file?

I think .gitignore is the way to go, that’s what we ended up doing.

edit; wanted to add this is the contents of our .gitignore file, we added schedules as we only want scheduled scripts running from the production environment.

licenses.ps1
schedules.ps1
4 Likes

Just circling back on this as I never did get .gitignore working particularly well.

MASSIVELY overcomplicating things when the license file is written in Powershell!

Solution is to set an environment variable in each environment and use that to choose the license:

If($env:WEBSITE_ENVIRONMENT -eq "PRD"){
    Set-PSULicense [prd details]
}
Elseif($env:WEBSITE_ENVIRONMENT -eq "DEV"){
    Set-PSULicense [dev details]
}

Amazing how simple things are when you’re not trying to make them as difficult as possible. :crazy_face: