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
}

 

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. 😀

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