Selecting an AWS subnet by name in Terraform

One of my recent challenges has been to write tf code to select existing subnets and use them in new blocks of code (specifically in this case to create a Directory, Workspaces and add a few Security Group entries). Since I am relatively new to using Terraform to do this it took far longer to figure out than I would care to say and I figured it would be best to document what finally worked and had the concept click for me in my mind.

provider "aws" {
  region = "us-east-1"
variable "subnet_name" {
  default = "workspaces-private-us-east-1c"
data "aws_subnet" "selected" {
  filter {
    name = "tag:Name"
    values = ["${var.subnet_name}"]

output "vpcid" {
  value = "${data.aws_subnet.selected.vpc_id}"

output "subnet_name" {
  value = "${var.subnet_name}"
output "subnet_id" {
  value = "${}"

This will look up the named subnet “workspaces-private-us-east-1c” and obtain not only the VPC ID associated with it but the unique subnet id as well, the output should look something like the below sample provided the name you are looking up is unique

data.aws_subnet.selected: Refreshing state...

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.


subnet_id = subnet-0299e079c90b20ea6
subnet_name = workspaces-private-us-east-1c
vpcid = vpc-04066bef0a56ebcc2

This is of course specific to things as of Terraform 0.12.20 and 2.48.0 so naturally things may change over time, however this will get you close and provide you enough of a starting point to use these subnets in other things.

On the Road: Chicago

Not too shabby of a view

So I find myself on the road in Chicago as of Sunday, doing a round of technical interviews in my effort to take the next step in my career progression. Not a very long stay but the view from my hotel room at night was great, really captured the feel of the city at night I think. As much as I miss being at home and sleeping in my own bed I kind of wish I could have at least one more day if only to take a trip to a few landmarks and hit up a nearby fountain pen shop.

New Digs

So I am moving and took the opportunity to change my desk setup to something a lilttle more focused from my previously insane configuration. Behold an actual matched pair of 24″ screens on a mount where I will hopefully be churning out all sorts of new projects (like YeRP – Yet another Ripping Portal that uses flask and youtube-dl to present a mobile friendly interface.

Patching CentOS 7 (and overcoming problems)

So I was working on patching some of my Icinga infrastructure at work, and it seems that sometimes libyajl breaks things, as illustrated below

root@icingasatellite ~]# yum update
Loaded plugins: fastestmirror, rhnplugin
This system is receiving updates from RHN Classic or Red Hat Satellite.
Loading mirror speeds from cached hostfile

  • epel:
    Resolving Dependencies
    --> Running transaction check
    ---> Package icinga2.x86_64 0:2.10.4-1.el7.icinga will be updated
    ---> Package icinga2.x86_64 0:2.10.5-1.el7.icinga will be an update
    ---> Package icinga2-bin.x86_64 0:2.10.4-1.el7.icinga will be updated
    ---> Package icinga2-bin.x86_64 0:2.10.5-1.el7.icinga will be an update
    --> Processing Dependency: for package: icinga2-bin-2.10.5-1.el7.icinga.x86_64
    Traceback (most recent call last):
    File "/bin/yum", line 29, in
    yummain.user_main(sys.argv[1:], exit_code=True)
    File "/usr/share/yum-cli/", line 375, in user_main
    errcode = main(args)
    File "/usr/share/yum-cli/", line 239, in main
    (result, resultmsgs) = base.buildTransaction()
    File "/usr/lib/python2.7/site-packages/yum/", line 1198, in buildTransaction
    (rescode, restring) = self.resolveDeps()
    File "/usr/lib/python2.7/site-packages/yum/", line 893, in resolveDeps
    CheckDeps, checkinstalls, checkremoves, missing = self._resolveRequires(errors)
    File "/usr/lib/python2.7/site-packages/yum/", line 1025, in _resolveRequires
    (checkdep, missing, errormsgs) = self._processReq(po, dep)
    File "/usr/lib/python2.7/site-packages/yum/", line 350, in _processReq
    CheckDeps, missingdep = self._requiringFromTransaction(po, requirement, errormsgs)
    File "/usr/lib/python2.7/site-packages/yum/", line 680, in _requiringFromTransaction
    File "/usr/lib/python2.7/site-packages/yum/", line 5280, in update
    availpkgs = self._compare_providers(availpkgs, requiringPo)
    File "/usr/lib/python2.7/site-packages/yum/", line 1648, in _compare_providers
    bestnum = max(pkgresults.values())
    ValueError: max() arg is an empty sequence

Turns out the secret is simply to install yaljl and yajal-devel and then I can patch successfully, really surprised nobody else out there has run into this yet but its the second time in a month I have had it happen when patching.

Project: hockey-info

So I don’t always have great cell phone service, sometimes its weak 4G or even not 4G at all so modern designed apps suffer when bandwidth is a trickle at best. I would be away from home trying to find out whats going on with a Caps game and the NHL app would just be painfully slow or not work at all sometimes. Eventually I decided the only reasonable thing a hockey nerd such as myself could do was write something to fill this void, ideally something simple and effective to get me the information I wanted without a lot of overhead and frilly extra stuff I didn’t really care about.

The repos are still in high flux right now as I don’t even have a readme file yet for the main one, however this page can serve to sort of explain the bits and pieces.

nhlapi – This is what started it all for me really, I wanted more information about games (for an IRC bot) and threw myself into pulling various bits of information together about the NHL API in an easy to read and access way so others didn’t have to spend the hours I did looking for how to do things.

hockey-info – A super simple website written in Python utilizing the Flask framework. The focus is to be fast, simple and mobile friendly. It directly queries the NHL API for all its information and is formatted in a way that works well on mobile

hockey-info-docker – A bare bones Dockerfile to deploy the latest release of hockey-info. The container is based on Alpine and is as trimmed down as possible, makes deployment super simple and easy for anybody to run their own instance with only a few commands (provided you already have a Docker host to run it on).

Naturally I make no warranty about this app or any of the code I have written, its purely something neat I built in my spare time and am tossing out there for others to enjoy, modify and extend to their hearts content. If you do happen to have input, ideas, or feedback hit me up on twitter or just open an issue on Gitlab if its a purely technical issue to address with the code.

Open links from iTerm2 in a specific browser

So by default iTerm2 uses whatever is the default browser, which I generally use Chrome for work related things, however I like to use Firefox for personal stuff.  I had to look around for a while to find this since I am not an OSX person really, figured someone else will find it useful.

Go to Preferences > Profiles > Advanced > and in the Smart Selection area hit Edit.

Select HTTP URL and hit the Edit Actions button

Add the following entry:

Title: Open in Firefox

Action: Run Command

Parameter: open -a Firefox \0

Hit OK and you should be good to go, now if you hold ⌘ and click on a link (say within Weechat) it will kick it over to Firefox specifically.


Learning Apple: Day 1

I have definitely railed anti-apple on the blog before but I am in the process of at least changing how I feel about their devices (I still might not like what they do as a business however) thanks to some prodding from co-workers.

Enter my Macbook Air which I recently picked up in hopes of finally getting a truly mobile computer with decent battery life as opposed to a short lived brick with an identity crisis (my Asus N-series).  I’ve owned a fair number of so-called portable computers and so far none have really measured up when I started paying attention to how I was using them.  This time however I seriously hope to make some inroads to developing a properly portable computing setup (to post to EDC forums of course!)

So far I have spent a day messing around with the air and I must say I’m already pleased with the experience.  Its absurdly portable; it weighs less than my tablet does (including the mandatory protective case) and gets better battery life than pretty much any laptop I have owned.  The physical aspects of the machine are just great, even holding it by a corner one handed while moving around on my bed its apparent that the construction is far more solid than anything else I’ve used.

The point I expected to be the big hang up was software, I’ve used Windows and Linux for ages so I was skeptical about how I would get along with OS X which often seems to do things differently just for the sake of being different.  So far the best explanation I can come up with is its like German to me, I know some of the basic words but I still have to sound things out and look stuff up online.  Trackpad gestures and command key combinations are taking a little while to get used to but overall things are similar enough that it hasn’t taken me long to get up and running; earlier I was using troubleshooting a web server that had mod_rewrite break after being updated and it was nothing to bring up a few terminals  and move around like I was on my Mint 13 machine jumping from browser to read documentation to the terminals (which seem to function just like every other default terminal client on X).

The real question will be long term how I get used to this and if it messes up my head as I already have two piles of data there for Linux and Windows and another one could just make my brain melt and run out my ears, but so far it doesn’t look like that will be the case.

youtube-dl september release

I don’t know if its just me (I have had a few beers) but it appears that the software is now being released as a compiled executable rather than raw python source, having poked around a bit with some tools to make sure I wasn’t being conned into running shitware I tested it since it seems Google updated some things on Youtube which broke the download script I had, so far everything works so if you are out there wondering the same thing it appears to be legit as far as I can tell.

Something Unexpected

So I broke down the other day after talking to a co-worker about the iPad and bought one. Generally I’m pretty anti-apple as far as most things go, however I wont even lie this thing is pretty nice so far even if its only the iPad 2 and not the 3rd gen model.

Battery life on it is pretty damn good, I can putz around on the internet surfing and reading things for hours without even thinking about charging it, in fact I think I’ve only had to plug it up to recharge once since I bought it. The camera leaves a bit to be desired, but then I have several other options like my HTC Evo Shift or Kodak Play if I really need a decent picture taken. As with any expensive piece of technology I picked up a case, for this device it was a Griffin rubber and plastic case much like the design that Otter Box uses except I made sure it would cover up the Apple logo on the back of the tablet as I have no need to flaunt that logo.

As far as Apps are concerned there are some drawbacks, like most of the SSH clients that I have tried so far are slow on wifi even when the access point is within eyesight of the device. Occasionally Safari will flake out and not follow links when I am doing searches on google, but that may just have been due to a pending update that I had yet to apply. I gave a RDP client a spin and was sorely disappointed, it took forever to load on a wifi connection so I can only imagine how painful it would be across a 3g connection.

When I began looking seriously at tablets one of my biggest concerns was input; I have used tablet computers in the past like the Fujitsu Stylistic and LifeBook however they had keyboards, in the case of pure tablets you often only have your fingers as input. The price of keyboards for the iPad are still a little steep for my liking, but I was fortunate to find that my roommate had a spare Logitech from when he bought an Acer Iconia (that proved to be quite poorly designed and made). That and a cheap 15$ stylus makes the iPad a much more pleasant computing experience as opposed to only using fingers to tap out messages, blog posts, URLs and facebook comments. Perhaps the only thing I would change about the input is support for a bluetooth mouse as even with a stylus it can be a little tricky to select text for copy and paste or drawing out complex designs.

All in all I’m quite pleased with the iPad, the experience has reinforced my belief that Apple’s strong point is in mobile devices such as the iPad, iPod and the iPhone as opposed to their laptops and desktops which are unfortunately vastly overpriced for the hardware they contain.

Close Bitnami banner