<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adedamola Adedapo</title>
    <description>The latest articles on DEV Community by Adedamola Adedapo (@lordamola).</description>
    <link>https://dev.to/lordamola</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F443260%2F8098240b-90d3-4e40-b8ca-49a0ea4b16f5.jpg</url>
      <title>DEV Community: Adedamola Adedapo</title>
      <link>https://dev.to/lordamola</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lordamola"/>
    <language>en</language>
    <item>
      <title>How to Package Dependency for AWS Lambda with Docker</title>
      <dc:creator>Adedamola Adedapo</dc:creator>
      <pubDate>Mon, 13 May 2024 18:21:17 +0000</pubDate>
      <link>https://dev.to/lordamola/how-to-package-dependency-for-aws-lambda-with-docker-3mpn</link>
      <guid>https://dev.to/lordamola/how-to-package-dependency-for-aws-lambda-with-docker-3mpn</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;This guide explains how to package dependencies for your AWS Lambda function. The tutorial demonstrates automating the process of packaging Python dependencies for AWS Lambda layers using Docker.&lt;/p&gt;

&lt;p&gt;By the end of this guide, you will have created a &lt;code&gt;Dockerfile&lt;/code&gt;. Building this file produces a Docker Image. From this image, you can run a Docker container to generate a &lt;code&gt;.zip&lt;/code&gt; file. You can then upload this file to Lambda as a dependency package for your Lambda function.&lt;/p&gt;

&lt;p&gt;We will explore two methods:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Manual method:&lt;/strong&gt; involving setting up an EC2 instance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automated method:&lt;/strong&gt; using Docker containers.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, let's dive right in! We'll walk you through each step for both the manual and automated approaches in the sections below. Let's get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  Manual Approach:
&lt;/h2&gt;

&lt;p&gt;This method requires setting up the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Launching:&lt;/strong&gt; an EC2 instance with Amazon Linux OS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Installing:&lt;/strong&gt; the following:

&lt;ul&gt;
&lt;li&gt;The desired version of Python,&lt;/li&gt;
&lt;li&gt;Pip, and&lt;/li&gt;
&lt;li&gt;The external Python library into a target folder.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Compressing:&lt;/strong&gt; the library folder.&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Using:&lt;/strong&gt; scp (secure copy) to transfer it from the remote machine to your local computer.&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Uploading:&lt;/strong&gt; the compressed folder from step 3 to the Lambda function.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;This approach could be ideal if you're fond of hands-on processes. However, for those in search of automation and a method that's free of cloud charge, kindly opt for the second approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automated Approach:
&lt;/h2&gt;

&lt;p&gt;In this method, we'll use Docker containers to streamline the process. We'll explore the files involved in the project and the functions they perform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Dockerfile&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the &lt;code&gt;Dockerfile&lt;/code&gt;, serving as the entry point into our code. We use it to configure the Amazon Linux image as the OS within our container. It orchestrates the setup of all supporting code files, such as &lt;code&gt;install_python.sh&lt;/code&gt; and &lt;code&gt;requirements.txt&lt;/code&gt;. Each line in the code snippet has a comment to explain its function.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;

&lt;span class="c"&gt;# Use the official Amazon Linux Docker image&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; amazonlinux:latest&lt;/span&gt;

&lt;span class="c"&gt;# Update package repositories and install necessary packages&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;yum update &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Set the working directory&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /usr/src&lt;/span&gt;

&lt;span class="c"&gt;# Copy the bash script and requirements file into the container&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; install_python.sh .&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; requirements.txt .&lt;/span&gt;

&lt;span class="c"&gt;# Make the bash script executable&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x install_python.sh

&lt;span class="c"&gt;# Run the bash script to install Python&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;./install_python.sh

&lt;span class="c"&gt;# Install Python dependencies into 'modules' directory&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;pip3.12 &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt &lt;span class="nt"&gt;-t&lt;/span&gt; /usr/src/modules/

