alphagov / cyber-security-windows-sandbox

Build a windows domain in AWS with terraform with a DC and WEC event forwarding.
MIT License
3 stars 0 forks source link

Look into replacing hard-coded domain ^^^ #5

Closed danjoneslf closed 3 years ago

danjoneslf commented 3 years ago

This is currently hard-coded in a lot of places.

alice-carr commented 3 years ago

Didn't get as far with this as I wanted to today:

danjoneslf commented 3 years ago

There are also a bunch of references in XML files for the forwarder subscriptions and global policy objects. I think probably given the only way to replace those ones is (I think) to template them and populate the domain into a placeholder variable, it's probably easiest to do that for everything. So just iterate over everything in scripts and pass it through something like jinja to move it from a templates location to the scripts location and populate the placeholders.

In terms of how they're used the ec2 terraforms for the DC and WEC instance each have a remote-exec which clones the repo and runs the scripts so I guess the domain would be passed into the remote-exec script as an env var maybe and then we'd have to replace the content of that script with a wrapper script that dealt with the domain and then ran the same tasks.

danjoneslf commented 3 years ago

Given it's just a string replace and we're in PS land it might be better to just do this: https://mcpmag.com/articles/2018/08/08/replace-text-with-powershell.aspx so we don't have to install a python runtime and requirements and whatnot.

danjoneslf commented 3 years ago

Then you could just use Set-Content to overwrite the files in-place.