Getting AWS Credentials into to a Docker Container without Hardcoding It

EDIT (3 June 2018): There are security concerns with following this approach. Check out this great article on why.

When I’m building with ECS, I’m more often than not building a worker that interacts with other AWS services. I need my AWS Access Key ID and my AWS Secret Access Key for it to work locally.
Nobody wants hard-coded values being pushed to version control nor do you want to have to dig it up every time you need to develop locally.

Set up your AWS credentials per the official docs.
The highlights taken from this page are as follows:

    • Set credentials in the AWS credentials profile file on your local system, located at:
        • ~/.aws/credentials on Linux, OS X, or Unix
        • C:\Users\USERNAME\.aws\credentials on Windows

      This file should contain lines in the following format:

      aws_access_key_id = your_access_key_id
      aws_secret_access_key = your_secret_access_key

      Substitute your own AWS credentials values for the values your_access_key_id and your_secret_access_key.

    • Set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

To set these variables on Linux, OS X, or Unix, use export:

export AWS_ACCESS_KEY_ID=your_access_key_id
export AWS_SECRET_ACCESS_KEY=your_secret_access_key
# To set these variables on Windows, use set:set AWS_ACCESS_KEY_ID=your_access_key_id
set AWS_SECRET_ACCESS_KEY=your_secret_access_key

Running $ aws help we see there is a –profile parameter.
Leveraging this, we can write a shell script to get our credentials into our Docker container.

Now we can run locally, push to version control and not worry about our credentials being insecure.
Plus, you can build and run your Docker container with one command now, woohoo.

Handling DynamoDB BatchWrite Errors in Node.js

So, you’re building a Node.js app to do DynamoDB Batch Writes or better yet, you’re diving into AWS’ Lambda? You want to be a good programmer and handle errors gracefully, right? You came to the right place.

First, how do errors look? Notice how you just get an empty {} when all is good, well here is it how it looks if any items are unprocessed by DynamoDB:

Now, this is really cool because Amazon just perfectly returned all the code you need to do a new batch write.
All you need to do now is write a callback and ideally put in some exponential backoff logic, like so:

A Few Things to Remember to Do before Deploying a Rails App to AWS Elastic Beanstalk

This might just be a few notes for myself but maybe someone else will find this handy:

  • Include the Puma gem, gem 'puma' (and bundle of course).
  • In the database.yml change the production database settings to this:
  • Once the environment is created run rake secret in the command line.
  • Copy the output and type eb setenv SECRET_KEY_BASE=generated_secret_key
  • Any additional environment variables are set the same way

Definition of “Abstraction” in Computer Science

I’ve been working on putting together a simpler definition for “abstraction” than I’ve been finding online that doesn’t get into other Computer Science concepts.

Here’s the conclusion I’ve come to:

There’s a few “common” meanings of the word that help to gather the full understanding of the word:

– To draw away
– To separate

and finally:

– To form a general concept from consideration of particular instances
(All definitions were taken from the Chambers Dictionary)

So, if I saw chicken wrapped in a tortilla, covered in cilantro, smothered with salsa and lime and being enjoyed by the limelight of Mexican horn music, I could abstract that this is a taco.

Similarly in computer science, I don’t want to have give all those little details every time I describe something to my program, I want to just be able to say “taco” and the program would put together my cilantro, chicken, tortilla and lime programs together. Thusly, I define “taco” as meaning all of that. I have created a layer of “abstraction”. Now I can “abstract” myself further when I want to describe my dining experience by putting my taco program together with my table program and my cerveza program. Then I would define it as my “lunch program”. As a result, I now I just say “Lunch” and my program understands and creates the whole taco party.

If that’s too simple for you, I’m sorry. This wasn’t intended for you though. Check out the WikiPedia article instead.

Some WordPress Basics

Here are some basics on keeping your site healthy and working for you in the future or your posterity. Not applying these basics will result in a massive headache for you or someone else later on…

  • When Building a new site always start building with a child theme. Many themes come pre-packaged with a child theme and that’s great – you should totally use it. If not, you have to make it yourself.
    You can follow the steps here to create one: or use a plugin like – which is great for beginners.
  • Don’t rename the Parent theme. Keep it the same name that the vendor created it with, doing otherwise will make it so you can’t update the theme in many circumstances. Side note: you’re not kidding anyone by renaming a theme… It’s obvious you didn’t make it from scratch, so stop being a douchebag and leave a little cred for the theme devs. 😉
  • NEVER EVER make a change to the parent theme. Doing this will allow your changes to get overwritten on the next update and you always want to keep your themes and plugins up-to-date to get the latest security patches and code updates.
  • If you have to edit WooCommerce files, do so in your child theme following these instructions: . Thoroughly comment out any changes you make as WooCommerce does make changes to template files every now and then and you need to be able to update those customized files if needed.
  • If you are using the DIVI theme or an Elegant Themes plugin be sure to install the Elegant Themes Updater to get the latest plugin/theme updates.
  • If you are using any theme from Theme Forest be sure to install the Envato WordPress Toolkit plugin and hook up the API following their instructions. This way you can easily download any updates. This has to be downloaded from GitHub ( )
  • If you are using any plugin or theme from WooCommerce (besides the basic WooCommerce plugin), then you must install the WooTheme Helper plugin. This will enable to update your premium WooCommerce plugins.
  • When using the WooTheme Helper, Envato WordPress Toolkit or the Elegant Themes Updater be sure to hook it up with their respective APIs as per their site’s instructions.

If you don’t apply these you’re going to have a bad time. Not to mention Magicarp will come after you.

And you don’t want that to happen.

How to – 301 Redirects

301 Redirects are what tell your browser, “Hey! This page has permanently moved! Go to xyz location!”

This is useful if you are for some reason changing domain names or simply changing a few pages URLs. You don’t want to lose any “link juice” (the great Google Elixir) your old pages may have. Not to mention, if you have people linking to your site, you don’t want them to be reaching 404s!

301 Redirects to the rescue!

If you are using WordPress or another CMS there’s probably an easier to use plugin to do this, but I’m a huge fan of keeping plugins to an absolute minimum. Plus this is really simple to do.

Connect to your site via FTP and in the root directory you will generally find a file called .htaccess.

Open it up and copy a backup of the file locally.

On a new line add (the spacing has to be exactly as below):

Redirect 301 /old-site-page/

/old-site-page/ is a relative URL of your old web page and is an absolute URL of the page you want users to be redirected to.

Now what if /old-site-page/ had a subdirectory e.g. /old-site-page/sub-site-page/

The order of how you handle this is important because if you do this:

Redirect 301 /old-site-page/
Redirect 301 /old-site-page/sub-site-page/

You’re going to have a bad time. The second redirect you declared won’t work as you have already redefined what “/old-site-page/” means.

Do it this way and have a good time:

Redirect 301 /old-site-page/sub-site-page/
Redirect 301 /old-site-page/

Remember to test that it worked after you finished!

Obviously Hackerman GIF

Direct Link Your Clients to Leave You a Google My Business Review in 2016

You use to be able to directly link to the review box on Google for your business by simply getting the link to the about portion of your Google + page and simply adding “?review=1” to the end of the URL.

It’s now 2016 and this is not the case anymore.

Fortunately, it’s still simple to do!

  1. Type in your business name in Google.
  2. Click on “Write a Review”
    Link to Google My Business Reviews
  3. A pop-up box will appear and again click on “Write a Review”.
    Link to Google My Business Reviews Part 2
  4. Copy the new URL in the URL bar and create your link.

See? It’s Pretty painless, so go out there and make it rain Google reviews!

Make it rain gif