DEV Community

Cover image for Cloud Resume Challenge, Days 7-11 (maybe, I lost count). The hard part...
CurtFarley
CurtFarley

Posted on

Cloud Resume Challenge, Days 7-11 (maybe, I lost count). The hard part...

Holy crap this was the hardest part yet. Lambda, API Gateway, more Python, and I'll admit - stolen Javascript.

I'm not sure exactly how many days I spent on this, but I know it was several. Not full, 8-hr days, but 2-3 hrs each day for sure.

Here's my blueprint for this phase of work:
blueprint:

There are so many things going on here (even though it doesn't look like it from high up) that I got flustered to start. I knew that I had working Python code to update my table, but how do I get it working in Lambda? Not knowing anything, and knowing I knew nothing, I do what I always do - fire up the Lambda GUI and start pressing buttons. :-) That of course, got me exactly what I expected - a big fat error. Fine, time to start looking at documentation, Stack Overflow, other people's GitHub repositories - anywhere I could find clues as to how to make this thing sing.

To help myself, I ended up simplifying my code to start. Instead of using 2 Python functions in Lambda, I just used 1 and then by reverse engineering someone else's code, I got my output to be what I wanted/needed. That was easily the thing I spent the most time on, by a lot. 4 or 5 days reading & testing & re-writing & failing & starting over... The final hurdle was a syntax error - spent several hours trying to figure out why - the code worked 100% in VSCode, but failed in Lambda. Turns out, just needed to indent 2 lines of code on the Lambda side- sheesh... That solution came within 5 minutes of me posting my problem on Stack Overflow - shoulda led with that. People there are freaking geniuses!

1 part down, 2 to go - moving on/back to API Gateway.
Once that was solved, it was pretty much downhill from there. I finished the API Gateway testing - I must diverge - I created the API Gateway earlier, after I had 1 iteration of Lambda working so I could start testing it. But, that didn't work, and I went back to Lambda to do more tinkering. So - I have my API Gateway built, my Lambda is 100% tested & working from inside Lambda, time to get it working via the API.

The API was really easy to get working - seems like that's normal & not just because the Lambda part was so difficult. I mean, I literally spent 10 minutes getting it working (once Lambda was correct) - my problem there was permissions. I had set the API to only respond to an AWS IAM authenticator - WRONG... Turned that off and BAM! API is good to go. Tested from inside the API GUI (best I can describe it) and from a cool little plugin for VSCode called Thunder Client

2 parts down, 1 to go - moving on to Javascript.
I'll be honest here, I 100% stole/borrowed the JS from someone else -the same person who I modeled my resume after to be exact. Links to him are in my first post. The code itself is simple enough, call the API to kick off the Lambda, which updates the counter & returns the current count, then reference the JS to show the count on the webpage. That really doesn't sound simple now that I type it out... Short version here - JS works as desired, no fuss no muss.

Now, while I fully understand WHAT the JS is doing, and I kinda understand some of the syntax, I don't fully understand all the syntax. For that, I need to do some reading, but I felt no reason to re-invent the wheel here (seems like I said that elsewhere) so that's why I didn't write the JS from scratch. It would take me longer to understand enough of it to write from scratch, then to understand the WHY of what little bit of code there is.

What's next?
Now that I have a fully functional website - & I'll be honest, I'm proud of what I've done. It's not super fancy like some of those who have completed the challenge, but it fits me. Clean, simple, efficient code, & has given me a ton of exposure to AWS.

The next phase of the challenge is to automate this sucker. General premise is to "re-do" this challenge using IaC - AWS SAM or Terraform for example. While I used the GUI & manually created a working website, being able to write IaC to do the same thing is the way it's done out there, so I need to understand & be able to do it - even if it's just a simple website.

I'll probably start reading about AWS SAM next week, maybe even tomorrow. But I have a nice little vacation coming up in 2 weeks and my main goal was to have my website 100% done before then. So the IaC work may be delayed a bit. Stay tuned for more posts as that work starts & progresses.

Until then, This is the way.

mando

Top comments (0)