Returning my focus to the hands-on! Day 4


Another day, some more hands-on labs! So this one is pretty fun, we are simply introducing Lambda functions to trigger with our API calls, AKA some serverless infrastructure, again for the benefit of being loosely coupled and highly available. From the above to the below diagram, you see we're introducing two Lambda functions to resolve the API functions (or basically queries in this instance).

Though, serverless infrastructure mentioned, this architecture can also be categorised as a dynamic website more broadly too. The severless element references to how the backend is designed ultimately. 

So, using a wrapper in the AWS SDK, the script uploads the intended Lambda to an S3 bucket and by the end of the project we have both lambda functions created and present alongside the API, as the image below demonstrates;


Here we're able to see how the DynamoDB reflect what is exhibited on the e-commerce website;


Great, but now let's having a little look into the actual code. Now the Line 12 which I've circled is important as this script actually handles two of our API calls but with slightly different filters going on. By creating another endpoint in the API (ie. a path parameter ) our  Lambda function calling on DynamoDB is going to filter results accordingly. Awesome. 


This next bit of code shows us just a wrapper for a skeleton Lambda function, created for future modification. Here you can see some obvious things, the IAM role ARN on line 5 as well as the code for the creation of the Lambda function in AWS starting from Line 8. 


Next are both Lambda functions in the console and we can see how the API gateway has been added as the trigger for the function and how within the API gateway dash, the Lambda has been added as the API endpoint. This exercise has definitely reinforced and built on my understanding of serverless architecture to a new level, beyond just thinking about it conceptually. I think it's interesting that some work still needs to be done on the AWS dash having worked with the IDE however I'm sure there would be a IaC way to deploy these associations without the need to manually connect endpoints on the dash. 



The next lab was about migrating a web application over to Docker. My experience of Docker had been limited to a Terraform tutorial I had completed on Udemy, so this also was also fun and definitely rounded my overall experience of what Docker is and how easy it is to use actually.


So we can see original architecture above, the web app as well as the MySQL database being hosted on two different EC2 instances. Here we use the IDE EC2 instance to complete the Docker migration, but of course you'd just AWS ECS to run your containers instead of having them on another EC2 instance. But anyway, I presume this is just done this way for the learning purposes rather than an example of WAF.


This time around the actual logistics of what a Dockerfile is became so much clearer. As experience and exposure compounds within Cloud tech, things just become more intrinsic. Now what a Dockerfile contains and how we then generate the image make infinitely more sense than before! 

So in sum total by the end of this lab, I had crafted two Dockerfiles, built images, and ran both containers. Continued using the IDE to interacted with and manage said containers, just passing through necessary environmental variables for connectivity. Finally at the end I established an Amazon ECR repository, authenticated Docker client, and pushed the image. So not bad work - definitely has helped cement much greater understanding of the tooling. Tempted to run this locally now, but more labs to finish before I crack on with Udemy bits! Now time for a walk with the better half. 

Popular posts from this blog

Network Fundamentals for the Cloud

Familiarizing with the Command Line Interface

Security Fundamentals for the Cloud

CLI Fundamentals for the Cloud

DataDog, a Cloud Analytics & Monitoring application

A brief introduction to Databases and MySQL

AWS CodeCommit + Creating a CI/CD pipeline

Future Orientation: Tips from a AWS re/Start Graduate

A brief introduction to AWS Cloud Adoption Framework (CAF) and Well-Architected Framework (WAF)

Building a VPC in AWS