Need Another AWS Change

Between the summer of 2014 and the end of 2018, I wrote solely at tommymaynard.com. As of January 2019, I took it upon myself to step up my game and write exclusively at PowerShell.org -- the center of the PowerShell community. One of the things I was able to do with my personal website over the years, was to help promote change. This, through simple learning for some, but also though reaching out for things I believed we needed.

There was an article I wrote in 2016 where I discussed AWS' (Amazon Web Services) need for an additional EC2 cmdlet. At that time, the Remove-EC2Instance Cmdlet did not exist. To remove an AWS EC2 compute instance -- a virtual server -- the Stop-EC2Instance cmdlet had to be invoked and include its Terminate parameter. Awesome, right? No.

Someone close to the PowerShell work at AWS read, agreed, and saw that a change was made. This was of no great surprise, as AWS is highly customer focused. I've heard several times now that much of what they do is driven by customer interaction and need. As it should be. Here's the Remove-EC2Instance cmdlet, as a part of their AWSPowerShell module.

Today I want to discuss the Get-AWSPowerShellVersion cmdlet. It’s one of those hey-run-this-command-after-you-install-the-module commands, in order to determine if things were installed properly. Here's the default output produced when it's invoked.

I don't think Get-AWSPowerShellVersion is a bad cmdlet. It even provides additional information. Nice, but from here forward is where the cmdlet gets "interesting," and where I think we should see some changes from AWS.

For those of us that have been paying attention to PowerShell, we've all likely been through, or heard, some best practices. One of which is that cmdlets and functions should do one thing, and that one thing well. Additionally, they should only produce a single object type. Simple. The problem with this cmdlet, is that it does more than it should. When Get-AWSPowerShellVersion is invoked with its ListServiceVersionInfo switch parameter, it will return both the version information we saw previously, as well as the AWS Service information. Huh?

As you can see in the above image, this command likely produces two different object types. And, in the below image, it's verified that it does. This shouldn't be happening.

Now, just because this command has been written this way, doesn't mean the cmdlet is of no use when someone wants to filter against the properties in the PSCustomObject -- the services output. I am able to include the ListServiceVersionInfo switch parameter and filter against the Service, the Noun Prefix, and even the API Version dates that are returned. That's nice, but it still just doesn't feel right.

I’m grateful the command can be used this way, but just maybe we can separate the values returned by this cmdlet by using and not using the ListServiceVersionInfo, into more than one command. Keep Get-AWSPowerShellVersion and make it only return the text-based version information (although an object there would be nice, too). Then, create a new cmdlet -- Get-AWSService, perhaps -- that only returns the Service, Noun Prefix, and API Version information. Both invocations of Get-AWSPowerShellVersion provide valuable information; however, I feel as they should do so separately. Additionally, this makes AWS Service discoverability and the matching nouns more difficult to find. It should have its own command; this information shouldn't be buried in a command where it doesn't belong.

About introducing breaking changes, AWS has long added warning messages that a certain switch(es) will be deprecated in future releases, and indicated to instead use new cmdlets. So AWS, if you're listening, let's see that a Get-AWSService Cmdlet is created. And, just maybe we should throw in a couple new aliases for the cmdlet, too. Allow Get-AWSNounPrefix and Get-AWSAPIVersion to invoke Get-AWSService, as well.

In closing, I want to mention how vital it is to be able to find commands within a specific AWS Service using the Noun Prefix property of Get-AWSPowerShellVersion.

Like with Get-Service, let me do this:

PS > Get-AWSService -NounPrefix T*

Instead of this:

PS > Get-AWSPowerShellVersion -ListServiceVersionInfo | Where-Object -Property 'Noun Prefix' -like 'T*'

Also, while we're here, let's lose the spaces between Noun and Prefix, and API and Version. We shouldn't have to delimit our strings because someone allowed for a space in a property name. We should remove the spaces; NounPrefix and APIVersion are fine.

≥ Tommy Maynard (Twitter: @thetommymaynard)

About Tommy Maynard

IT Pro. Passionate for #PowerShell, #AWS (certified x2), & all things automation. I'm not done learning. Author in #PSConfBook. Writes at https://powershell.org.