&lt;span class="c"&gt;# Zip up the installed dependencies&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;zip &lt;span class="nt"&gt;-9r&lt;/span&gt; /usr/src/modules.zip /usr/src/modules

&lt;span class="c"&gt;# Declare a volume to persist data&lt;/span&gt;
&lt;span class="k"&gt;VOLUME&lt;/span&gt;&lt;span class="s"&gt; /usr/src/data&lt;/span&gt;

&lt;span class="c"&gt;# Move modules.zip to the volume&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["mv", "/usr/src/modules.zip", "/usr/src/data/"]&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;2. Install_python.sh&lt;/strong&gt;&lt;br&gt;
This script builds and installs Python from source, along with installing pip. It is called from the &lt;code&gt;Dockerfile&lt;/code&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="c1"&gt;#!/bin/bash
&lt;/span&gt;
&lt;span class="c1"&gt;# Install development tools
&lt;/span&gt;&lt;span class="n"&gt;yum&lt;/span&gt; &lt;span class="n"&gt;groupinstall&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Development Tools&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;

&lt;span class="c1"&gt;# Install necessary dependencies
&lt;/span&gt;&lt;span class="n"&gt;yum&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="n"&gt;gcc&lt;/span&gt; &lt;span class="n"&gt;bzip2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;devel&lt;/span&gt; &lt;span class="n"&gt;libffi&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;devel&lt;/span&gt; &lt;span class="n"&gt;openssl&lt;/span&gt; &lt;span class="n"&gt;openssl&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;devel&lt;/span&gt; &lt;span class="n"&gt;wget&lt;/span&gt;

&lt;span class="c1"&gt;# Set Python version
&lt;/span&gt;&lt;span class="n"&gt;PYTHON_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3.12.2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Download Python source
&lt;/span&gt;&lt;span class="n"&gt;wget&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Extract Python source
&lt;/span&gt;&lt;span class="n"&gt;tar&lt;/span&gt; &lt;span class="n"&gt;xzf&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Python-${PYTHON_VERSION}.tgz&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Navigate into the extracted directory
&lt;/span&gt;&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Python-${PYTHON_VERSION}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Configure Python build with OpenSSL 1.1
&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;configure&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;openssl&lt;/span&gt;&lt;span class="o"&gt;=/&lt;/span&gt;&lt;span class="n"&gt;usr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;lib64&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;openssl11&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;enable&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;optimizations&lt;/span&gt;

&lt;span class="c1"&gt;# Build and install Python
&lt;/span&gt;&lt;span class="n"&gt;make&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt;

&lt;span class="c1"&gt;# Download get-pip.py
&lt;/span&gt;&lt;span class="n"&gt;curl&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;O&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://bootstrap.pypa.io/get-pip.py&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Install pip for Python 3.12
&lt;/span&gt;&lt;span class="n"&gt;python3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt; &lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;pip&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;

&lt;span class="c1"&gt;# Check pip version
&lt;/span&gt;&lt;span class="n"&gt;pip3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;3. Requirements.txt&lt;/strong&gt;&lt;br&gt;
Our &lt;code&gt;requirements.txt&lt;/code&gt; file lists the libraries needed for packaging the project, following a standard practice in Python projects. The content of the file is as follows:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

requests


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Compile Python Version
&lt;/h2&gt;

&lt;p&gt;To compile a different Python version, you can obtain the link to your preferred version from &lt;a href="https://www.python.org/ftp/python/" rel="noopener noreferrer"&gt;here&lt;/a&gt;. You have to ensure that the link points to a &lt;code&gt;.tgz&lt;/code&gt; file.  If you select a different version from the one in this post, adjust the following lines in the &lt;code&gt;Dockerfile&lt;/code&gt; and &lt;code&gt;install_python.sh&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Install_python.py:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="c1"&gt;# Set Python version
&lt;/span&gt;&lt;span class="n"&gt;PYTHON_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3.12.2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Install pip for Python 3.12
&lt;/span&gt;&lt;span class="n"&gt;python3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt; &lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;pip&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;

