Introduction
In today's world, building applications that automatically adjust to changing demands is crucial. A unique way to showcase this is by deploying your resume in JSON format using serverless AWS services. This guide will walk you through deploying your JSON resume data with Terraform, leveraging AWS Lambda, DynamoDB, and API Gateway. This setup ensures your resume is always available, scales seamlessly, and can be accessed through a user-friendly API.
Before we begin, ensure you have the following:
- AWS Account: An active AWS account with the necessary permissions.
- Terraform: Installed on your local machine.
- AWS CLI: Installed and configured on your local machine.
Step 1: Define Your JSON Resume Data
Create your resume in JSON format. You can use a JSON schema from the link below:
https://jsonresume.org/schema
Step 2: Define Your Lambda function
We will be creating a python code that our lambda function will use to retrieve the resume data from DynamoDB. See complete code in the repository.
Step 3: Create Terraform Configuration
Create a new directory for your Terraform configuration files. Inside this directory, we will create a sub-directory for our modules. Each folder in the modules directory will contain the infrastructures required to be deployed for each AWS service. See below.
- Api Gateway module: This describes the detailed terraform configuration for our Api Gateway.
- DynamoDB Module: This module contains the terraform codes for deploying DynamoDB and also uploading the resume JSON data on it.
- Iam_Role Module: This module contains the terraform codes that defines the necessary permissions for lambda function to access DynamoDB and CloudWatch.
- Lambda Module: This module defines the terraform codes for archiving the python code in a zip file and also create a lambda function from same.
The full terraform configuration codes can be found in the repository below:
https://github.com/Samuel7050/AWS_RESUME_CHALLENGE.git
Step 3: Test your codes locally
Run terraform init
to initialize the terraform plugins and providers
Run terraform validate
to validate the terraform codes
Run terraform plan
to preview the infrastructures to be deployed. Also note that the Zip file for the lambda function will also be created in the project directory.
Run terraform apply --auto-approve
to deploy the infrastructure on AWS.
Copy the** api_gateway_invoke_url** as indicated in the output above and run a test locally from VScode . Ensure you include **/path_part **of the api gateway. See below
https://susia7qsb6.execute-api.us-east-1.amazonaws.com/dev/data
Paste on a web browser
To clean up locally, run terraform destroy --auto-approve
Step 4: Configure GitHub Actions
To automate the deployment process using GitHub Actions, create a .github/workflows directory in your project root directory and add a file named deploy.yml
Step 5: Configure GitHub Secrets
In your GitHub repository, navigate to Settings > Secrets and variables and add the following secrets and variable, as shown below:
Whenever there is a push action on the main branch or a pull request to the main branch, the GitHub action is automatically triggered. See result of a push action to the main branch of the repository.
The PR from my feature branch to main branch failed as seen below
The workflow failed because of already existing policy as seen in the error code below
Lets fix the error and do another PR the to main branch again to trigger the workflow
To verify, copy the api_gateway_invoke_url/data as shown below and run on your browser. Note that /data is my api gateway path_part
https://sx60706aef.execute-api.us-east-1.amazonaws.com/dev/data
Conclusion
By following these steps, you've deployed your resume in JSON format using AWS Lambda, DynamoDB, API Gateway, and automated the process using GitHub Actions. This setup ensures your resume is highly available, scalable, and easily accessible via a REST API, with the added benefit of continuous integration and deployment. You can now share your resume API endpoint with potential employers or integrate it into your personal website.
Top comments (2)
Great work @gbenga700
thank you for participating in the Cloud Resume API Challenge.
Thanks@rishabk7
You are truly an inspiration in the cloud space