Featured Video Play Icon

Jessitron & Avdi Learn About Alloy

The other night Jess & I drank vodka mango drinks while she showed me Alloy, which is “a language for describing structures and a tool for exploring them”, according to the website. I think of it as a model checker, although that may not be the correct term. The truth is there’s a lot I don’t understand about Alloy, but Jess did a great job explaining to me why this kind of model analysis matters.

Check out the stream recording (and bonus cocktail recipe) below!

Read More

Be careful of whitespace in .php files

So I was debugging some anomalous behavior on my website and as I was poking around, I half-consciously noticed the change bars in in my editor that showed two extra newlines at the end of a .php file. But I dismissed this even as soon as I saw it because… I mean, it’s just whitespace. At the end of a file.

Read More

Featured Video Play Icon

Jessitron & Avdi Attempt Event Storming

Recently Jess & I decided we needed an app idea to give us an excuse to write code, and last night we spent 45 minutes sketching it out with post-its on a wall. This was our first highly uneducated stab at event-storming, but it was fun and helped us think through what are the tangible, actionable outputs we want to see from our app.

Read More

SIGAVDI #83: Cream Cheese BBQ Chicken Edition

Hello friends,

Before I get into this week fortnight’s newsletter, a quick note: I have immediate availability to take on a new consulting client! I’m particularly good with gnarly gnarly Ruby/Rails codebases, as well as coaching/mentoring junior and midlevel engineers, helping to evolve technical architecture, and facilitating the spread of healthy practices within your organization. More info here!

Read More

A hand-cranked pump in a rice field

The Well in the Field

When I was a child, I lived with my parents in the woods. We had an old-fashioned hand-dug well, the kind from storybooks that looks like a big hole in the ground lined with stacked stones. In summer, if there was a drought, the well would sometimes run dry.

Read More

Hiking near the Meramec River

SIGAVDI #82: Broccoli Rabe Edition

Hello friends,

It’s been another couple weeks of hunkering down with Jess & family in St. Louis. It turns out the way I deal with social distancing is to buckle down and work really hard. When all this is over I may need to impose periodic “productivity quarantines” on myself to match this level of output.

Read More

Reproducibly Setting Production Environment Variables for AWS Lambda Apps

The problem with infinitely flexible building blocks is that there are always a half-dozen well-documented ways to do things wrong.

I wanted my AWS Lambda app (I refuse to call it a “function” because it isn’t) to get the third-party API keys it needs from environment variables. Not from hardcoded strings or config files.

The most immediately accessible way to set up env vars for a Lambda is via the AWS console. But that’s not a reproducible, versionable workflow I can capture in my project.

Searching for info on setting up environment variables in a SAM-based AWS Lambda app turns up a lot of results. It seems you can set variables in the SAM config in template.yaml.

Resources:
HelloWorldFunction:
  Type: AWS::Serverless::Function
  Properties:
    CodeUri: hello_world/
    Handler: app.lambda_handler
    Runtime: python3.7
    Environment:
      Variables:
        API_KEY: 12345...

More usefully, you can define env vars that apply to all of your functions by putting them in the globals section that normally lives at the top of template.yaml

Globals:
Function:
# ...
  Environment:
    Variables:
      API_KEY: 12345...

Which is all great, except that I explicitly don’t want these variable values to apply universally, and I don’t want them to be checked-in to my repo. I just want to set them for my production deployment.

My searching next took me down the rabbit hole of AWS Systems Manager Parameter Store. But that’s way too heavyweight a solution for what I want to do.

Finally, I realized that I could probably set env vars via the aws CLI (not sam). Like everything to do with AWS, the command isn’t particularly intuitive, but here’s what I cam up with:

aws --region us-east-1 lambda  update-function-configuration \
   --function-name myapp-MyFunction-1234ABCD \
   --environment "Variables={API_KEY=12345}"

Some points to note:

  1. Nothing worked until I explicitly set the –region
  2. Environment variables are part of a “function configuration”
  3. The function name for a SAM-managed app is the full name that SAM invents, including the app name, the function name, and some ID garbage at the end.
  4. You can’t just set environment variables directly; that would be too easy. You need to pass Variables={...}, where the contents of the curly braces are key=value pairs delimited by commas.

This gives me a documentable, reproducible template for setting API key environment variables in just the production deployment. Which is what I wanted.