A Case Study in Over-Engineering

 •  Filed under illiniboard, daily-news, lambda

In an effort to procrastinate even in my free time, I have spent the last month or so trying to understand AWS CodeBuild, AWS CodePipeline, and AWS CodeDeploy. While I get everything at the high-level, I haven't been able to actually figure out my simple goal: deploy code for the IlliniBoard Daily News Job to my AWS Lambda function that will run it.

The thing that gets me is this should be really damn easy, and I cannot figure it out. No idea why. Here are the simple steps that I think I should be able to do:

  1. Check Code into GitHub.
  2. Build the code using AWS CodeBuild
  3. Deploy the code to an AWS Lambda Function using AWS CodeDeploy.

I mean this is as simple a process as you can get. But for some reason, I could not figure it out as I think my use case was just too simple as all of the documentation talks about things way more complicated than this, especially surrounding AWS CodeDeploy, my actual hangup. All the rest worked.

So after a few nights of trying different things, I decided to look at other options. I know I didn't need to use CodeDeploy, but I was thinking it would be a way for me to learn the technology for when I actually need it. I guess that is going to have to come another day since this has just frustrated me a bit too much.

So what was my solution? Leveraging the AWS Command Line interface and Gradle. It's pretty damn simple actually this way and integrated into my already working build process. I just automated the step of uploading the ZIP file to Lambda which has been annoying me.

The first thing I did was create a simple bat file that I can call to execute the AWS CLI. It simply had the following contents:

aws lambda update-function-code --function-name daily_news_execute --zip-file fileb://c:/users/john/illiniboard/illiniboard-dailynews-v2/build/distributions/illiniboard-dailynews-v2.zip

Simple. Elegant. And it works. Then I updated my Gradle script with the following task.

`task deployToLambda ( type: Exec ) {
commandLine 'cmd', '/c', 'deploy_to_lambda.bat'
standardOutput = new ByteArrayOutputStream()

ext.output = {
    return standardOutput.toString()
}

}`

It's that simple. Now, all I need to do to build and push to my Lambda function is type in: gradle deployToLambda. It's not elegant, but it works. Sure, I still need to learn how to use AWS CodeDeploy, but right now I just want to get the Daily News Job done as I often times to forget to run it, and then stories aren't posted. I just need to get this thing running every hour or so and be done with it. So now I can focus on finishing the actual coding, not the stuff that I was trying to learn while procrastinating from that because it just isn't that interesting to me to update.