Thanks to AWS, I Got My iPhone X

Sushant Pophli
Aug 31, 2018 · 2 min read

Morning of Nov-3–2017, I woke up at 5 AM and walked to nearest apple store, to buy iPhone X (Yes, I am a Fanboy !).

The queue was not long, around 50 people tops. I thought my chances of getting a phone are solid. I came home without phone that day. Bummer, you say. I was on a business travel and had to get one in next 2 weeks, so shipping was not an option.

Availability of iPhone X in store was sporadic. I was frequently checking the availability online and couple of times, I even came very close to buying one, only to know it went out-of-stock before I could finish the order.

So, I did, what any developer would do; I poked around Apple.com and figured out REST API used to fetch the availability of phones. An hour later, trying out different set of input parameters for memory, color and location etc. and I had exact URL of a REST service to fetch availability, just like apple does on their website.

Now was the easy part.

All I wanted to do is invoke this REST endpoint at regular interval and get a notification if it returns data. For this, i turned to AWS.
I used following components to complete this task
1) AWS Lambda
2) AWS CloudWatch trigger
3) AWS SES

I created a Serverless Lambda function which would :-

1) Invoke Apple check availability REST endpoint
2) Parse the response
3) If records were found, trigger SES event
4) If no records identified, exit.

Then I created CloudWatch trigger for this Lambda, which would execute the Lambda function every 5 minutes.

I configured AWS SES with from and to email address and validated them.

Set everything up and waited and waited and waited …

Finally after 3 days of this setup, one fine early morning, while I was sipping my coffee and gazing through the window, I heard a “ding” on my phone, picked up the phone and there it was!

Notification, stating iPhone x is now available in store near you. I Immediately placed an order for in-store pickup.

Being a responsible developer which I am, later logged into AWS console and stopped the trigger.

Thanks to AWS, I got my iPhone x :-)

Sushant Pophli

Written by

Software Developer, focusing on microservices and cloud. Serverless enthusiast.