🌈 ESP32-S3 Rainbow: ZX Spectrum Emulator Board! Get it on Crowd Supply →
View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

In this third step we create an RDS instance running Postgres in our VPC using our private subnets. We connect to the database using our Bastion server and create dev and production databases.

We are going to run our database in our private subnets - this should ensure maximum security as there is no way that we can accidentally make our database publicly accessible. The first thing we need to do is create a subnet group from our private subnets:

Create Subnet Group

In the advanced settings of our database we place it in our new VPC and we tell it to use the subnet group that we have just created with our private subnets. We also specify the security group we created in step 1 that gives access to the Postgres port (5432) from our Web Severs security group and our Bastion security group.

Network and Security Settings

We can now create or RDS instance - we’ll create our database manually by logging into our Bastion server (see the video for how to launch this server) and connecting to our new RDS instance.

To create a database we use the following commands:

Connect to the database using the following command - the host should be copied from your RDS instance, the username should be the master username you configured when creating the RDS instance. You will be prompted for the master password.

sudo yum install postgresql95
psql -h [HOST] -U [USERNAME] -d postgres

We will create a dev and prod database using the following commands:

CREATE ROLE dev with encrypted password '[STRONG_PASSWORD1]' LOGIN;
GRANT dev TO [MASTER_USERNAME];
CREATE ROLE prod with encrypted password '[STRONG_PASSWORD2]' LOGIN;
GRANT prod TO [MASTER_USERNAME];
CREATE DATABASE dev with owner dev;
CREATE DATABASE prod with owner prod;

[STRONG_PASSWORD1] and [STRONG_PASSWORD2] should be replace by two different passwords that you generate using a strong password generator. [MASTER_USERNAME] should be replaced by the master username that you set the database instance up with.

Our RDS instance is now ready for use from our Rails application. You can now shut down the Bastion server until you need to perform any other database maintenance jobs.

In the next step we’ll deploy a real Rails application to the Elastic Beanstalk application we created in step2 and connect it to our new database.

Related Posts

Connecting PSQL and Rails Console to Elastic Beanstalk - In this post, we explore a solution to the challenge of running the Rails console against a PostgreSQL database housed in a private subnet for security reasons. While it's a good security practice, it can limit access for bootstrapping users or debugging issues. By tunnelling through a Bastion server, we can establish a connection to the database as if it was running locally. We walk through code examples of SSH tunneling, database connection, and how to run Rails console. A key point is to ensure the Bastion server is shut down after use.
Step 1 - Setup VPC: Deploying a Rails Application to Elastic Beanstalk - In this blog post, I am guiding you through the process of deploying a Rails application to Elastic Beanstalk in a Virtual Private Cloud (VPC) on Amazon AWS. I detail the setup of a VPC, subnets, and internet gateways, as well as the configuration of NAT gateways and security groups. Ultimately, this will allow for a safe, internet-accessible environment for your application and its accompanying databases.
Step 4: Deploy Rails App To Elastic Beanstalk from Command Line - This post guides you through the essential steps of creating and deploying a Rails application into Elastic Beanstalk environment. Topics include creating an AWS user, configuring AWS CLI for deployment, and setting up the environment variables for your app. Also, it provides you the valuable knowledge of connecting your Rails app to RDS instance and ensuring it successfully connects with the dev database.
Step 2 - Setup Elastic Beanstalk: Deploying a Rails Application to Elastic Beanstalk - In this post, I describe how to set up, configure and deploy an Elastic Beanstalk application on a VPC in Amazon AWS, using Rails 5 and Ruby, using Puma for deployment and configuration of Public and Private subnets in Elastic Load Balancer. I also cover the details of network card settings, the selection process for subnets and security groups for Load Balancer and Instances, and finally shared the result of deploying the sample application on Elastic Beanstalk.
Step 6: Add a Custom Domain and SSL to Elastic Beanstalk - In this post, we successfully set up a custom domain name for our Elastic Beanstalk environment and secured it using SSL. By creating a CNAME or an ALIAS pointing at our environment URL (found on the dashboard screen), we made our app accessible via the new domain name. We then used AWS Certificate Manager to add SSL to our environment for access over HTTPS, which was confirmed by visiting the secured site. Now we have a Rails application that can not only be deployed by a CI server, but is also SSL secured with a custom domain.

Related Videos

Is it time to change my batteries? Amazon thinks so! - Got a heads up from Amazon that one of my device batteries was low. Gotta give it to the battery, it lasted quite longer than I anticipated. So, I peeked into the device usage history, which was a trove of data Amazon has kindly stored. In fact, I wrote a web scraper to download all this data. Sadly, records only go back to two weeks. Nevertheless, I plotted the data and surprisingly the pattern revealed that battery level gets affected by temperature change. Cool, isn't it? Finally managed to change the battery. Also, I might just plug in a rechargeable one next time so as to not be a part of the 'throw-away battery' culture. All in all, quite an interesting discovery, courtesy of my Amazon device battery.
ESP-IDF 6 Setup in VS Code: Blink & Debug an ESP32-S3 - Time to get with the program and jump to ESP-IDF v6.0.1 in VS Code. I show you how to install the prerequisites (I’m on a Mac with Homebrew), run the ESP-IDF Installation Manager, spin up a Blink example for an ESP32-S3, tweak menuconfig (GPIO21, 500 ms), then build and flash—switching from stubborn USB JTAG to trusty UART when things fail. We check the monitor, bump CPU to 240 MHz, fix flash to 16 MB, peek at PSRAM, and give PCBWay a quick shout-out.
ESP32-S3 USB UAC Audio Device - does it work? - Time for an audio project: I took my PCBWay ESP32‑S3 board for a spin—fixed the common anode/cathode LED mix‑up, verified the IMU and battery charger, then tested an I2S PDM mic and tiny speaker with a Web Serial Audio Studio (scope, spectrogram, tuner). I also turned it into a USB UAC device in ESP‑IDF: the mic is clean, but speaker over UAC is crackly (Mac/Windows toggle oddity); direct I2S WAV playback is perfect, so the hardware passes QA.
ESP32-S3 - Which Pins Are Safe To Use? - In this video, I've decided to dive deep into the ESP32-S3, a module ruling my lab recently due to its plug-in-and-play functionality, and the flexibility offered by its GPIO matrix. However, working with it requires vigilance, especially with regard to the strapping pins and USB data pins, among others. Discovering such quirks, I've encountered unexpected values, short glitches and the occasional code crash. To help you avoid these bumps, I've documented everything I've learned on my GitHub repo, where I'm inviting you, my fellow makers and engineers, to contribute your valuable experiences and findings. After a minor hiccup with my ESP32-TV, expect an updated PCB design, courtesy of PCBWay. Explore the ESP32-S3 with me, and let's unravel its secrets together, one pull request at a time.
Three ESP32 Rainbow Boards Failed QA — Can we fix them? - I’m assembling another batch of ESP32 Rainbows: PCB house does the boards, UV silkscreen and some parts, and I finish assembly and QA here in Scotland. I run through three QA fails—no sound, dodgy keyboard, and no USB—then fix two: the audio fault was lifted pads on the headphone jack, so I bodged it back with flux and solder (speaker and headphones now work, but it’s a spares board). The no‑USB issue was an ESD protection IC sitting off its pad; I reflowed it on a mini hot plate, cleaned up with IPA, verified continuity, and it now enumerates and flashes perfectly. On to the keyboard next—oh, and Happy New Year!
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening


Published

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts