This cookbook is still in progress and will grow over time.
Lambda, AWS’s bite-size “serverless” compute service, is mostly awesome. However, it still has a relative lack of good documentation.
I’ve been using Lambda a lot lately, meaning I’ve had a lot of browser tabs open trying to find examples of the latest features like VPC support, Cloudformation integration and Python 2.7 functions. In this post, I’ll try to save you some time by sharing examples of a few things that have sent me searching.
Continue reading “My AWS Lambda Cookbook”
This blog post definitely falls under the “Note to Self” category, because I’ve run into this issue like three times now, so here’s hoping that writing down the answer helps me (and maybe you too).
If you launch CloudFormation stacks through the AWS Powershell Tools with the New-CFNStack cmdlet, you may have run into this funky error from time to time:
New-CFNStack: Object reference not set to an instance of an object.
This is not a helpful error message, and I’ve seen it mean a couple different things.
Reason 1 (most common): You’re missing a required template parameter
The New-CFNStack cmdlet takes an array of Amazon.CloudFormation.Model.Parameter key-value pairs as an argument to the “Parameters” parameter. If you try to put a null value in one of those parameter objects and your CloudFormation template doesn’t allow that parameter to be null, you’ll get the error specified above. This can be hard to debug because normally you’d expect a Powershell cmdlet to come back with an error message like “No argument was specified for parameter ‘X'” in such situation. Again, like I said, bad error message, but an easy fix.
Reason 2 (incredibly specific and stupid): You’re using an old version of the Powershell Tools with named credential profiles
Hopefully nobody else has run into this one. Recent versions of the Powershell Tools include a common parameter called “ProfileName”, which can be used to specify the name of an AWS access keypair saved in your .aws/credentials file or the SDK Store. The old “StoredCredentials” common parameter is still available for backwards compatibility. If you’re using a version of the Powershell Tools older than 2.1.9 (I think), the StoredCredentials parameter is all you get, but it doesn’t work too well with profiles saved in .aws/credentials instead of the SDK Store. In fact, I’ve gotten the “object reference” New-CFNStack error when trying to use named profiles with that cmdlet. Moral of the story: keep your AWS Tools up to date and you’ll never see this issue.
I’ll update this post if I find any other issues with this cmdlet. Thanks for reading!