&lt;span class="c1"&gt;# Check pip version
&lt;/span&gt;&lt;span class="n"&gt;pip3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The third digit in the version number, 3.12.2, is included in the &lt;code&gt;PYTHON_VERSION&lt;/code&gt;, but Python ignores it when running &lt;code&gt;get-pip.py&lt;/code&gt; and in &lt;code&gt;pip3.12&lt;/code&gt;. This applies to any version of Python we decide to use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Dockerfile&lt;/strong&gt;&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="c"&gt;# Install Python dependencies into 'modules' directory&lt;/span&gt;&lt;br&gt;
RUN pip3.12 &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt &lt;span class="nt"&gt;-t&lt;/span&gt; /usr/src/modules/&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Result:&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;When we build our Docker image and convert it to a container, the output is a zip file named modules.zip in the same folder as our &lt;code&gt;Dockerfile&lt;/code&gt;. Below is the terminal log of successfully runing our &lt;code&gt;Dockerfile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vtajk9hulgmx0y2wq18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vtajk9hulgmx0y2wq18.png" alt="output of successfully running the docker file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Code:
&lt;/h2&gt;

&lt;p&gt;Our code is hosted on a GitHub repository. You can access it: &lt;a href="https://github.com/ichdamola/package-lambda-dependency" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;In this guide, we covered two approaches to packaging Python dependencies for AWS Lambda. The first involves using an AWS EC2 instance, installing Amazon Linux OS on it, and building Python from source, along with installing pip, which is then used to install dependencies listed in the requirements.txt file. The second approach streamlines the process using Docker, with the &lt;code&gt;Dockerfile&lt;/code&gt; as the entry file.&lt;/p&gt;

&lt;p&gt;You can read more in the AWS documentation &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/python-package.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Provisioning Multiple AWS RDS Instances with Terraform</title>
      <dc:creator>Adedamola Adedapo</dc:creator>
      <pubDate>Sat, 23 Mar 2024 19:06:57 +0000</pubDate>
      <link>https://dev.to/lordamola/provisioning-multiple-aws-rds-instances-with-terraform-5237</link>
      <guid>https://dev.to/lordamola/provisioning-multiple-aws-rds-instances-with-terraform-5237</guid>
      <description>&lt;p&gt;In this post, we'll create multiple RDS instances using Terraform, a cloud provider-agnostic Infrastructure as Code (IAC) tool, primarily used by DevOps teams to automate infrastructure tasks. For a quick introduction to AWS RDS, you can refer to the blog by K21Academy &lt;a href="https://k21academy.com/amazon-web-services/aws-solutions-architect/amazon-rds/?gc_id=21032105012&amp;amp;g_special_campaign=true&amp;amp;gad_source=1&amp;amp;gclid=Cj0KCQjw-_mvBhDwARIsAA-Q0Q5b6qufmORhha6cJz5vALe7MVOoE9XHcOwBXiD0nFTy0MsbgfmB1GUaAqxYEALw_wcB"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To complete this tutorial, ensure that the AWS CLI client is installed and configured with the access and secret keys. If you haven't done this yet, follow the instructions in the previous post &lt;a href="https://dev.to/lordamola/aws-cli-setup-iam-user-configuration-command-line-access-3m30"&gt;here&lt;/a&gt; to complete this stage.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create Development Folder
&lt;/h2&gt;

&lt;p&gt;Create the folder named &lt;code&gt;RDS&lt;/code&gt; and within it, create a file named &lt;code&gt;main.tf&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;RDS
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;RDS/main.tf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Directory structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; RDS/
&lt;span class="p"&gt;  -&lt;/span&gt; main.tf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Provider Configuration
&lt;/h2&gt;

