Posts

Automate Your API Gateway Setup with Boto3: Rendering HTML from Lambda

Creating RESTful endpoints using the AWS Management Console can quickly become frustrating — especially when dealing with API Gateway. If you've ever felt like the Console experience is too slow for repeatable tasks, you're not alone. In this post, we’ll walk through a Python script using the boto3 library that automates the creation of an AWS API Gateway REST API backed by a Lambda function — and returns HTML, not JSON. This makes it ideal for rendering mobile-friendly forms or web content directly from serverless logic. Why Use Python Over the Console? Repeatability : Run your script anytime without clicking through dozens of console menus. Version Control : Store and track API configurations in Git. Speed : Automate CORS setup, deployment stages, permissions — in seconds. Precision : Avoid human error by defining everything in code. Use Case This script will: Create a REST API in API Gateway. Add a /form route with a GET method. Integrat...

Automating AWS API Gateway and Lambda Integration with Boto3 in Python

 Setting up AWS API Gateway endpoints and integrating them with Lambda functions can be a repetitive and error-prone task when done manually through the AWS Management Console. Automating this process using Python's Boto3 library not only saves time but also ensures consistency across deployments. Prerequisites Before diving into the automation script, ensure you have the following: AWS CLI Configured : Set up with the necessary credentials and default region. Python 3.x Installed : Along with the Boto3 library. If not installed, you can do so using: pip install boto3 Existing Lambda Function : Ensure you have a Lambda function created. For this example, we'll refer to it as xxxx . The Automation Script The following Python script performs the following actions: Creates a REST API named SDKStatsAPI . Adds a /stats resource to the API. Configures a GET method on the /stats resource, integrating it with the specified Lambda function. Enables CORS by...

Building and Deploying a Fargate Container that runs Python and performs CloudWatch Logging

Image
This guide walks you through building and deploying an AWS Fargate container that runs a Python script. The container will be tagged as the latest version, pushed to Amazon Elastic Container Registry (ECR), and configured to log messages to CloudWatch Logs. The process includes setting up the Dockerfile, creating the Python script, building and pushing the Docker image, and configuring AWS services to ensure your container runs smoothly on Fargate. By the end of this tutorial, you will have a running Fargate service that logs information to CloudWatch Logs, allowing you to monitor the status and output of your containerized application in real time. NOTE - In this guide, when you see aws_account_id replace it with your AWS account number and region with your AWS region.  Step-by-Step Guide Overview Setting up the Dockerfile Define a Dockerfile that uses Amazon Linux 2023 as a base image, installs Python, sets up the environment, and configures the CloudWatch logging agent. Wri...

Setting up an AWS Cognito User Pool and building a React login component

Image
Setting up an AWS Cognito User Pool and building a React login component involves several steps. After you follow this guide, you will have a React component that lets a user log into the application using AWS Cognito. Setting Up AWS Cognito User Pool Log in to AWS Management Console and navigate to the Amazon Cognito service. Click on "Create a User Pool". Provide a name for your user pool. Configure Sign-in Options. Choose Username as the primary method of user identification. Optionally, allow email and/or phone numbers as aliases. Configure Password Policy. Define the minimum length and strength (e.g., uppercase, numbers, special characters). Enable Multi-Factor Authentication (MFA) if needed. Choose User Attributes like email or phone number to store additional user information. Configure App Clients In the User Pool, go to the "App clients" section and create a new app client. Disable secret generation for public clients like a React app....

Deploying a Java web application to Amazon ECS

Image
 You can deploy a Java web application that uses the AWS SDK for Java (v2) to Amazon Elastic Container Service (Amazon ECS). Amazon ECS is a highly scalable and fast container management service. You can use it to run, stop, and manage containers on a cluster. With Amazon ECS, your containers are defined in a task definition that you use to run an individual task or task within a service. This AWS tutorial walks you through deploying a Java web application to an AWS Fargate container. With AWS Fargate, you don't need to manage servers, handle capacity planning, or isolate container workloads for security. Fargate handles the infrastructure management aspects of your workload for you. For more information, see What is Amazon Elastic Container Service . To deploy a Java web application to AWS Fargate, create a Docker image from your Spring Boot project. Then, you can deploy your Docker image to Docker Hub, which is a hosted repository service. Finally, configure AWS Fargate to import...

Explore different ways to code AWS database solutions with different AWS SDKs

Image
 When working with AWS database solutions, there are different options and different SDKs available. This post contains a collection of different technologies and different SDKs. The example app that shows usage of AWS SDKs is a decoupled React app.   Item Tracker The following illustration shows the item tracker application.  1. Build the Item tracker with AWS RDS MySQL You can build this app by using the Java Database Connectivity (JDBC) API that provides data access from the Java programming language to an AWS RDS MySQL instance.  Creating the Amazon Relational Database Service item tracker 2. Build the Item tracker app with the Amazon DynamoDB Java API You can build this app by using the Amazon DynamoDB Java V2 API and the Enhanced Client.  Creating the Amazon DynamoDB web application item tracker 3. Build the Serverless Amazon Aurora item tracker application using the Java RdsDataClient API You can build this app by using the RdsDataClient object to pe...

How to play an Audio file located in an Amazon S3 bucket in your web page

Image
 You can play an Audio file (MP3) that is located in your Amazon S3 bucket in your web page.  You can follow these steps: 1. Install the JQuery plug-in by following the instructions in the jPlayer documentation . 2. Add the plug-in to your page, along with the required the CSS. <!DOCTYPE HTML> <html xmlns:th="https://www.thymeleaf.org"> <head>     <meta charset="utf-8" />     <meta http-equiv="X-UA-Compatible" content="IE=edge" />     <meta name="viewport" content="width=device-width, initial-scale=1" />     <link rel="stylesheet" th:href="|https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css|"/>     <link rel="stylesheet" th:href="|https://cdnjs.cloudflare.com/ajax/libs/jplayer/2.9.2/skin/pink.flag/css/jplayer.pink.flag.css|"/>     <script th:src="|https://code.jquery.com/jquery-1.12.4.min.js|"></script...