Using Terraform to Create a Linux Image with Cloud Watch Agent and Amazon Agent

In this installment of my adventures with Terraform.  I want to spin up an Amazon Linux AMI with the Cloud Watch Agent and the Amazon Agent.

The Cloud Watch Agent will configure the ability to send the logs for the EC2 Instance to Cloud Watch.

The Amazon Agent will enable Amazon Inspector to inspect the instance for security vulnerabilities.

The first step is to create a Terraform script that remotely executes a shell script.

Three parts are required.
This provides the ssh connection info in order to connect to the EC2 Instance.
  connection {
    user        = "${var.INSTANCE_USERNAME}"
    private_key = "${file("${var.PATH_TO_PRIVATE_KEY}")}"
File Provisioner 
This allows us to take an arbitraty files and upload it to the EC2 instance, we could just put all of the scripts in the remote-exec, but that would be ugly.
  provisioner "file" {
    source      = "awscli.conf"
    destination = "/tmp/awscli.conf"

  provisioner "remote-exec" {
    inline = [
      "chmod +x /tmp/",
      "sudo /tmp/",
      "sudo cp /tmp/awscli.conf /etc/awslogs/awscli.conf",
Remote Exec Provisioner
Create a remote ssh session for executing commands on the EC2 Instance.
provisioner "remote-exec" {
    inline = [
      "chmod +x /tmp/",
      "sudo /tmp/",
      "sudo cp /tmp/awscli.conf /etc/awslogs/awscli.conf",
So clearly there is some magic missing.  I mean what am i actually deploying?
For that we go to the Shell Script
First part install the Logging Agent
sudo yum update -y
sudo yum install -y awslogs
sudo service awslogs start
sudo chkconfig awslogs on
Here are the amazon instructions
Second part install the amazon agents
sudo bash install
sudo /etc/init.d/awsagent start
sudo /opt/aws/awsagent/bin/awsagent status
Here are the amazon instructions
When you run terraform apply you get a lot of output.
Now we can jump into amazon inspector, use a filter for a tag and see what we find.

aws_instance.linuxec2 (remote-exec): Total download size: 78 k
aws_instance.linuxec2 (remote-exec): Installed size: 240 k
aws_instance.linuxec2 (remote-exec): Downloading packages:
aws_instance.linuxec2 (remote-exec): (1/2): aws-cli-p |  69 kB     00:00
aws_instance.linuxec2 (remote-exec): (2/2): awslogs-1 | 8.8 kB     00:00
aws_instance.linuxec2 (remote-exec): ----------------------------------------
aws_instance.linuxec2 (remote-exec): Total      436 kB/s |  78 kB  00:00
aws_instance.linuxec2 (remote-exec): Running transaction check
aws_instance.linuxec2 (remote-exec): Running transaction test
aws_instance.linuxec2 (remote-exec): Transaction test succeeded
aws_instance.linuxec2 (remote-exec): Running transaction
aws_instance.linuxec2 (remote-exec):   Installing : aws-cli- [         ] 1/2
aws_instance.linuxec2 (remote-exec):   Installing : aws-cli- [#        ] 1/2
aws_instance.linuxec2 (remote-exec):   Installing : aws-cli- [####     ] 1/2
aws_instance.linuxec2 (remote-exec):   Installing : aws-cli- [#####    ] 1/2
aws_instance.linuxec2 (remote-exec):   Installing : aws-cli- [######   ] 1/2
aws_instance.linuxec2 (remote-exec):   Installing : aws-cli- [######## ] 1/2
aws_instance.linuxec2 (remote-exec):   Installing : aws-cli-plugin-clo   1/2
aws_instance.linuxec2 (remote-exec):   Installing : awslogs- [         ] 2/2
aws_instance.linuxec2 (remote-exec):   Installing : awslogs- [#####    ] 2/2
aws_instance.linuxec2 (remote-exec):   Installing : awslogs- [######   ] 2/2
aws_instance.linuxec2 (remote-exec):   Installing : awslogs- [######## ] 2/2
aws_instance.linuxec2 (remote-exec):   Installing : awslogs-1.1.2-1.10   2/2
aws_instance.linuxec2 (remote-exec):   Verifying  : awslogs-1.1.2-1.10   1/2
aws_instance.linuxec2 (remote-exec):   Verifying  : aws-cli-plugin-clo   2/2

aws_instance.linuxec2 (remote-exec): Installed:
aws_instance.linuxec2 (remote-exec):   awslogs.noarch 0:1.1.2-1.10.amzn1

aws_instance.linuxec2 (remote-exec): Transaction Summary
aws_instance.linuxec2 (remote-exec): ========================================
aws_instance.linuxec2 (remote-exec): Install  1 Package

aws_instance.linuxec2 (remote-exec): Total size: 5.9 M
aws_instance.linuxec2 (remote-exec): Installed size: 5.9 M
aws_instance.linuxec2 (remote-exec): Downloading packages:
aws_instance.linuxec2 (remote-exec): Running transaction check
aws_instance.linuxec2 (remote-exec): Running transaction test
aws_instance.linuxec2 (remote-exec): Transaction test succeeded
aws_instance.linuxec2 (remote-exec): Running transaction
aws_instance.linuxec2 (remote-exec):   Installing : AwsAgent [         ] 1/1
aws_instance.linuxec2 (remote-exec):   Installing : AwsAgent [#        ] 1/1
aws_instance.linuxec2 (remote-exec):   Installing : AwsAgent [##       ] 1/1
aws_instance.linuxec2 (remote-exec):   Installing : AwsAgent [###      ] 1/1
aws_instance.linuxec2 (remote-exec):   Installing : AwsAgent [####     ] 1/1
aws_instance.linuxec2 (remote-exec):   Installing : AwsAgent [#####    ] 1/1
aws_instance.linuxec2 (remote-exec):   Installing : AwsAgent [######   ] 1/1
aws_instance.linuxec2 (remote-exec):   Installing : AwsAgent [#######  ] 1/1
aws_instance.linuxec2 (remote-exec):   Installing : AwsAgent [######## ] 1/1
aws_instance.linuxec2 (remote-exec):   Installing : AwsAgentKernelModu   1/1
aws_instance.linuxec2 (remote-exec):   Verifying  : AwsAgentKernelModu   1/1

aws_instance.linuxec2 (remote-exec): Installed:
aws_instance.linuxec2 (remote-exec):   AwsAgentKernelModule__amzn__4.4.41-36.55.amzn1.x86_64 0:

Here is a link to the github repo with the working code.
Look in the folder ec2instances.

Setting Different Background Images Per Workspace in Ubuntu – 16.10

Lately i have been doing almost all of my Development at home using Ubuntu.

Things I love:

  1. Muliple Workspaces (I can get this in windows, but you can’t do multiple backgrounds)
  2. Visual Studio Code (I love the fact that I can use on any platform)
  3. A good bash shell
  4. I have been doing a lot of stuff with AWS, and for the most part Linux is the ami of choice, so i just needed to get use to it.

Here is what i did to improve Number 1.

In order to be able to differentiate the workspaces it is nice to have a different desktop image per workspaces

I am using Ubuntu 16.10.

Here is the documentation i started with

There seemed to be a bunch wrong, for example the i could not find the compiz-fusion-plugins-extra I found that the compiz-plugins package must have changed name.

Here is what i ended up with

Go into the terminal

sudo apt install compiz-plugins compizconfig-settings-manager

Opened up the Compiz Config Manager, and navigated to wallpaper.

Make sure to Enable the plugin “Enable Wallpaper.

Click on add, and add the four backgrounds.

I then searched for Image Loading and enabled jpeg and png.

I rebooted and voila i had 4 different backgrounds.

It was pretty straightforward once i navigated all of the different versions of documentation.


Introducing Kids to Programming and the Internet of Things

This Christmas I am looking to introduce some of the kids in my family to the world of programming and the Internet of Things.

(Devices that can do stuff, like hit a button and make an LED light up)

I am not 100% where to start, but I am thinking about first starting out with some basic electronics, moving to programming and then combining them.

This is going to be a multi-year process. Since this stuff is not necessarily easy.

Basic Electronics

There is a pretty clear winner out there for starting the journey into electronics.

Snap Circuits SC-300 Electronics Discovery Kit


The snap circuits have won many awards including: The National Parenting Center-Seal of Approval, Dr. Toy 100 Best Children’s Products, Dr Toy Best Educational Products

Basic Programming

  • Scratch
    • Scratch has been around a while and was developed by the MIT Media Lab
    • They have a vibrant community with lots of examples.
    • Developed by Microsoft.
    • They have a partnership with the BBC micro:bit project that is rolling out about a million devices across the UK schools.
    • The video and editor are easy to use.
  • Code Studio This one was is used by and comes with a bunch of great lessons.
    • There is a minecraft themed lesson, that would appeal to a whole lot of kids.
    • There are many very user friendly lessons.

Each programming environment works with various devices. So it important to know which device each works with, to understand the long term capability.

Programming and Devices

The Pi’s


Programming Environment Raspberry Pi 2 arduino
Scratch Great support

You can use scratch on the raspberry pi with no computer.

Touch Develop A bit of work A bit of work
Code Studio

Scratch also works with something called the PicoBoard


It is not a full board and requires a computer to really do anything.

It is a start, but you would end up buying an Arduino or Raspberry Pi if you wanted to do something serious.

Other Devices

I have had a gadgeteer board for a couple of years now.

To be exact it is the FEZ Spider, but it is way more expensive ($149.99) and you are asking a kid or parent to download and setup visual studio.  It can be messy. Before Windows 10 IoT it was really the best option to build and deploy .Net code to a device and watch it run. I will say I am biased towards Microsoft technologies, and that is mainly because I want to be able to provide some guidance and tech support.

My Recommendation is to go with scratch and the raspberry pi.

Raspberry Pi has great support and it ends up to be a computer you can put in your pocket. Plug an Hdmi into and program on your tv.

My Top 5 Strengths


You love to learn. The subject matter that interests you most will be determined by your other themes and experiences, but whatever the subject, you will always be drawn to the process of learning. The process, more than the content or the result, is especially exciting for you. You are energized by the steady and deliberate journey from ignorance to competence. The thrill of the first few facts, the early efforts to recite or practice what you have learned, the growing confidence of a skill mastered—this is the process that entices you. Your excitement leads you to engage in adult learning experiences—yoga or piano lessons or graduate classes. It enables you to thrive in dynamic work environments where you are asked to take on short project assignments and are expected to learn a lot about the new subject matter in a short period of time and then move on to the next one. This Learner theme does not necessarily mean that you seek to become the subject matter expert, or that you are striving for the respect that accompanies a professional or academic credential. The outcome of the learning is less significant than the “getting there.”


You look for areas of agreement. In your view there is little to be gained from conflict and friction, so you seek to hold them to a minimum. When you know that the people around you hold differing views, you try to find the common ground. You try to steer them away from confrontation and toward harmony. In fact, harmony is one of your guiding values. You can’t quite believe how much time is wasted by people trying to impose their views on others. Wouldn’t we all be more productive if we kept our opinions in check and instead looked for consensus and support? You believe we would, and you live by that belief. When others are sounding off about their goals, their claims, and their fervently held opinions, you hold your peace. When others strike out in a direction, you will willingly, in the service of harmony, modify your own objectives to merge with theirs (as long as their basic values do not clash with yours). When others start to argue about their pet theory or concept, you steer clear of the debate, preferring to talk about practical, down-to-earth matters on which you can all agree. In your view we are all in the same boat, and we need this boat to get where we are going. It is a good boat. There is no need to rock it just to show that you can.


Excellence, not average, is your measure. Taking something from below average to slightly above average takes a great deal of effort and in your opinion is not very rewarding. Transforming something strong into something superb takes just as much effort but is much more thrilling. Strengths, whether yours or someone else’s, fascinate you. Like a diver after pearls, you search them out, watching for the telltale signs of a strength. A glimpse of untutored excellence, rapid learning, a skill mastered without recourse to steps—all these are clues that a strength may be in play. And having found a strength, you feel compelled to nurture it, refine it, and stretch it toward excellence. You polish the pearl until it shines. This natural sorting of strengths means that others see you as discriminating. You choose to spend time with people who appreciate your particular strengths. Likewise, you are attracted to others who seem to have found and cultivated their own strengths. You tend to avoid those who want to fix you and make you well rounded. You don’t want to spend your life bemoaning what you lack. Rather, you want to capitalize on the gifts with which you are blessed. It’s more fun. It’s more productive. And, counterintuitively, it is more demanding.


You are inquisitive. You collect things. You might collect information—words, facts, books, and quotations—or you might collect tangible objects such as butterflies, baseball cards, porcelain dolls, or sepia photographs. Whatever you collect, you collect it because it interests you. And yours is the kind of mind that finds so many things interesting. The world is exciting precisely because of its infinite variety and complexity. If you read a great deal, it is not necessarily to refine your theories but, rather, to add more information to your archives. If you like to travel, it is because each new location offers novel artifacts and facts. These can be acquired and then stored away. Why are they worth storing? At the time of storing it is often hard to say exactly when or why you might need them, but who knows when they might become useful? With all those possible uses in mind, you really don’t feel comfortable throwing anything away. So you keep acquiring and compiling and filing stuff away. It’s interesting. It keeps your mind fresh. And perhaps one day some of it will prove valuable.


Your Achiever theme helps explain your drive. Achiever describes a constant need for achievement. You feel as if every day starts at zero. By the end of the day you must achieve something tangible in order to feel good about yourself. And by “every day” you mean every single day—workdays, weekends, vacations. No matter how much you may feel you deserve a day of rest, if the day passes without some form of achievement, no matter how small, you will feel dissatisfied. You have an internal fire burning inside you. It pushes you to do more, to achieve more. After each accomplishment is reached, the fire dwindles for a moment, but very soon it rekindles itself, forcing you toward the next accomplishment. Your relentless need for achievement might not be logical. It might not even be focused. But it will always be with you. As an Achiever you must learn to live with this whisper of discontent. It does have its benefits. It brings you the energy you need to work long hours without burning out. It is the jolt you can always count on to get you started on new tasks, new challenges. It is the power supply that causes you to set the pace and define the levels of productivity for your work group. It is the theme that keeps you moving.

Learned from

My Utility for one user is now deployed across the enterprise

You created a simple Utility to aid in doing your job. You give it to one user, and he/she gives it to someone else. 

Everyone is singing your praises.  Great Job.  I love this app.

Now 30 people have it.  Cracks are appearing, the app is not ready for the load.

People are starting to complain.

You were the hero, now you are constantly defending yourself for an unstable application.


What do you do?

Sell it

  • Get your users to quantify the value.
  • Get Feedback on new features and figure out the value.
  • Estimate the time.
  • Acknowledge the risk (It could 20% more because I don’t understand widgets)
  • Put together a presentation
  • Sell it to people who are willing to pay.
  • Execute.

Developer Resources for Windows 8 and Window Phone 8

Technorati Tags:

Starter Kits

1. Apimash

All kinds of examples of using web services.

Lots of nice UI design.

19 Windows 8 Starter Kits

1 Windows 8.1 Starter Kit

10 Windows Phone 8 Starter Kits

Lots of Sample

More Samples


Windows 8 Libraries that will help with MVVM

1. MvvmLight

2. Obelisk – Persistence Library – Tombstoning and Permanent Persistence

3. Okra App Framework – Navigation Framework


Windows Phone 8 Libraries that will help with MVVM

1. MvvmLight


XAML Spy   – Costs a few bucks, but it is definately worth it.

Just like snoop for wpf.  This works for Windows 8 and Windows Phone 8


The Design Resources for Windows 8 are amazing!!!

Choosing a Cross Platform Mobile Framework for Dummies


There are currently many choices for creating Mobile Applications.

1. You can just create a website.

2. You can create an app in each platform using Native Tools.

3. You can use a Cross-Platform Solution that can reduce the coding necessary to deploy to all platforms.


The ones that I know about are

If you like C# and want to use Visual Studio then Xamarin is the clear choice.

Software Development and The Cycle of Crap


You sit down in front of a legacy application. Maybe something that has a fair bit of complexity.

Do you allow yourself to enter the “This is crap let’s rewrite it” Cycle ?


The “This is crap let’s rewrite it” cycle is simple. The app is in shambles, there are business rules everywhere, you think you understand the app and all of the intricacies. You suggest that rewriting will be simple. It is not.  You run into things…

You now have this


You try to put the worms back in the can. But it involves hacking because you are up against a deadline.

You end up with something better, but will another developer enter into the same cycle?




Things that can save you and others

Humility – You don’t know everything and maybe some of the things are there for a reason

Architecture – Gives you clues on the big picture.

Historical Info – Someone on the project gives you insight on why things are the way they are.

Everyone should drive cars

Lately I have been having more and more discussions on the reasons to not drive an SUV. 

The gas price issue is obvious, but what about the safety concern.

It seems pretty obvious that an SUV is going to be safer just based on the fact that it is heavier.  (force = mass * acceleration)

Here are the fatality stats for SUV vs Cars. They are old but should still be relevant.

Of the 5,259 fatalities caused when light trucks struck cars in 1996

  • 81 percent of the fatally injured were occupants of the car.(9)
  • In multiple-vehicle crashes, the occupants of the car are four times more likely to be killed than the occupants of the SUV.(10) 
  • In a side-impact collision with an SUV, car occupants are 27 times more likely to die.

According to the research the fatality difference is more related to the height than the weight. On average an SUV or light truck rides about 8 inches higher.  That makes them especially deadly in a side impact crash.

 I think the best thing we could do is create some bumper compatibility laws that would even out the safety disparity that is happening.

The saddest part about that suggestion is that they have been looking into regulations like this since 1996.

Instead of doing something they produce documents like the Bumper Q & A, which basically say that they are looking into the issue.

I think for now, I will just raise my bumper a few inches to get the best of both worlds. Safety and fuel economy

Winamp is cooler than Itunes

Over the past 2 years my primary media player has been Itunes. For some reason the other day I thought it would be nice to check out winamp again.

Some of the reason that I like winamp.

1. Smart Views

Beyond just having playlists you can have filtered views.  You can build whatever kind of  query that you want.

Example: audio by Air longer than 4 minutes: type = 0 & artist = “air” & length > 4:00

These are an incredibly powerful way to segregate arrange your music.

2. Audio CDs

You can make audio cd’s from within winamp.  Just drag some songs on the CD and voila and audio cd for your friends.

3. It can sync pretty much any type of media player including ipod.

4. It is winamp and not apple.

Need I say more:)