This is the fourth installment of this series. I never thought I’d write another article about it and yet, here I am. One thing before we recap, I’m breaking this fourth installment into two parts: a and b. It’s too much to read at once. Well, it might be for me at least, if I wasn’t the one writing it. The link for Part b is at the bottom of this post.
This series of articles began in 2017 when I wrote exclusively at https://tommymaynard.com. First, I’ll explain what each article brought to this series. Then, I’ll discuss the newest changes — the purpose of this fourth article. You know how it goes, though. You get a chance to see your old code, and you almost immediately find things you would’ve done differently. That’s what this is partially about. That and the fact that I may use this framework again here soon.
When you provision a new Windows virtual server (an EC2 Instance) in AWS, or Amazon Web Services, you get an option to run batch and/or PowerShell against the instance at first launch. This allows you, by default, a one-time shot to configure your server as you see fit. In my AWS UserData Multiple Run Framework, you’ve long been able to configure an instance multiple times between multiple restarts. Follow along, as I quickly catch you up and introduce the changes. This is partially due to how AWS has changed things from Server 2012 R2 and earlier, and Server 2016 and later. There’s also some of that traditional code clean up, to which I eluded, and the addition of new features, as well.
In the first article, I introduced the AWS UserData Multiple Run Framework. It used text files, stored at the root of the C:\ drive, to determine where in the UserData code it should proceed after each restart.
In the second article, I picked up where the first one left off. This article was the first one to include code to create the code that would be used in the EC2 instance’s UserData. It was, and still is, PowerShell creating PowerShell. It still used text files, as it ran each code section against the server.
In the third article, things changed. Here I introduced using the Windows Registry to maintain what had and hadn’t yet been run in UserData. Additionally, I included an updated New-AWSMultiRunTemplate (as you’ll see, the name has changed) function to create the UserData code. As stated in that article and above, this isn’t the code you place inside the UserData section — it’s the code that creates the code you place inside the UserData section. It’s an important distinction.
In this fourth article — as you’ll see in part b — I’ve added and corrected a good deal. I’ve made additions, removals, and changes in both the function that produces the UserData code and within the UserData produced code, as well. In part b we’ll do a quick rundown on the modifications I remember making. Then, we’ll include and invoke our code producing code. Following that, we’ll cover the produced code for those unfamiliar with this project. This is backwards from the previous articles; however, it’s more of a logical flow for moving forward.
≥ Tommy Maynard (Twitter: @thetommymaynard)