Simplifying Messy Conditions: Adaptive Models

Hello! Today we're getting into the thorns of programming. Beware cactus. 🌵 Years ago I found Martin Fowler's article on Adaptive Models. Adaptive models let you replace nests of conditions with a declaration of actions. That pattern has helped clean up my DevOps code a ton of times. Fowler is a better programmer than me. His … Continue reading Simplifying Messy Conditions: Adaptive Models

Python DevOps Code error checking: lint with Pyflakes

Hello! For those unfamiliar with linting (static analysis), read Dan Bader's introduction. There are several linters for Python, but when I'm doing DevOps I use Pyflakes. I love the opening sentence of its design principals: Pyflakes makes a simple promise: it will never complain about style, and it will try very, very hard to never … Continue reading Python DevOps Code error checking: lint with Pyflakes

CodePipeline: Python AWS Lambda Functions Without Timeouts

Hello! Today we're going to cover how to add Python AWS lambda functions to CodePipeline, and specifically how to do that without getting stuck in timeout loops you can't cancel. Copy/pastable code first, details below. Replace the two highlighted lines with the code you actually need to run in the pipeline. The commented raise is … Continue reading CodePipeline: Python AWS Lambda Functions Without Timeouts

Better boto3 Error Handling: Stopping Silent Failures

Good morning! Today's post covers a pattern I use to increase my confidence that my infrastructure code is working. It turns silent errors into loud ones. I've handled plenty of code that runs without errors but still ends up doing the wrong thing, so I'm never really sure if it's safe to go to sleep … Continue reading Better boto3 Error Handling: Stopping Silent Failures

CloudFormation Custom Resources: Avoiding the Two Hour Exception Timeout

There's a gotcha when writing CloudFormation Custom Resources that's easy to miss and if you miss it your stack can get stuck, ignoring its timeout setting. It'll fail on its own after an hour, but if it tries to roll back you have to wait a second hour. Here's how to avoid that. This post … Continue reading CloudFormation Custom Resources: Avoiding the Two Hour Exception Timeout

Lamba: Filter boto3’s Logs into CloudWatch

Good morning! If you're writing a regular script (i.e. not a lambda function), check out this article instead. For those custom cases that don't fit into Terraform or CloudFormation, a little bit of Python and some boto3 in a lambda function can save you. Lambda captures the output of both print() and logging.Logger calls into CloudWatch … Continue reading Lamba: Filter boto3’s Logs into CloudWatch

3 Tools to Validate CloudFormation

Update August 2019: cfn-nag replaced with cfn-lint, a newer tool. Hello! If you haven't read the AWS page on validating CloudFormation templates, check that out first. It's a better starting place. I run three tools before applying CF templates. Here they are! #1 AWS CLI's validator This is the native tool. It's ok. It's really only … Continue reading 3 Tools to Validate CloudFormation