&lt;p&gt;Open main.tf in your favorite editor (if you use vim, say hi in the comment😊) and add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight terraform"&gt;&lt;code&gt;&lt;span class="k"&gt;provider&lt;/span&gt; &lt;span class="s2"&gt;"aws"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;region&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="nx"&gt;profile&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Terraform, being cloud provider agnostic, requires a provider block. The AWS provider authenticates Terraform with your AWS account and exposes the necessary resources for management.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;region:&lt;/strong&gt; Specifies the AWS region where resources will be provisioned or managed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;profile:&lt;/strong&gt; Specifies the AWS profile name, especially useful if multiple profiles are defined. If not, set it to &lt;code&gt;default&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;After filling:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight terraform"&gt;&lt;code&gt;&lt;span class="k"&gt;provider&lt;/span&gt; &lt;span class="s2"&gt;"aws"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;region&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"us-west-2"&lt;/span&gt;
    &lt;span class="nx"&gt;profile&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"default"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Instance Template
&lt;/h2&gt;

&lt;p&gt;Below is the Terraform template for creating an RDS instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight terraform"&gt;&lt;code&gt;&lt;span class="k"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_db_instance"&lt;/span&gt; &lt;span class="s2"&gt;"db_instance1"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;engine&lt;/span&gt;                 &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"postgres"&lt;/span&gt;       &lt;span class="c1"&gt;# Specify the database engine (PostgreSQL)&lt;/span&gt;
  &lt;span class="nx"&gt;engine_version&lt;/span&gt;         &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"16.1"&lt;/span&gt;           &lt;span class="c1"&gt;# Specify the PostgreSQL version&lt;/span&gt;
  &lt;span class="nx"&gt;multi_az&lt;/span&gt;               &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;            &lt;span class="c1"&gt;# Set to true for Multi-AZ deployment&lt;/span&gt;
  &lt;span class="nx"&gt;identifier&lt;/span&gt;             &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"xxxxxxxxxx"&lt;/span&gt; &lt;span class="c1"&gt;# Unique identifier for the first DB instance&lt;/span&gt;
  &lt;span class="nx"&gt;username&lt;/span&gt;               &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"xxxxxxxxxx"&lt;/span&gt;     &lt;span class="c1"&gt;# Username for the master DB user of the first instance&lt;/span&gt;
  &lt;span class="nx"&gt;password&lt;/span&gt;               &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"xxxxxxxxxx"&lt;/span&gt;     &lt;span class="c1"&gt;# Password for the master DB user of the first instance&lt;/span&gt;
  &lt;span class="nx"&gt;instance_class&lt;/span&gt;         &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"db.m5d.xlarge"&lt;/span&gt;  &lt;span class="c1"&gt;# Instance type for the first DB instance&lt;/span&gt;
  &lt;span class="nx"&gt;allocated_storage&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;xxx&lt;/span&gt;              &lt;span class="c1"&gt;# Allocated storage in GB for the instance&lt;/span&gt;
  &lt;span class="nx"&gt;db_subnet_group_name&lt;/span&gt;   &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_db_subnet_group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;database_subnet_group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;
  &lt;span class="nx"&gt;vpc_security_group_ids&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;aws_security_group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;database_security_group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="nx"&gt;availability_zone&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;aws_availability_zones&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;available_zones&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="nx"&gt;db_name&lt;/span&gt;                &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"xxxxxxxxx"&lt;/span&gt;
  &lt;span class="nx"&gt;skip_final_snapshot&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="nx"&gt;publicly_accessible&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;             &lt;span class="c1"&gt;# Allow access from the public internet&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Define Dependencies:
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;aws_db_instance&lt;/code&gt; is a Terraform block that produces an RDS instance resource. This RDS instance is also a database instance, which is an isolated database environment in the cloud. A DB instance can contain multiple user-created databases depending on preference.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;engine:&lt;/strong&gt;  The &lt;code&gt;engine&lt;/code&gt; field specifies the type of database instance to be provisioned. Common examples are MySQL, PostgreSQL, and Amazon Aurora. We are experimenting with the PostgreSQL engine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;engine_version:&lt;/strong&gt; This defines the version of the Postgres database to be used. Note that this version must be within the ranges recognized by AWS. Therefore, check your web console to be sure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;multi_az:&lt;/strong&gt; Defines if instance the should be provisioned in multiple AWS available zone. This is useful in cases where our customers are in different geographical location, and we will have planned to deployed database to be queried by each customer group in the same location with them. This is mostly useful in a microservice architecture, but our design is a simple one, as a result, we have explicitly set it value to false.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;identifier:&lt;/strong&gt; This is the field that specifies a unique identifier for the db instance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;username:&lt;/strong&gt; Defines a username for the db instance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;password:&lt;/strong&gt; Password to be used to access the database instance after it is provisioned. I recommend that you use at least a 12-character-long password. Use a free password generator &lt;a href="https://www.greengeeks.com/tools/password-generator?gad_source=1&amp;amp;gclid=Cj0KCQjw-_mvBhDwARIsAA-Q0Q518zKyuL630bqcYqFiqHwJ9TVRXzl3kGm-P0FFH6vOBRp73xOwSyUaAmvREALw_wcB"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;instance_class:&lt;/strong&gt; Defines the class of the database instance to be provisioned. For a list of all classes with great insight into usage, visit &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;allocated_storage:&lt;/strong&gt; Size of the db storage capacity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;db_subnet_group_name:&lt;/strong&gt; Defines the IP address ranges group to add the database instance to. The Terraform block for creating a subnet is &lt;strong&gt;aws_db_subnet_group&lt;/strong&gt;. Preceding steps are dependent steps to achieve the aim. Follow the steps in the code below to define a subnet.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight terraform"&gt;&lt;code&gt;&lt;span class="c1"&gt;#step 1: use data source to get all availability zones in region&lt;/span&gt;
&lt;span class="k"&gt;data&lt;/span&gt; &lt;span class="s2"&gt;"aws_availability_zones"&lt;/span&gt; &lt;span class="s2"&gt;"available_zones"&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="c1"&gt;#step 2: create a default subnet in the first AZ if one does not exist&lt;/span&gt;
&lt;span class="k"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_default_subnet"&lt;/span&gt; &lt;span class="s2"&gt;"subnet_az1"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;availability_zone&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;aws_availability_zones&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;available_zones&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;#step 3: create a default subnet in the second AZ if one does not exist&lt;/span&gt;
&lt;span class="k"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_default_subnet"&lt;/span&gt; &lt;span class="s2"&gt;"subnet_az2"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;availability_zone&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;aws_availability_zones&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;available_zones&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;#step 4: create the subnet group for the rds instance&lt;/span&gt;
&lt;span class="k"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_db_subnet_group"&lt;/span&gt; &lt;span class="s2"&gt;"database_subnet_group"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"database-subnets"&lt;/span&gt;
  &lt;span class="nx"&gt;subnet_ids&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;aws_default_subnet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subnet_az1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;aws_default_subnet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subnet_az2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"subnets for database instance"&lt;/span&gt;

  &lt;span class="nx"&gt;tags&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"database-subnets"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;vpc_security_group_ids:&lt;/strong&gt; VPC security group controls the traffic that is allowed to reach and leave the resources within the VPC. This field specifies the ID of the predefined VPC security group to be used. Follow the code below to define one:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight terraform"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Step 1: create default vpc if one does not exist&lt;/span&gt;
