AWS Elastic Beanstalk – Managed Platform Updates

AWS Elastic Beanstalk can now update to the latest version of your underlying platform during a specified maintenance window.

ElasticBeanstalk_Thumbnail[1]Last night, I logged into the EC2 instance that supports this blog. Turns out that I’ve been a negligent system administrator – there were 69 updates pending!

The issue of patching and maintenance may seem trivial; however, companies spend millions of dollars keeps the underlying platforms for their enterprise systems up-to-date.

Enter the Managed Platform Updates updates to the AWS Elastic Beanstalk service. As stated on the AWS blog:

You can now choose to have your AWS Elastic Beanstalk environments automatically update to the latest version of the underlying platform running your application during a specified maintenance window. Elastic Beanstalk regularly releases new versions of supported platforms (i.e., Java, PHP, Ruby, Node.js, Python, .NET, Go, and Docker) with operating system, web & application server, and language & framework updates. Previously, you had to manually initiate updates to your Elastic Beanstalk environments using the Elastic Beanstalk console, command line interface (CLI), or API. Now, you can simply select a weekly maintenance window and have Elastic Beanstalk automatically update the platform version of your environment during that window.

It’ll be interesting to see if companies take advantage of this functionality, and if it causes a reduction in TCO for systems as they move to AWS.

Using Amazon CloudFront to speed up my site

Hare-and-Tortoise-300x156[1]For the first few months of it’s existence, this website was slow. I wasn’t sure what the problem was; I thought that maybe I needed more compute (the site is running on a t2.micro EC2 instance). Fortunately, before I switched instance sizes, I did some reading online.

The most helpful site -found here – lists 15 steps to improve performance. After making many of the recommended changes, I found that the largest impact was due to enabling a Content Delivery Network (CDN) and using caching.

I used W3 Total Cache for my cache changes. For my CDN, I used Amazon CloudFront. CloudFront was easy to set-up. Though W3 Total Cache has an option for enabling CDN, I used the WP Offload plugin (as it was already enabled to access my AWS account).

And, just like that, my response times went from 5-8 seconds to 1-3.

 

 

 

A Fitbit Low Battery SMS Notification using AWS – Part 3

In Part 1, I introduced an app that sends an SMS notification when your Fitbit battery is low. Part 2 covered the Authentication Flow of the process. This post describes how the device status is checked and communicated to the user.

Fitbit-SMS-Sched2The flow is as follows:

  1. The CloudWatch Scheduler kicks off a Lambda job that pulls registered users from the DynamoDB table. This information is based to a SNS topic, which in turn…
  2. …kicks off the Lambda function that obtains the Fitbit device info. The Fitbit api is called, and the resulting message is processed by the Lambda function. The device information is stored in and retrieved from the DynamoDB table as needed for processing and history tracking.
  3. If the result was a success then the a message is sent to the SNS topic for the subscribed user – assuming that the battery status is low AND the user has not already been notified.
  4. If a “Token Expired” error is returned, then the Lambda function passes the required information to the Refresh User SNS topic. The Lambda function again calls a Fitbit API; this time to refresh the token.
  5. If the token is refreshed, then the information is saved to the DynamoDB table and passed to the Get Device Info Topic (starting the process all over again)
  6. If a failure occurs, then a message is sent to the user, directing them to re-authorize the application to access their Fitbit account.

Continue reading “A Fitbit Low Battery SMS Notification using AWS – Part 3”

A Fitbit Low Battery SMS Notification using AWS – Part 2

In Part 1, I introduced an app that sends an SMS notification when your Fitbit battery is low. Part 2 covers the Authentication Flow of the process.

Fitbit-SMS-Auth

The flow is as follows:

  1. User accesses the sign-up page (and by default, provides authorization via Fitbit.com). The request is passed through an API Gateway to a Lambda function. The Lambda function calls a Fitbit api to authenticate the user.
  2. The Fitbit authentication returns to the Lambda code. From there: (3) the token is saved to a DynamoDB database, (4) a message is placed on a SNS topic, and (5) a success response is sent back to the webpage
  3. The user information (access_token, refresh_token, and mobile number) is saved to a DynamoDB table
  4. An SNe1079abb478cc4e04d13615bc10aa4ca[1]S topic receives the mobile number as a message
  5. A success message is sent back to the end user.
  6. The SNS topic (step 4) calls a second Lambda function.
  7. The Create_User_Topic lambda function creates a sns topic for the newly authenticated user.
  8. Once the topic is created, a notice is sent to the user’s mobile device – asking to confirm subscription.
  9. The user confirms the subscription.

Continue reading “A Fitbit Low Battery SMS Notification using AWS – Part 2”

A Fitbit Low Battery SMS Notification using AWS – Part 1

765a3f73cd8c5b0c0bc96bc3cd094740[1]

A few weeks ago, my Fitbit (one of my new favorite devices) died.

Not died, as in bricked; my battery died.

That was a bit surprising, as I am signed up for low battery notifications. Turns out, I did get a notice – in an email. Problem was, I wasn’t checking my email that day.1

fitbit_notificationThe next day, I went back to the Fitbit website to sign-up for SMS notifications; unfortunately, Fitbit doesn’t provide a low battery notification via SMS.

So, I built my own, using a handful of AWS services (Lambda, SNS, API Gateway, and DynamoDB) and exposed Fitbit APIs.

So far, it works well. After subscribing to the service, I got an introductory note telling my my battery status. A few hours later, I received a second notice – letting me know that my battery was low. Continue reading “A Fitbit Low Battery SMS Notification using AWS – Part 1”