AWS and PowerShell Core

Quick script to automatically updated my AWS access ID and secret

#setup
#set-psrepository psgallery -installationpolicy Trusted
#install-module AWSPowerShell.NetCore -scope currentuser -AllowClobber -force
import-module AWSPowerShell.NetCore
$profilename = 'ohyeah'
# Initialize-AWSDefaultConfiguration -region us-west-2 -AccessKey $x -SecretKey $y
Initialize-AWSDefaultConfiguration -ProfileName $profilename
$keys = get-iamaccesskey
if(($keys | measure-object).count -gt 1) { "Two keys already exist, must delete one first" | out-host}
elseif(($keys|measure-object).count -eq1)
{
    "One key exists, ready to switch" | out-host
    $newkey=new-iamaccesskey
    Set-AWSCredential -AccessKey $newkey.AccessKeyId -SecretKey $newkey.SecretAccessKey -StoreAs $profilename
    Initialize-AWSDefaultConfiguration -profileName $profilename
    Remove-IAMAccessKey -AccessKeyId $keys.AccessKeyId -passthru -force # old key
}

 

What’s Wireless “mesh”?

Eero, similar devices, how they work, and why I decided to jump into the deep end of this tech. What is a wireless mesh? In simpler terms, it consists of multiple wireless devices working together (instead of a network extender, which connects to another wireless base station, and acts as a “helper” to get packets to a farther away device) to understand where the internet is and how best to get your packets from your device to the internet. Most wireless extenders that I’ve tried, usually halve the internet bandwidth to account for getting packets to/from the base station. Mesh devices, such as eero, connect together in a more intelligent way to understand where the devices are and routes packets from devices in a much faster way. My understanding is that when the mesh is set up, where the mobile device is, it connects to the closest access point and that access point knows how best to route traffic to the internet (either another AP or the base station, whichever is closest). Wireless extenders only know how to route traffic to the base station which sounds like it would be fastest, but not in every situation since half of the bandwidth is still consumed by extender-to-base-station traffic internally. Eeros cut down on that since they remember the fastest route to the internet. In my experience, having a couple of these devices in my condo, I get near gigabit speeds to my ISP from my Macbook Pro over wireless 802.11ac. Before with one access point and an extender, I might get 20-30Mbps. For me at least, mesh creates a more stable and reliable wireless network/internet connection without having the need to “reboot the router” every week or month. Other companies like Google, Luna, and Netgear also make wireless mesh products.

Making the switch from Android to iPhone

Earlier this year I made the switch from an Android based phone (Google Pixel XL) over to an Apple iPhone 7 Plus. Why? Well let me give you a history of some of the devices I’ve had first for a less biased view.

I started with an Ericsson AF738 flip phone back in 1996. Small and compact flip phone that fit in my pocket. Most students had pagers in high school, which required someone to call a number and leave a numerical message which then got sent to the pagers, then those people would call the senders back. My cell phone (which on AT&T had a 20 minute per month voice plan), was more than enough to let my family and friends know that I was running late on my way home, or that I was going somewhere after school. In many senses, it was my digital leash which allowed me more freedom than most.

Once in college, I decided an upgrade was needed and I got a Nokia 5160. I had a few more candybar style and flip phones until I bought my first PalmOS based device which combined my calendar and contacts with notes. Treo 600/650 were devices based on PalmOS, and the 650 was one of the first on Sprint’s network at the time to allow text messaging. After that, a Windows Phone, the Pocket PC PPC6601 slider with a keyboard was now my primary phone. It was useful and fun, but large.

After college, I moved up to Redmond, WA to work at Microsoft. I drank some of the Kool-aid and had some more Windows-based phones (Pocket PC, Windows Mobile, Windows Phone, etc.) until my first iPhone. I then had some reception issues where I lived at the time, and found that switching networks and switching to a new Motorola Droid on Verizon worked better for me at the time. I stuck with mostly Android phones up until this year, when I found that iPhones might be a worthwhile switch again for what I needed.

So… I switched to the iPhone 7 plus, picked up an iPad, Airpods, Apple TV, and some other Apple goodies. I still have Windows workstations and my passion for technology hasn’t changed. Best tool for the job, but why iPhone? It does what I need it to for now, allows me to iMessage with my friends and family, and my data just goes where it needs to when I need it. Will I switch again? Perhaps. Is Android dead? Absolutely not, and it keeps pushing the other player(s) in the mobile space to get better, including Apple. The new Apple Watch Series 3 with LTE is pretty neat, and definitely works well making phone calls and data.

My story so far…

People at a recent summit were asking a bit about my story, what did I do besides helping with the summit, technical background, etc.