&lt;span class="k"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_default_vpc"&lt;/span&gt; &lt;span class="s2"&gt;"default_vpc"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;tags&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"default vpc"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# create security group for the database&lt;/span&gt;
&lt;span class="k"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_security_group"&lt;/span&gt; &lt;span class="s2"&gt;"database_security_group"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"database security group"&lt;/span&gt;
  &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"enable postgres/aurora access on port 5432"&lt;/span&gt;
  &lt;span class="nx"&gt;vpc_id&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_default_vpc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;default_vpc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;

  &lt;span class="nx"&gt;ingress&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"postgre/aurora access"&lt;/span&gt;
    &lt;span class="nx"&gt;from_port&lt;/span&gt;   &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5432&lt;/span&gt;
    &lt;span class="nx"&gt;to_port&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5432&lt;/span&gt;
    &lt;span class="nx"&gt;protocol&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"tcp"&lt;/span&gt;
    &lt;span class="nx"&gt;cidr_blocks&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"0.0.0.0/0"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# Modify this to allow access from specific IPs&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;egress&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;from_port&lt;/span&gt;   &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="nx"&gt;to_port&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="nx"&gt;protocol&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;-1&lt;/span&gt;
    &lt;span class="nx"&gt;cidr_blocks&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"0.0.0.0/0"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;tags&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"database security group"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;availability_zone:&lt;/strong&gt; Availability zones (AZs) are isolated data centers located within specific regions in which public cloud services originate. Remember that you have defined a region to provision your instances in the provider block. Typically, a region contains at least 2 available zones; this field allows you to specify which of the zones to use. To get all available zones, you use a data block in Terraform as shown below:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# use data source to get all availability zones in region
data "aws_availability_zones" "available_zones" {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Select the first AZ as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight terraform"&gt;&lt;code&gt;&lt;span class="k"&gt;data&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;aws_availability_zones&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;available_zones&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;db_name:&lt;/strong&gt; Takes a unique name for the db instance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;skip_final_snapshot:&lt;/strong&gt; Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;publicly_accessible:&lt;/strong&gt; This is a true or false field. If true, it means that your database instance will be accessible from the public internet. However, note that this is also dependent on the defined ingress &lt;strong&gt;cidr_block&lt;/strong&gt;. If it is not set to be accessible from &lt;strong&gt;anywhere&lt;/strong&gt; i.e., &lt;strong&gt;0.0.0.0/0&lt;/strong&gt;, then only the specified CIDR will have access to the database instance.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Create multiple instances
&lt;/h2&gt;

&lt;p&gt;You can create multiple instances by copying and pasting the aws_db_instance block template and making the necessary fields unique to each instance. Alternatively, a more sophisticated approach would involve specifying an array of objects holding unique fields for each instance and iterating through them to create instances dynamically.&lt;/p&gt;

&lt;p&gt;You can download an extended template for creating multiple databases &lt;a href="https://github.com/ichdamola/What-To-Know/blob/master/iac/terraform/multiple_postgres_db.tf"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Running the code
&lt;/h2&gt;

&lt;p&gt;Change your directory into the folder where the &lt;strong&gt;multiple_postgres_db.tf&lt;/strong&gt; file is. Update all the &lt;strong&gt;x-redacted&lt;/strong&gt; field values. Then perform the operation below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;terrafrom init
&lt;span class="nv"&gt;$ &lt;/span&gt;terraform plan
&lt;span class="nv"&gt;$ &lt;/span&gt;terraform apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running the files successfully, you get the 3 db instance host endpoint output on your command. To connect to the DB instances, assuming you have &lt;strong&gt;psql&lt;/strong&gt;, the Postgres terminal client is installed. Run the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;psql &lt;span class="nt"&gt;-U&lt;/span&gt; &amp;lt;username&amp;gt; &lt;span class="nt"&gt;-h&lt;/span&gt; &amp;lt;db host endpoint as outputted as applying the .tf script&amp;gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 5432 &amp;lt;db_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thank you 🙏🤗🙌&lt;/p&gt;

</description>
      <category>terraform</category>
      <category>rds</category>
      <category>aws</category>
      <category>devops</category>
    </item>
    <item>
      <title>AWS CLI Setup: IAM User Configuration &amp; Command-Line Access</title>
      <dc:creator>Adedamola Adedapo</dc:creator>
      <pubDate>Sat, 16 Mar 2024 20:41:17 +0000</pubDate>
      <link>https://dev.to/lordamola/aws-cli-setup-iam-user-configuration-command-line-access-3m30</link>
      <guid>https://dev.to/lordamola/aws-cli-setup-iam-user-configuration-command-line-access-3m30</guid>
      <description>&lt;p&gt;Assuming you've already navigated through the AWS Management Console and set up an IAM user using the AWS web console, as well as generated the essential access and secret keys for programmatic access, you're now ready to configure the AWS Command Line Interface (CLI) for seamless interaction with AWS services.&lt;/p&gt;

&lt;p&gt;If you haven't completed these initial steps yet, don't worry! You can follow along with this hassle-free setup video &lt;a href="https://www.youtube.com/watch?v=66dm5_TnKTc"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;With your IAM user credentials in hand, let's proceed to install and configure the AWS CLI.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Installing the AWS CLI
&lt;/h2&gt;

&lt;p&gt;To start, you'll need to install the AWS CLI client on your system. Refer to the detailed installation process outlined in the AWS official documentation &lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once installed, you can verify that the CLI is accessible from your shell by using the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;which aws
/usr/local/bin/aws 
&lt;span class="nv"&gt;$ &lt;/span&gt;aws &lt;span class="nt"&gt;--version&lt;/span&gt;
aws-cli/2.11.21 Python/3.11.3 Darwin/22.5.0 exe/x86_64 prompt/off
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Configuring the AWS CLI
&lt;/h2&gt;

&lt;p&gt;Now that the AWS CLI is successfully installed, the next step is to configure it with your IAM user credentials. You can do this by running the &lt;code&gt;aws configure&lt;/code&gt; command in your terminal and filling in the prompted fields with your access and secret keys.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;aws configure
AWS Access Key ID &lt;span class="o"&gt;[&lt;/span&gt;None]: &amp;lt;&lt;span class="nb"&gt;paste &lt;/span&gt;access key&amp;gt; &lt;span class="nt"&gt;--&lt;/span&gt; generated &lt;span class="k"&gt;in &lt;/span&gt;step 1 
AWS Secret Access Key &lt;span class="o"&gt;[&lt;/span&gt;None]: &amp;lt;&lt;span class="nb"&gt;paste &lt;/span&gt;secret key&amp;gt; &lt;span class="nt"&gt;--&lt;/span&gt; generated &lt;span class="k"&gt;in &lt;/span&gt;step 1 
Default region name &lt;span class="o"&gt;[&lt;/span&gt;None]:
Default output format &lt;span class="o"&gt;[&lt;/span&gt;None]:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember, you can always update these configuration values by rerunning the &lt;code&gt;aws configure&lt;/code&gt; command.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Finding Your Default Region
&lt;/h2&gt;

&lt;p&gt;To determine the appropriate value for the &lt;code&gt;Default region name&lt;/code&gt; prompt, navigate to your AWS Management Console. Open the service you intend to access or make API calls to, and in the top-right corner of the screen, click on the second menu item to the left. Find the region that matches your desired location, such as &lt;code&gt;eu-west-1&lt;/code&gt; as in the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9ajt0souyz9o3osrovy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9ajt0souyz9o3osrovy.png" alt="AWS RDS screen showing the region where the service is sdeployed" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that you cannot obtain your service region from the IAM service, as it is a global service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;With the AWS CLI now configured, you're all set to interact with AWS services seamlessly from your command line interface.&lt;/p&gt;

</description>
      <category>awsclisetup</category>
      <category>iamuserconfig</category>
      <category>cliinstallation</category>
      <category>awscliconfiguration</category>
    </item>
  </channel>
</rss>