Well, short version. College at Oregon Tech, contracted at Microsoft on the Exchange Mailbox team and tested the first versions of the Monad/PowerShell cmdlets for Exchange, then System Center Configuration Manager testing deployments, then a few years in SharePoint/SharePoint Designer for the 2010 release. Hopped over to Expedia, learned Splunk, and now I work at Splunk as a software engineer. I work on deployments, Microsoft related things, Python, Ansible, Cloud (AWS), Apps, Testing methodologies and a ton of other things.

PowerShell Summit 2017

So this week, was the annual PowerShell Summit in Bellevue, WA. I think the number was around 230 attendees, not including speakers. So many smart and funny people around the world came to one place to hear what Microsoft and the community are doing next with PowerShell Core (6.0), technologies and companies working with Powershell, DevOps in general, and solving solutions.

PowerShell Summit

What did I get from it as a developer? Besides spending time with friends in the industry, I was able to meet people like Jeffrey Snover, Lee Holmes, and Bruce Payette. Meeting up with friends like Don Jones, Jason Helmick, Missy Januszko (@thedevopsdiva), Jeff Hicks, Richard Siddaway, Steve Murawski (Chef) and so many others I’ve met over the years, the conversations gave me inspiration and ideas for how I can not only make my personal projects better and more efficient, but also help with solutions to problems I didn’t yet know I had!

Now the meat of the story. Ansible, Python, and virtualenvs have been my life lately, and after talking to some guys at AWS, the awspowershell module sounds like it would simplify my personal dev workflow. 😀

Git Squashing, what’s going on here?

So, being a beginner to git and its associated commands and check ins, I needed a way of “squashing” the 15 or so check ins into one so others can see one checkin versus my save-a-holic-ness. I save a lot, whether it’s video games or code, and that includes commits to my local history. Squashing is combining commits into fewer to make the history much more readable. How does one squash their commits? With this magic command.

git rebase -i HEAD~3

This is what it does. The rebase command basically rewrites the local history (make sure you’ve not pushed to a remote repo though! You don’t want to mess up history for others) The -i makes it interactive, usually opening in your local editor or vi as a default for most OSes, and yes this includes Windows if you’ve installed git on Windows with the bash shell. The HEAD~3 part (no spaces between HEAD and ~3 though, and that is the tilde character before the 3), takes the local head and goes down 3 commits. Change the entries to “squash” and include in the check in.

Before
After

After that, “:wq” to write the changes if using vi, git commit and merge with your upstream repo.

The Google search results in a simpler explanation: “ Use git rebase -i <after-this-commit> and replace “pick” on the second and subsequent commits with “squash” or “fixup”, as described in the manual.”

Run pytest inside of a Nano Server Container on Win10

Work in progress, but this is what I’ve got so far. I’ve been wanting to run small workloads in isolated environments that are repeatable and identical.

This is my Dockerfile, on my Win10 workstation, but customize to your environment and requirements as necessary for use. Windows Server 2016 Core is a little overkill, but I haven’t got all the necessary software running on Nano Server yet.

FROM microsoft/windowsservercore
# Because why not?
# Build docker image: docker build -t jeff1 .
# Run docker image: docker run -it jeff1 powershell
WORKDIR /test
# Install Chocolatey for package installs
RUN powershell -c "iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex"
RUN choco install -y python2
RUN powershell -command [Environment]::SetEnvironmentVariable('PYTHONIOENCODING','utf-8','User')
RUN pip install --upgrade pip pytest paramiko boto
# This requires Administrator privileges, so leaving out for now
#RUN powershell -command "install-module pswindowsupdate -force;import-module -Name pswindowsupdate;Get-WUInstall -MicrosoftUpdate -IgnoreUserInput -AcceptAll"
RUN choco install -f -y --allow-empty-checksums strawberryperl vcpython27 curl git.install jdk8 openssh wixtoolset
# Placeholder for Windows Driver requirements
# git clone <git repo>
#RUN pytest <git repo>/test_foo.py

OpenStack idea

So I keep hearing about OpenStack, but I don’t have a ton of physical machines laying around. Looking at http://docs.openstack.org/developer/devstack/guides/single-machine.html for some initial work, then I’ll move on to multiple VMs on my VM host. What I’d like to do, is be able to spin up an environment quickly, easily, using OpenStack for some of the work I’ve been doing. I’ve used AutomatedLab (https://github.com/AutomatedLab/AutomatedLab) on Hyper-V before, as well as the new Containers feature of Windows Server 2016, but I want to learn about how others use virtualization and management tools in order to scale up/out their infrastructure and services.