<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by SriNu SaMEinI on Medium]]></title>
        <description><![CDATA[Stories by SriNu SaMEinI on Medium]]></description>
        <link>https://medium.com/@ssrinuwas.r?source=rss-f7fcf9015ac2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by SriNu SaMEinI on Medium</title>
            <link>https://medium.com/@ssrinuwas.r?source=rss-f7fcf9015ac2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 01:12:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ssrinuwas.r/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Redis Cache Installation and Configuration Guide]]></title>
            <link>https://medium.com/@ssrinuwas.r/redis-cache-installation-and-configuration-guide-aa847381edc2?source=rss-f7fcf9015ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa847381edc2</guid>
            <dc:creator><![CDATA[SriNu SaMEinI]]></dc:creator>
            <pubDate>Wed, 09 Sep 2026 07:57:47 GMT</pubDate>
            <atom:updated>2026-09-09T07:57:47.508Z</atom:updated>
            <content:encoded><![CDATA[<p>This document outlines the step-by-step procedure for installing, configuring, optimizing, and securing Redis as an in-memory caching system on <strong>RHEL / Rocky Linux / CentOS</strong> environments.</p><h4>1. System Details &amp; Environment</h4><ul><li><strong>Target Server Hostname:</strong> &lt;Your Hostname&gt;</li><li><strong>Default Port:</strong> 6379</li><li><strong>Purpose:</strong> High-performance Application Caching</li><li><strong>Configuration File Path:</strong> /etc/redis/redis.conf</li></ul><h4>2. Installation</h4><p>To install Redis and its dependencies on enterprise Linux distributions, execute the following commands as root:</p><pre># Install the EPEL repository (if not already installed)<br>dnf install epel-release -y<br><br># Install the Redis package<br>dnf install redis -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*4ulmEHsIP-Cimsd5Bmq6Hw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*wfOr93cMBAWjxjVdRdD2JA.png" /></figure><h4>3. Configuration for Caching Purpose</h4><p>Open the configuration file with a text editor (vi /etc/redis/redis.conf) and apply the following production settings:</p><blockquote>A. Network &amp; Access Management</blockquote><p>Modify the bind directive based on your architectural design:</p><ul><li><strong>Option A: App and Redis on the same server (Localhost only)</strong></li></ul><p>Search this line and make changes — (vi /etc/redis/redis.conf)</p><pre>bind 127.0.0.1</pre><ul><li><strong>Option B: App on a separate server (Listen on all network interfaces)</strong></li></ul><pre>bind 0.0.0.0</pre><p>Search this line and make changes — (vi /etc/redis/redis.conf)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*pvdgmhTuZR9KdayxqujE1A.png" /></figure><p>I have application in other server so i have bind 0.0.0.0</p><h4>B. Security &amp; Authentication</h4><p>Enforce strict authentication by adding or uncommenting the requirepass directive at the bottom of the configuration file:</p><p>This password can paste at the end of the (vi /etc/redis/redis.conf) file</p><pre>requirepass TrilokSrinu#ts4321</pre><h4>C. Caching &amp; Memory Optimization (LRU Eviction)</h4><p>To ensure Redis safely operates as a cache (dropping oldest data when full instead of crashing), append these lines to the bottom of the file:</p><pre># Limit Redis max RAM usage to 2 Gigabytes<br>maxmemory 2gb<br><br># Evict the Least Recently Used (LRU) keys when maxmemory is hit<br>maxmemory-policy allkeys-lru</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*gKBu-Aipm62I0VbERaH76Q.png" /><figcaption>Image for B and C</figcaption></figure><h4>4. Service Management</h4><p>Enable the Redis service to persist across system reboots and apply the new configuration:</p><pre># Reload and restart the Redis daemon<br>systemctl restart redis<br><br># Enable Redis to start automatically on system boot<br>systemctl enable redis<br><br># Verify the service status is active (running)<br>systemctl status redis</pre><h4>5. Verification &amp; Testing</h4><p>To confirm the cache is operating correctly, connect locally using the Redis Command Line Interface (redis-cli):</p><pre># Open the CLI interface<br>redis-cli</pre><p>Inside the interactive Redis prompt, execute the following validation string:</p><pre>127.0.0.1:6379&gt; auth TrilokSrinu#ts4321<br>OK<br><br>127.0.0.1:6379&gt; config get maxmemory*<br>1) &quot;maxmemory-policy&quot;<br>2) &quot;allkeys-lru&quot;<br>...<br>7) &quot;maxmemory&quot;<br>8) &quot;2147483648&quot;<br><br>127.0.0.1:6379&gt; set testkey &quot;Cache is working fine&quot;<br>OK<br><br>127.0.0.1:6379&gt; get testkey<br>&quot;Cache is working fine&quot;<br><br>127.0.0.1:6379&gt; exit</pre><h4>6. Application Connection Parameters</h4><p>Provide the following parameters to the development team to establish a connection to the cache cluster:</p><p>Parameter Local Connection (Same Server) Remote Connection (Different Server)<strong>Host</strong>127.0.0.1<em>[Your Server Private IP]</em><strong>Port</strong>63796379<strong>Password</strong>Pennant#pt4321Pennant#pt4321<strong>Database Index</strong>0 <em>(Default)</em>0 <em>(Default)</em></p><pre>Parameter    Local Connection(Same Server)   Remote Connection(Different Server)<br><br>Host         127.0.0.1                       Your Server Private IP<br>Port         6379                            6379<br>Password     YourPassword                    YourPassword<br>DB Index     0                               0</pre><p>Connection String (URI Format)</p><pre>redis://:TrilokSrinu#ts4321@&lt;SERVER_IP&gt;:6379/0</pre><p>👏 <strong>Clap 30 times</strong> to help push this guide out to other cloud engineers via the Medium algorithm!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa847381edc2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon S3 Introduces Account Regional Namespaces]]></title>
            <link>https://medium.com/@ssrinuwas.r/amazon-s3-introduces-account-regional-namespaces-0f13589ce1dd?source=rss-f7fcf9015ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f13589ce1dd</guid>
            <dc:creator><![CDATA[SriNu SaMEinI]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 10:25:22 GMT</pubDate>
            <atom:updated>2026-09-08T10:25:22.743Z</atom:updated>
            <content:encoded><![CDATA[<p>On <strong>March 12, 2026</strong>, AWS quietly rolled out one of the most significant architectural updates to Amazon S3 in years: <strong>account regional namespaces</strong> for general purpose buckets. If you manage production workloads on AWS, this is a massive change in how you name, organize, and secure your S3 resources.</p><p>For nearly two decades, S3 bucket names lived in a single global namespace. Every bucket name had to be completely unique across every AWS account worldwide. This caused endless headaches: naming conflicts, bucket squatting, and security risks when attackers guessed and snatched up predictable names.</p><h3>What Are Account Regional Namespaces?</h3><h4>The Old Way: Global Namespace</h4><p>Previously, if you wanted to name a bucket my-app-data, you had to pray no one else in the world had taken it. Because common names like backups or logs were taken years ago, developers resorted to messy workarounds:</p><ul><li>Adding complex random strings or hashes to bucket names.</li><li>Making Infrastructure-as-Code (IaC) templates cluttered and annoying to reuse across different accounts.</li><li>Risking data leaks if a predictable bucket name was squatted on by a bad actor.</li></ul><pre>python# The Old Way: Forcing unique names with random strings<br>import random<br>import string<br><br>def create_unique_bucket_name(base_name):<br>    suffix = &#39;&#39;.join(random.choices(string.ascii_lowercase + string.digits, k=8))<br>    return f&quot;{base_name}-{suffix}&quot; <br><br>bucket_name = create_unique_bucket_name(&quot;my-app-data&quot;)<br># Result: my-app-data-x7k2m9q1 (Messy and unpredictable)</pre><h4>The New Way: Account + Region Scoping</h4><p>With <a href="https://www.google.com/goto?url=CAESkQEB6zswFdPTxx4SdbZHYhKibZUs3Ue0WP6e5fl_Z-zYi_AQly84Badim7ASfUkjJUU4f9A0ds2e9T_sy6bfNlyP3EXyuMl6S_dJl5ODdj_NmW2PEEv6Mf1snGOlQ5OlrCs5wycZUNC_HJwr3II_mAanpFtQuCDzqWT_TmL2tt6AiZPsh9uHm-ql44iBj-1gNhE-">AWS’s new account regional namespaces</a>, your bucket names are now locked directly to your specific AWS account and region. Two completely different AWS accounts can now use the exact same bucket name without any conflict.</p><p><strong>What this means for you:</strong></p><ul><li>Use clean, highly readable bucket names.</li><li>The exact same infrastructure template can deploy seamlessly across Dev, Staging, and Prod accounts.</li><li>Say goodbye to bucket squatting and naming conflicts.</li></ul><pre># The New Way: Clean and predictable names<br>bucket_name = &quot;my-app-data&quot; # Handled automatically by your account namespace!</pre><h3>How the Architecture Shifts</h3><h4>1. The Under-the-Hood Naming Convention</h4><p>To keep everything unique behind the scenes, AWS uses a specific naming formula for regional buckets: [your-bucket-name]-[account-id]-[region]-an. The trailing -an stands for <strong>Account Namespace</strong>.</p><h4>2. How Bucket ARNs Look Now</h4><p>Because the identity is explicit, Amazon Resource Names (ARNs) now formally include the region and account ID:</p><p>Namespace TypeARN Format<strong>Old Global Namespace</strong>arn:aws:s3:::bucket-name<strong>New Account Regional Namespace</strong>arn:aws:s3:region:account-id:bucket/bucket-name</p><h4>3. IAM Policy Changes</h4><p>Because the ARN format includes the region and account ID, your IAM policies must be updated to target the new pattern correctly:</p><p><strong>Old IAM Target:</strong></p><pre>&quot;Resource&quot;: &quot;arn:aws:s3:::my-app-data/*&quot;</pre><p><strong>New IAM Target:</strong></p><pre>&quot;Resource&quot;: &quot;arn:aws:s3:us-east-1:123456789012:my-app-data/*&quot;</pre><h4>4. SDK and API Updates</h4><p>When using tools like Python’s boto3, specifying the region is now mandatory, and you must explicitly pass the new BucketNamespace parameter:</p><pre>import boto3<br><br>s3_client = boto3.client(&#39;s3&#39;, region_name=&#39;us-west-2&#39;)<br>s3_client.create_bucket(<br>    Bucket=&#39;my-app-data-123456789012-us-west-2-an&#39;, # Explicit format<br>    BucketNamespace=&#39;account-regional&#39;,              # Crucial flag!<br>    CreateBucketConfiguration={<br>        &#39;LocationConstraint&#39;: &#39;us-west-2&#39;<br>    }<br>)</pre><h3>Step-by-Step: Creating a Regional Namespace Bucket</h3><blockquote>Via the AWS Management Console</blockquote><ol><li><strong>Log In:</strong> Open the AWS Management Console and navigate to the <strong>S3</strong> service dashboard.</li><li><strong>Create Bucket:</strong> Click the orange <strong>Create bucket</strong> button.</li><li><strong>Choose the Namespace:</strong> Under Bucket Type, select <strong>General purpose</strong> and opt for the <strong>Account regional namespace</strong>.</li></ol><ul><li><em>Note: Traditional general purpose buckets stay global by default, while special bucket types like S3 Table or Vector buckets natively use account namespaces, and Directory buckets use zonal namespaces.</em></li></ul><ol><li><strong>Name and Region:</strong> Provide your name prefix and select your target AWS Region. The console will show you a preview of the clean, account-isolated path.</li><li><strong>Security Settings:</strong> Leave <strong>Block Public Access</strong> turned <strong>ON</strong> and disable ACLs (Bucket Owner Enforced) for modern security best practices.</li><li><strong>Finish:</strong> Review your encryption and versioning settings, then click <strong>Create bucket</strong>.</li></ol><p>Via the AWS CLI</p><p>You can achieve the same setup instantly using the <a href="https://www.google.com/goto?url=CAEShQEB6zswFeyvkH6dEa7_INL-OW76lDHKsI-BjCuj_6Rx3Pqx0hvTcvSrQwq_csX1Zb_U6ecD1urraLGByCAwQc1W7BhkwIilSgS4ttiG1k5VLieRJl_1jT0V7cUTldpm_UkQtTv0CwHA2o3zIblVyTOe_js0bezU4-OezOKbBrzum5MfFRUM">AWS CLI</a> by appending the --bucket-namespace flag:</p><pre>aws s3api create-bucket \<br>    --bucket test-012345678910-us-east-1-an \<br>    --bucket-namespace account-regional \<br>    --region us-east-1 \<br>    --create-bucket-configuration LocationConstraint=us-east-1</pre><p>Use code with caution.</p><p>Summary of Core Benefits</p><ul><li><strong>Zero Cost:</strong> This feature is rolled out across 37+ core regions at <strong>absolutely no extra charge</strong>.</li><li><strong>No Performance Hits:</strong> There is zero latency or speed impact when transitioning to regional namespaces.</li><li><strong>Safer Automation:</strong> Drastically reduces the risk of deployment failures in CI/CD pipelines due to name availability issues.</li></ul><h3>Conclusion</h3><p>Amazon S3’s shift to account regional namespaces fixes a long-standing pain point for cloud engineers. While you will need to map out your migration strategy and update your IAM structures carefully, the reward is a cleaner, more predictable, and far more secure architecture.</p><p>👏 <strong>Clap 30 times</strong> to help push this guide out to other cloud engineers via the Medium algorithm!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f13589ce1dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Breaking the Laws of Routing: How to Connect Overlapping CIDRs Across AWS and OCI — Part 02 of 02]]></title>
            <link>https://medium.com/@ssrinuwas.r/breaking-the-laws-of-routing-how-to-connect-overlapping-cidrs-across-aws-and-oci-part-02-of-02-818a097bbd90?source=rss-f7fcf9015ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/818a097bbd90</guid>
            <category><![CDATA[cidr]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[oci]]></category>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[SriNu SaMEinI]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 06:30:09 GMT</pubDate>
            <atom:updated>2026-08-31T06:30:09.826Z</atom:updated>
            <content:encoded><![CDATA[<p>In [Part 1], we looked at the fundamental problem of connecting networks when both sides use the same CIDR range.</p><p>Now we are going to build the solution.</p><p>The approach is to create a <strong>separate Transit Network</strong> in each cloud and deploy a Linux server inside each Transit Network. These servers will act as the controlled middlemen between the overlapping production networks.</p><p>Our example architecture looks like this:</p><pre>INTERNET<br>                            |<br>              +-------------+-------------+<br>              |                           |<br>        AWS Transit VPC             OCI Transit VCN<br>        10.1.0.0/16                 10.2.0.0/16<br>              |                           |<br>        Linux Middleman             Linux Middleman<br>        10.1.1.x                    10.2.2.x<br>              |                           |<br>        AWS Transit GW                 OCI DRG<br>              |                           |<br>        AWS Production VPC          OCI Production VCN<br>          10.0.0.0/24                 10.0.0.0/24</pre><p>The important point is that the <strong>production CIDRs overlap</strong>, but the Transit Networks do not.</p><p>That gives us a clean routing domain in which we can build the connectivity.</p><h3>Step 1: Create the Transit Network Subnets</h3><p>We start by creating a dedicated Transit VCN in OCI and a dedicated Transit VPC in AWS.</p><p>Think of these as separate network neighborhoods whose only purpose is to host the infrastructure required to connect the two environments.</p><h3>OCI — Create the Transit VCN</h3><p>In the OCI Console:</p><p><strong>Networking → Virtual Cloud Networks</strong></p><p>Open the Transit VCN created for this architecture.</p><p>For this example, we are using:</p><pre>Transit VCN CIDR: 10.2.0.0/16</pre><p>Create a subnet inside the Transit VCN.</p><p>For example:</p><pre>Transit Subnet: 10.2.2.0/24</pre><p>This subnet will contain the OCI Linux middleman server.</p><h3>Create the OCI Linux Instance</h3><p>Go to:</p><p><strong>Compute → Instances → Create Instance</strong></p><p>Under <strong>Networking</strong>, select:</p><pre>VCN:       Transit VCN<br>Subnet:    10.2.2.0/24</pre><p>Assign a private IP to the instance.</p><p>For documentation purposes, we can refer to it as:</p><pre>OCI Middleman:<br>10.2.2.x</pre><p>If the architecture specifically requires 10.2.2.2, configure that address as the instance&#39;s reserved/private IP rather than assuming OCI will automatically assign it.</p><h3>AWS — Create the Transit VPC</h3><p>Now we create the equivalent network on AWS.</p><p>In the AWS VPC Console, open the Transit VPC.</p><p>For this example:</p><pre>Transit VPC CIDR: 10.1.0.0/16</pre><p>Create a subnet:</p><pre>Transit Subnet: 10.1.1.0/24</pre><p>This subnet will contain the AWS Linux middleman server.</p><h3>Launch the AWS Linux Instance</h3><p>Go to:</p><p><strong>EC2 → Instances → Launch Instance</strong></p><p>Under <strong>Network Settings</strong>, select:</p><pre>VPC:       Transit VPC<br>Subnet:    10.1.1.0/24</pre><p>Launch the instance.</p><p>The private IP will be something such as:</p><pre>AWS Middleman:<br>10.1.1.x</pre><p>Again, if we specifically require 10.1.1.1, configure it explicitly as the private IP rather than assuming it will be assigned automatically.</p><h3>Step 2: Connect the Transit Networks to the Production Networks</h3><p>Creating the Transit VPC and Transit VCN is not enough.</p><p>The cloud networking infrastructure must also know how to reach these networks.</p><p>This is where the <strong>OCI DRG</strong> and <strong>AWS Transit Gateway</strong> come into the picture.</p><h3>Part A — Connect OCI Production VCN to the Transit VCN</h3><p>Our OCI production network is:</p><pre>OCI Production VCN<br>10.0.0.0/24</pre><p>Our Transit VCN is:</p><pre>OCI Transit VCN<br>10.2.0.0/16</pre><p>We want both networks connected through the OCI Dynamic Routing Gateway (DRG).</p><h3>1. Open the DRG</h3><p>Go to:</p><p><strong>Networking → Dynamic Routing Gateways</strong></p><p>Select the DRG you will use for this architecture.</p><p>If one does not already exist, create a DRG.</p><h3>2. Attach the Production VCN</h3><p>Under:</p><p><strong>VCN Attachments → Create VCN Attachment</strong></p><p>Select:</p><pre>Production VCN<br>10.0.0.0/24</pre><h3>3. Attach the Transit VCN</h3><p>Create another VCN attachment and select:</p><pre>Transit VCN<br>10.2.0.0/16</pre><p>The resulting topology is:</p><pre>Production VCN<br>10.0.0.0/24<br>       |<br>       |<br>    OCI DRG<br>       |<br>       |<br>Transit VCN<br>10.2.0.0/16</pre><p>However, attaching the VCNs to the DRG is only part of the configuration.</p><p><strong>Routing tables still need to be configured.</strong></p><p>The relevant route tables must contain routes pointing the required traffic toward the DRG.</p><p>For example:</p><pre>Destination: 10.2.0.0/16<br>Target:      DRG</pre><p>and, where required:</p><pre>Destination: 10.0.0.0/24<br>Target:      DRG</pre><p>The exact routes depend on which subnets need to communicate.</p><h3>Part B — Connect AWS Production VPC to the Transit VPC</h3><p>Now we build the equivalent connectivity in AWS.</p><p>Our AWS Production VPC is:</p><pre>AWS Production VPC<br>10.0.0.0/24</pre><p>Our AWS Transit VPC is:</p><pre>AWS Transit VPC<br>10.1.0.0/16</pre><p>We use an <strong>AWS Transit Gateway (TGW)</strong> to connect them.</p><h3>1. Open the AWS Transit Gateway</h3><p>Go to:</p><p><strong>VPC → Transit Gateways</strong></p><p>Select the Transit Gateway that will be used for this architecture.</p><h3>2. Create the Production VPC Attachment</h3><p>Go to:</p><p><strong>Transit Gateway Attachments → Create Transit Gateway Attachment</strong></p><p>Select:</p><pre>Resource type: VPC<br>VPC: AWS Production VPC</pre><p>Select the required subnets.</p><h3>3. Create the Transit VPC Attachment</h3><p>Create another Transit Gateway attachment.</p><p>Select:</p><pre>Resource type: VPC<br>VPC: AWS Transit VPC</pre><p>Select the required Transit VPC subnets.</p><p>The resulting topology becomes:</p><pre>AWS Production VPC<br>10.0.0.0/24<br>       |<br>       |<br>AWS Transit Gateway<br>       |<br>       |<br>AWS Transit VPC<br>10.1.0.0/16</pre><p>Just like OCI, the attachment itself does not automatically solve every routing requirement.</p><p>The VPC route tables and Transit Gateway route tables must be configured so that the required traffic is forwarded to the correct attachment.</p><p>For example:</p><pre>Destination: 10.1.0.0/16<br>Target:      Transit Gateway</pre><p>and, where required:</p><pre>Destination: 10.0.0.0/24<br>Target:      Transit Gateway</pre><h3>Step 3: Deploy the Linux Middleman Servers</h3><p>Now we have the network infrastructure.</p><p>It’s time to deploy the two servers that will act as our middlemen.</p><p>These servers are deliberately placed in the <strong>non-overlapping Transit Networks</strong>, rather than directly inside the overlapping production networks.</p><h3>OCI Middleman</h3><p>Deploy a Linux Compute Instance inside:</p><pre>Transit VCN<br>10.2.0.0/16</pre><pre>Transit Subnet<br>10.2.2.0/24</pre><p>A suitable operating system could be:</p><ul><li>Oracle Linux</li><li>RHEL</li></ul><p>The server will receive a private IP such as:</p><pre>10.2.2.x</pre><h3>AWS Middleman</h3><p>Deploy a Linux EC2 instance inside:</p><pre>Transit VPC<br>10.1.0.0/16</pre><pre>Transit Subnet<br>10.1.1.0/24</pre><p>A suitable operating system could be:</p><ul><li>RHEL</li><li>Rocky Linux</li><li>Amazon Linux</li></ul><p>The server will receive a private IP such as:</p><pre>10.1.1.x</pre><h3>What Have We Built So Far?</h3><p>At this point, we have deliberately avoided trying to directly route the overlapping networks.</p><p>Instead, we have created two non-overlapping Transit Networks:</p><pre>OCI Transit<br>10.2.0.0/16</pre><pre>        |<br>        |<br>   OCI Middleman<br>      10.2.2.x<br>        |<br>        |<br>    OCI DRG<br>        |<br>        |<br>OCI Production<br>10.0.0.0/24</pre><p>And on AWS:</p><pre>AWS Production<br>10.0.0.0/24<br>        |<br>        |<br> AWS Transit GW<br>        |<br>        |<br> AWS Transit<br>10.1.0.0/16<br>        |<br>        |<br> AWS Middleman<br>10.1.1.x</pre><p>Notice something important.</p><p>The production networks still use the same CIDR:</p><pre>AWS Production: 10.0.0.0/24<br>OCI Production: 10.0.0.0/24</pre><p>We have <strong>not changed them</strong>.</p><p>Instead, we introduced unique transit ranges:</p><pre>AWS Transit: 10.1.0.0/16<br>OCI Transit: 10.2.0.0/16</pre><p>This gives us unique addresses with which to build the interconnection.</p><h3>Do We Need Public IP Addresses?</h3><p>This is an important design decision.</p><p>A public IP is <strong>not inherently required simply because the networks are in different clouds</strong>.</p><p>If the two middleman servers communicate through a private interconnection such as:</p><ul><li>VPN</li><li>FastConnect + Direct Connect</li><li>another private connectivity solution</li></ul><p>then the middleman servers can communicate using private IP addresses.</p><p>For a lab or demonstration architecture, however, we may deliberately use public connectivity between the two middleman instances.</p><p>If we do that, the public IP addresses are used for the <strong>middleman-to-middleman connection</strong>.</p><p>They are not used to magically solve the overlapping CIDR problem.</p><p>For example:</p><pre>OCI Middleman<br>Private: 10.2.2.x<br>Public:  &lt;OCI public IP&gt;<br>       |<br>       | Internet / encrypted tunnel<br>       |<br>AWS Middleman<br>Private: 10.1.1.x<br>Public:  &lt;AWS public IP&gt;</pre><p>For production environments, this traffic should generally be protected with an appropriate encrypted tunnel or private connectivity architecture rather than exposing administrative or application traffic directly to the Internet.</p><h3>The Critical Part Comes Next</h3><p>At this stage, we have built the roads.</p><p>But we have <strong>not yet solved the overlapping-CIDR problem</strong>.</p><p>The two production networks still look identical:</p><pre>AWS: 10.0.0.0/24<br>OCI: 10.0.0.0/24</pre><p>If a packet simply says:</p><pre>Destination = 10.0.0.50</pre><p>the router cannot inherently know whether:</p><pre>10.0.0.50</pre><p>means the AWS server or the OCI server.</p><p>That is the real problem we need to solve.</p><p>The Linux middleman servers are where the next layer of the solution comes in.</p><p>In the next part, we will configure the middleman servers to <strong>translate the overlapping addresses into unique address spaces</strong>, allowing traffic to cross between AWS and OCI without changing the existing production CIDRs.</p><p>That is where the routing starts to get interesting.</p><h3>Phase 2: Configuring the Linux Instances as Network Routers</h3><p>In Part 1, we created the Transit VPC and Transit VCN and deployed a Linux instance in each environment.</p><p>The architecture now looks like this:</p><pre>AWS Production VPC                    OCI Production VCN<br>10.0.0.0/24                           10.0.0.0/24<br>       |                                      |<br>       |                                      |<br>AWS Transit Gateway                     OCI DRG<br>       |                                      |<br>       |                                      |<br>AWS Transit VPC                         OCI Transit VCN<br>10.1.0.0/16                            10.2.0.0/16<br>       |                                      |<br>       |                                      |<br>AWS Linux Router                       OCI Linux Router<br>10.1.1.x                               10.2.2.x<br>       \                                      /<br>        \                                    /<br>         +------ Encrypted IPsec Tunnel ----+</pre><p>The next step is to turn these two Linux instances from ordinary application servers into <strong>network routers</strong>.</p><p>They will eventually perform three important jobs:</p><ol><li>Forward packets between network interfaces and the tunnel.</li><li>Establish the encrypted IPsec connection between AWS and OCI.</li><li>Perform the address translation required to work around the overlapping 10.0.0.0/24 networks.</li></ol><p>We will configure these one step at a time.</p><h3>Step 1: Disable AWS Source/Destination Checking</h3><p>This is an important AWS-specific configuration.</p><p>Normally, an EC2 instance is expected to send and receive traffic associated with its own network identity.</p><p>Our AWS Linux instance is different.</p><p>It will act as a <strong>router</strong>, meaning it may receive a packet whose final destination is another server.</p><p>For example:</p><pre>AWS Production Server<br>10.0.0.50<br>        |<br>        | packet<br>        v<br>AWS Linux Router<br>10.1.1.x<br>        |<br>        | forwarded traffic<br>        v<br>IPsec Tunnel</pre><p>AWS must therefore be told that this EC2 instance is allowed to forward traffic on behalf of other systems.</p><h3>Disable Source/Destination Check</h3><p>In the AWS Console:</p><p><strong>EC2 → Instances</strong></p><p>Select the AWS Transit Linux instance.</p><p>Then:</p><p><strong>Actions → Networking → Change source/destination check</strong></p><p>Disable the check and save the configuration.</p><p>The setting should now be:</p><pre>Source/Destination Check: Disabled</pre><h3>Why is this required?</h3><p>Without this change, AWS can reject traffic that is being forwarded by the EC2 instance because the instance is not the actual source or destination of that traffic.</p><p>Once disabled, the instance can operate as a network appliance such as:</p><ul><li>Router</li><li>NAT gateway</li><li>Firewall</li><li>VPN gateway</li></ul><blockquote><strong><em>Important:</em></strong><em> This setting is required on the AWS EC2 router. OCI does not have this AWS-specific Source/Destination Check feature.</em></blockquote><h3>Step 2: Enable IP Forwarding on Linux</h3><p>The next step is inside the operating system.</p><p>Linux normally behaves like an end host.</p><p>If a packet arrives at the server but the packet is actually intended for another network, Linux will not automatically forward it unless IP forwarding is enabled.</p><p>We therefore need to turn the Linux instance into a router.</p><p>Perform this configuration on <strong>both the AWS and OCI Linux instances</strong>.</p><h3>Enable forwarding immediately</h3><p>Run:</p><pre>sudo sysctl -w net.ipv4.ip_forward=1</pre><p>Verify:</p><pre>sysctl net.ipv4.ip_forward</pre><p>You should see:</p><pre>net.ipv4.ip_forward = 1</pre><h3>Make IP forwarding permanent</h3><p>Create a dedicated sysctl configuration file:</p><pre>sudo vi /etc/sysctl.d/99-cross-cloud-router.conf</pre><p>Add:</p><pre>net.ipv4.ip_forward = 1<br>net.ipv4.conf.all.accept_redirects = 0<br>net.ipv4.conf.all.send_redirects = 0</pre><p>Save the file and apply it:</p><pre>sudo sysctl --system</pre><p>Verify:</p><pre>sysctl net.ipv4.ip_forward</pre><p>Expected:</p><pre>net.ipv4.ip_forward = 1</pre><p>The two redirect settings are used to prevent the router from generating or accepting ICMP redirects, which is generally appropriate for a dedicated routing appliance.</p><h3>Step 3: Install Libreswan</h3><p>Now that Linux is capable of forwarding traffic, we need software to create the encrypted tunnel.</p><p>For this architecture, we will use <strong>Libreswan</strong> to establish an IPsec VPN between the AWS and OCI Linux routers.</p><p>Install Libreswan on <strong>both servers</strong>.</p><p>For Oracle Linux, RHEL, or Rocky Linux:</p><pre>sudo dnf install libreswan -y</pre><p>Enable the IPsec service:</p><pre>sudo systemctl enable --now ipsec</pre><p>Verify:</p><pre>sudo systemctl status ipsec</pre><p>The service should show:</p><pre>active (running)</pre><p>At this point, the servers are ready for IPsec configuration.</p><h3>Step 4: Prepare the IPsec Tunnel</h3><p>Now we need to establish a secure tunnel between the two Linux routers.</p><p>For this example, we will use the following placeholder addresses.</p><p>Replace these values with the actual addresses in your environment.</p><pre>OCI Linux Router<br>Private IP:  10.2.2.x<br>Public IP:   &lt;OCI_PUBLIC_IP&gt;</pre><pre>AWS Linux Router<br>Private IP:  10.1.1.x<br>Public IP:   &lt;AWS_PUBLIC_IP&gt;</pre><p>For example:</p><pre>OCI Public IP:  &lt;OCI_PUBLIC_IP&gt;<br>AWS Public IP:  &lt;AWS_PUBLIC_IP&gt;</pre><p>We deliberately use placeholders here because public IP addresses are environment-specific.</p><h3>Step 5: Configure the Pre-Shared Key</h3><p>The two IPsec endpoints need a shared secret so they can authenticate each other.</p><p>This is called a <strong>Pre-Shared Key (PSK)</strong>.</p><p>On <strong>both</strong> Linux routers, open:</p><pre>sudo vi /etc/ipsec.secrets</pre><p>Add the corresponding PSK configuration.</p><p>Conceptually:</p><pre>&lt;OCI_PUBLIC_IP&gt; &lt;AWS_PUBLIC_IP&gt; : PSK &quot;&lt;STRONG_RANDOM_SECRET&gt;&quot;</pre><p>For example:</p><pre>203.0.113.10 198.51.100.10 : PSK &quot;REPLACE_WITH_A_STRONG_SECRET&quot;</pre><h3>Security note</h3><p>Do not use a simple password such as:</p><pre>MySuperSecretCrossCloudPassword123</pre><p>in a real environment.</p><p>Generate a long, random secret and protect the file:</p><pre>sudo chmod 600 /etc/ipsec.secrets</pre><p>The PSK must be <strong>identical on both endpoints</strong>.</p><h3>Step 6: Configure the OCI IPsec Endpoint</h3><p>On the OCI Linux router, create:</p><pre>sudo vi /etc/ipsec.d/cross-cloud.conf</pre><p>The IPsec configuration should identify:</p><ul><li>The OCI endpoint</li><li>The AWS endpoint</li><li>The authentication method</li><li>IKE version</li><li>The tunnel parameters</li></ul><p>For example:</p><pre>conn aws-to-oci<br>    left=&lt;OCI_PRIVATE_IP&gt;<br>    leftid=&lt;OCI_PUBLIC_IP&gt;<br>    right=&lt;AWS_PUBLIC_IP&gt;<br>    authby=secret<br>    ikev2=insist<br>    auto=start</pre><p>Replace:</p><pre>&lt;OCI_PRIVATE_IP&gt;<br>&lt;OCI_PUBLIC_IP&gt;<br>&lt;AWS_PUBLIC_IP&gt;</pre><p>with the actual values.</p><h3>Step 7: Configure the AWS IPsec Endpoint</h3><p>On the AWS Linux router, create:</p><pre>sudo vi /etc/ipsec.d/cross-cloud.conf</pre><p>Use the mirrored configuration:</p><pre>conn oci-to-aws<br>    left=&lt;AWS_PRIVATE_IP&gt;<br>    leftid=&lt;AWS_PUBLIC_IP&gt;<br>    right=&lt;OCI_PUBLIC_IP&gt;<br>    authby=secret<br>    ikev2=insist<br>    auto=start</pre><p>Again, replace the placeholders with the actual addresses.</p><p>The important concept is:</p><pre>AWS Router<br>    |<br>    | IPsec<br>    |<br>    |<br>OCI Router</pre><p>The two endpoints authenticate using the same PSK and establish an encrypted connection.</p><h3>Step 8: Allow IPsec Through the Cloud Firewalls</h3><p>Before testing the tunnel, make sure the cloud-level firewalls allow the required IPsec traffic.</p><p>For a traditional IPsec connection over the Internet, the relevant traffic normally includes:</p><pre>UDP 500    IKE<br>UDP 4500   NAT-T<br>ESP        IP protocol 50</pre><p>If NAT is involved between the two endpoints, UDP 4500/NAT-T is particularly important.</p><p>You must allow the required traffic in:</p><ul><li>AWS Security Group</li><li>AWS Network ACL, if applicable</li><li>OCI Security List or NSG</li><li>Any host-based firewall such as firewalld</li></ul><p>For example, if using firewalld, verify its configuration before testing:</p><pre>sudo firewall-cmd --list-all</pre><p>Do not simply open every port. Allow only the traffic required by the IPsec design.</p><h3>Step 9: Start and Verify the IPsec Tunnel</h3><p>After both configuration files are created, restart Libreswan:</p><pre>sudo systemctl restart ipsec</pre><p>Check the service:</p><pre>sudo systemctl status ipsec</pre><p>Then check the IPsec state:</p><pre>sudo ipsec status</pre><p>Depending on the Libreswan version, more detailed status can be checked with:</p><pre>sudo ipsec statusall</pre><p>We are looking for an established IKE/IPsec connection.</p><p>The exact output varies by Libreswan version, but the tunnel should show as established rather than merely configured.</p><h3>Important: The Tunnel Is Not the Same as Routing</h3><p>This distinction is critical.</p><p>At this point, we may have:</p><pre>AWS Router<br>     |<br>     |  Encrypted IPsec tunnel<br>     |<br>OCI Router</pre><p>But that does <strong>not automatically mean</strong>:</p><pre>AWS Production<br>10.0.0.0/24<br>        |<br>        v<br>OCI Production<br>10.0.0.0/24</pre><p>will work.</p><p>Why?</p><p>Because both production networks still use:</p><pre>10.0.0.0/24</pre><p>The routers still need to know:</p><ol><li>Which traffic should enter the tunnel?</li><li>Which address should represent the remote system?</li><li>How should the overlapping address be translated?</li><li>How should the return traffic be translated back?</li></ol><p>That is the actual heart of this architecture.</p><h3>What We Have Completed</h3><p>So far, we have completed the infrastructure required to turn the Linux instances into routing appliances.</p><h3>AWS</h3><pre>AWS Production<br>10.0.0.0/24<br>      |<br>      v<br>AWS Transit Gateway<br>      |<br>      v<br>AWS Transit VPC<br>10.1.0.0/16<br>      |<br>      v<br>AWS Linux Router</pre><h3>OCI</h3><pre>OCI Production<br>10.0.0.0/24<br>      |<br>      v<br>OCI DRG<br>      |<br>      v<br>OCI Transit VCN<br>10.2.0.0/16<br>      |<br>      v<br>OCI Linux Router</pre><h3>Cross-cloud</h3><pre>AWS Linux Router<br>      |<br>      |  IPsec / Libreswan<br>      |<br>      v<br>OCI Linux Router</pre><p>The important part is that the actual production networks remain unchanged.</p><pre>AWS: 10.0.0.0/24<br>OCI: 10.0.0.0/24</pre><p>Instead, the Linux routers will provide the translation layer needed to make these overlapping networks communicate.</p><h3>Next: Breaking the Overlap with NAT</h3><p>Now we reach the interesting part.</p><p>Suppose AWS needs to access:</p><pre>OCI server:<br>10.0.0.50</pre><p>But AWS already has:</p><pre>10.0.0.50</pre><p>inside its own network.</p><p>The destination address is therefore ambiguous.</p><p>We cannot simply tell the AWS router:</p><pre>10.0.0.0/24 → IPsec tunnel</pre><p>because 10.0.0.0/24 already exists locally.</p><p>Instead, we will introduce a <strong>translated address space</strong>.</p><p>For example:</p><pre>AWS view of OCI:<br>172.31.0.0/24</pre><p>The traffic can then follow a path such as:</p><pre>AWS Application<br>10.0.0.50<br>      |<br>      | Destination:<br>      | 172.31.0.50<br>      v<br>AWS Linux Router<br>      |<br>      | NAT<br>      | 172.31.0.50<br>      v<br>   IPsec Tunnel<br>      |<br>      v<br>OCI Linux Router<br>      |<br>      | DNAT<br>      v<br>OCI Server<br>10.0.0.50</pre><p>The return traffic is translated back in the opposite direction.</p><p>This is the key technique that allows two networks using the same CIDR to communicate without renumbering the production environments.</p><h3>Phase 3: Breaking the Overlap with Shadow Networks</h3><p>The IPsec tunnel is now established.</p><p>The Linux instances are forwarding packets.</p><p>The AWS source/destination check has been disabled.</p><p>But there is still one fundamental problem.</p><p>Both production environments use the same address space:</p><pre>OCI Production: 10.50.10.0/24<br>AWS Production: 10.50.10.0/24</pre><p>A packet destined for:</p><pre>10.50.10.55</pre><p>is ambiguous.</p><p>Is it:</p><pre>OCI 10.50.10.55</pre><p>or:</p><pre>AWS 10.50.10.55</pre><p>Traditional routing cannot distinguish between the two.</p><p>This is where the <strong>Shadow Network</strong> concept comes in.</p><p>Instead of trying to route the real overlapping addresses across the tunnel, we create unique address spaces that represent each remote network.</p><p>For this architecture:</p><pre>Real OCI Network:<br>10.50.10.0/24</pre><pre>Real AWS Network:<br>10.50.10.0/24</pre><pre>OCI Shadow Network:<br>10.10.10.0/24</pre><pre>AWS Shadow Network:<br>10.20.10.0/24</pre><p>From OCI’s perspective, AWS is no longer represented by 10.50.10.0/24.</p><p>It is represented by:</p><pre>10.20.10.0/24</pre><p>From AWS’s perspective, OCI is represented by:</p><pre>10.10.10.0/24</pre><p>The result is:</p><pre>OCI                              AWS</pre><pre>10.50.10.0/24                         10.50.10.0/24<br> REAL OCI                              REAL AWS<br>      |                                     |<br>      |                                     |<br>      v                                     v<br> OCI Linux Router                    AWS Linux Router<br>      |                                     |<br>      |                                     |<br>10.10.10.0/24                         10.20.10.0/24<br> OCI SHADOW                             AWS SHADOW<br>      \                                     /<br>       \                                   /<br>        +--------- IPsec Tunnel ---------+</pre><p>Now the routing system has unique destinations to work with.</p><h3>Step 1: Configure the OCI Router</h3><p>The OCI Linux router needs to perform two translations.</p><h3>Translation 1 — AWS Shadow → Real AWS</h3><p>Traffic arriving from AWS may be addressed to:</p><pre>10.10.10.x</pre><p>The OCI router needs to understand that this represents the real OCI network:</p><pre>10.50.10.x</pre><h3>Translation 2 — Real OCI → OCI Shadow</h3><p>When an OCI server sends traffic toward AWS, its real source address:</p><pre>10.50.10.x</pre><p>must be represented across the tunnel using:</p><pre>10.10.10.x</pre><p>This prevents the AWS side from seeing the conflicting 10.50.10.0/24 source network.</p><h3>Configure the OCI NAT Rules</h3><p>If iptables is being used directly, the conceptual NETMAP rules are:</p><pre># Incoming AWS-shadow destination → real OCI destination<br>sudo iptables -t nat -A PREROUTING \<br>    -i vti1 \<br>    -d 10.20.10.0/24 \<br>    -j NETMAP \<br>    --to 10.50.10.0/24</pre><pre># Real OCI source → OCI shadow source<br>sudo iptables -t nat -A POSTROUTING \<br>    -o vti1 \<br>    -s 10.50.10.0/24 \<br>    -j NETMAP \<br>    --to 10.10.10.0/24</pre><p>The exact direction and selectors must match the final tunnel design.</p><p>This is important because NAT rules should be built around the <strong>actual packet direction</strong>, not simply copied symmetrically between the two routers.</p><h3>Step 2: Configure the AWS Router</h3><p>The AWS router performs the opposite translation.</p><p>Traffic arriving from OCI uses the OCI Shadow Network:</p><pre>10.10.10.0/24</pre><p>The AWS router converts that to the real AWS network:</p><pre>10.50.10.0/24</pre><p>Likewise, when AWS sends traffic toward OCI, the AWS router represents the AWS source using the AWS Shadow Network:</p><pre>10.20.10.0/24</pre><p>Conceptually:</p><pre># Incoming OCI-shadow destination → real AWS destination<br>sudo iptables -t nat -A PREROUTING \<br>    -i vti1 \<br>    -d 10.10.10.0/24 \<br>    -j NETMAP \<br>    --to 10.50.10.0/24</pre><pre># Real AWS source → AWS shadow source<br>sudo iptables -t nat -A POSTROUTING \<br>    -o vti1 \<br>    -s 10.50.10.0/24 \<br>    -j NETMAP \<br>    --to 10.20.10.0/24</pre><p>Again, the exact rule set depends on the selected IPsec/VTI routing model.</p><h3>Step 3: Make the Shadow Networks Routable</h3><p>NAT alone is not enough.</p><p>The cloud networking layer needs to know where the Shadow Networks live.</p><p>For example:</p><pre>OCI:<br>10.20.10.0/24 → OCI Linux Router</pre><p>and:</p><pre>AWS:<br>10.10.10.0/24 → AWS Linux Router</pre><p>These routes are what direct traffic toward the correct middleman.</p><h3>Step 4: Configure OCI Routing</h3><p>The OCI production workloads need a route for the AWS Shadow Network.</p><p>In the OCI Console, go to:</p><p><strong>Networking → Virtual Cloud Networks → Production VCN → Route Tables</strong></p><p>Select the route table associated with the production subnet.</p><p>Add:</p><pre>Destination:<br>10.20.10.0/24</pre><pre>Target:<br>DRG</pre><p>This means:</p><pre>OCI Server<br>10.50.10.55<br>      |<br>      | destination 10.20.10.55<br>      v<br>OCI DRG</pre><p>The DRG then needs to know that:</p><pre>10.20.10.0/24</pre><p>is reachable through the Transit VCN attachment.</p><p>The Transit VCN route table then needs to direct that traffic toward the OCI Linux router.</p><p>Conceptually:</p><pre>OCI Production<br>      |<br>      | 10.20.10.0/24<br>      v<br>     DRG<br>      |<br>      v<br>Transit VCN<br>      |<br>      v<br>OCI Linux Router</pre><blockquote><strong><em>Important:</em></strong><em> OCI route tables are evaluated per subnet. Make sure the route is added to the route table actually associated with the workload subnet that originates the traffic.</em></blockquote><h3>Step 5: Configure AWS Routing</h3><p>AWS needs the equivalent route.</p><p>In the AWS VPC Console, open the route table associated with the AWS production subnet.</p><p>Add:</p><pre>Destination:<br>10.10.10.0/24</pre><pre>Target:<br>Transit Gateway</pre><p>The packet flow becomes:</p><pre>AWS Server<br>10.50.10.55<br>      |<br>      | destination 10.10.10.55<br>      v<br>AWS Transit Gateway<br>      |<br>      v<br>AWS Transit VPC<br>      |<br>      v<br>AWS Linux Router</pre><p>The Transit Gateway route table must also have a route for:</p><pre>10.10.10.0/24</pre><p>pointing toward the Transit VPC attachment.</p><p>Finally, the Transit VPC subnet route table must direct that traffic toward the AWS Linux router.</p><h3>Step 6: Add the Router’s Host Routes</h3><p>The Linux routers also need to know that the remote Shadow Network should travel through the IPsec interface.</p><p>If the tunnel uses:</p><pre>vti1</pre><p>the conceptual routes are:</p><h3>OCI</h3><pre>sudo ip route add 10.20.10.0/24 dev vti1</pre><h3>AWS</h3><pre>sudo ip route add 10.10.10.0/24 dev vti1</pre><p>Verify with:</p><pre>ip route</pre><p>You should see the corresponding Shadow Network associated with the VTI.</p><blockquote><strong><em>Important:</em></strong><em> These routes should eventually be made persistent using the networking mechanism appropriate to the Linux distribution. A route added manually with </em><em>ip route add may disappear after a reboot.</em></blockquote><h3>Step 7: Disable Reverse Path Filtering</h3><p>There is another Linux feature that can interfere with asymmetric or translated routing.</p><p>It is called <strong>Reverse Path Filtering (</strong><strong>rp_filter)</strong>.</p><p>Linux can perform a reverse-route check on an incoming packet.</p><p>In a normal network, this is useful.</p><p>In our translated cross-cloud topology, however, the packet’s source address may not correspond to the route Linux would normally expect.</p><p>This can cause apparently valid packets to be silently discarded.</p><p>Check the current setting:</p><pre>sysctl net.ipv4.conf.all.rp_filter</pre><p>For this routing design, configure the required interfaces appropriately.</p><p>For a lab/test environment, one approach is:</p><pre>sudo sysctl -w net.ipv4.conf.all.rp_filter=0<br>sudo sysctl -w net.ipv4.conf.default.rp_filter=0</pre><p>If vti1 exists:</p><pre>sudo sysctl -w net.ipv4.conf.vti1.rp_filter=0</pre><p>Verify:</p><pre>sysctl net.ipv4.conf.all.rp_filter<br>sysctl net.ipv4.conf.default.rp_filter<br>sysctl net.ipv4.conf.vti1.rp_filter</pre><p>For production, configure this deliberately rather than blindly disabling reverse-path filtering globally. Where possible, use the narrowest interface-specific configuration that works with the chosen routing design.</p><h3>Step 8: Configure Firewalld for the IPsec Traffic</h3><p>If firewalld is running, the IPsec endpoint must be allowed to receive the necessary traffic.</p><p>Check whether it is running:</p><pre>sudo systemctl status firewalld</pre><p>For Libreswan, allow the IPsec service:</p><pre>sudo firewall-cmd --permanent --add-service=ipsec</pre><p>If required by the specific deployment, allow IKE and NAT-T:</p><pre>sudo firewall-cmd --permanent --add-port=500/udp<br>sudo firewall-cmd --permanent --add-port=4500/udp</pre><p>For ESP:</p><pre>sudo firewall-cmd --permanent --add-protocol=esp</pre><p>Then reload:</p><pre>sudo firewall-cmd --reload</pre><p>Verify:</p><pre>sudo firewall-cmd --list-all</pre><h3>Step 9: Make NETMAP Rules Persistent</h3><p>iptables commands entered directly into the shell are not necessarily persistent across reboot.</p><p>This is especially important for a router.</p><p>If the operating system uses firewalld, direct rules can be used where appropriate:</p><pre>sudo firewall-cmd --permanent --direct \<br>    --add-rule ipv4 nat PREROUTING 0 \<br>    -i vti1 \<br>    -d 10.20.10.0/24 \<br>    -j NETMAP \<br>    --to 10.50.10.0/24</pre><p>And the corresponding POSTROUTING rule:</p><pre>sudo firewall-cmd --permanent --direct \<br>    --add-rule ipv4 nat POSTROUTING 0 \<br>    -o vti1 \<br>    -s 10.50.10.0/24 \<br>    -j NETMAP \<br>    --to 10.10.10.0/24</pre><p>Repeat the corresponding rules on the AWS router.</p><p>Then:</p><pre>sudo firewall-cmd --reload</pre><p>Verify the direct rules:</p><pre>sudo firewall-cmd --direct --get-all-rules</pre><p>You should see the configured NAT rules.</p><blockquote><strong><em>Important:</em></strong><em> </em><em>NETMAP availability depends on the kernel/netfilter packages installed on the operating system. Verify that the target system supports the </em><em>NETMAP target before building the production configuration around it.</em></blockquote><h3>Phase 4: Test the Complete Data Path</h3><p>Now we have reached the moment where the architecture can be tested end-to-end.</p><p>Assume:</p><pre>OCI real server:<br>10.50.10.55</pre><pre>AWS real server:<br>10.50.10.55</pre><p>Because these addresses overlap, we do <strong>not</strong> access the AWS server using:</p><pre>10.50.10.55</pre><p>from OCI.</p><p>Instead, OCI uses the AWS Shadow address:</p><pre>10.20.10.55</pre><p>Likewise, AWS accesses the OCI server through:</p><pre>10.10.10.55</pre><h3>Step 1: Test from OCI to AWS</h3><p>Log into the OCI application server:</p><pre>ssh &lt;OCI_SERVER&gt;</pre><p>Test the AWS Shadow address:</p><pre>ping 10.20.10.55</pre><p>If ICMP is allowed, the request should travel through the architecture.</p><p>The logical packet path is:</p><pre>OCI Application<br>10.50.10.55<br>      |<br>      | Destination:<br>      | 10.20.10.55<br>      v<br>OCI Production Route Table<br>      |<br>      v<br>OCI DRG<br>      |<br>      v<br>OCI Transit VCN<br>      |<br>      v<br>OCI Linux Router<br>      |<br>      | Source translated:<br>      | 10.50.10.55<br>      |       ↓<br>      | 10.10.10.55<br>      |<br>      v<br>IPsec / VTI<br>      |<br>      v<br>AWS Linux Router<br>      |<br>      | Destination translated:<br>      | 10.20.10.55<br>      |       ↓<br>      | 10.50.10.55<br>      |<br>      v<br>AWS Production Server<br>10.50.10.55</pre><p>The AWS server therefore receives a packet addressed to its <strong>real</strong> address.</p><h3>Step 2: Test the Reverse Direction</h3><p>Now perform the opposite test.</p><p>From the AWS server:</p><pre>ping 10.10.10.55</pre><p>The logical path becomes:</p><pre>AWS Application<br>10.50.10.55<br>      |<br>      | Destination:<br>      | 10.10.10.55<br>      v<br>AWS Transit Gateway<br>      |<br>      v<br>AWS Linux Router<br>      |<br>      | Source translated:<br>      | 10.50.10.55<br>      |       ↓<br>      | 10.20.10.55<br>      |<br>      v<br>IPsec / VTI<br>      |<br>      v<br>OCI Linux Router<br>      |<br>      | Destination translated:<br>      | 10.10.10.55<br>      |       ↓<br>      | 10.50.10.55<br>      |<br>      v<br>OCI Production Server<br>10.50.10.55</pre><p>This is the key idea behind the Shadow Network design.</p><p>The actual production servers retain their original addresses.</p><p>Only the representation of those addresses changes while traffic crosses the inter-cloud boundary.</p><h3>Phase 5: Don’t Start With Ping</h3><p>Ping is useful, but it should not be the only connectivity test.</p><p>ICMP may be blocked by:</p><ul><li>Security Groups</li><li>Network Security Groups</li><li>Security Lists</li><li>Network ACLs</li><li>Host firewalls</li></ul><p>Instead, test the actual application port.</p><p>For example, if the AWS application listens on TCP/443:</p><pre>nc -vz 10.20.10.55 443</pre><p>Or:</p><pre>curl -vk https://10.20.10.55/</pre><p>For SSH:</p><pre>nc -vz 10.20.10.55 22</pre><p>This tells us whether the application protocol can actually traverse the entire path.</p><h3>Phase 6: Observe the Packet at Every Hop</h3><p>If the connection fails, do not immediately change the NAT rules.</p><p>First determine where the packet stops.</p><p>On the OCI Linux router:</p><pre>sudo tcpdump -ni any host 10.20.10.55</pre><p>On the AWS Linux router:</p><pre>sudo tcpdump -ni any host 10.10.10.55</pre><p>You can also monitor the VTI interface:</p><pre>sudo tcpdump -ni vti1</pre><p>This gives us visibility into the packet at different stages.</p><h3>Phase 7: Check the NAT Counters</h3><p>One of the fastest ways to determine whether a NAT rule is actually matching traffic is to inspect the counters.</p><p>For example:</p><pre>sudo iptables -t nat -L -n -v</pre><p>Look for the NETMAP rules.</p><p>The packet and byte counters should increase when traffic crosses the router.</p><p>If the counters remain at:</p><pre>0 packets<br>0 bytes</pre><p>then the rule is probably not matching the traffic.</p><p>Possible causes include:</p><ul><li>Wrong source CIDR</li><li>Wrong destination CIDR</li><li>Wrong interface</li><li>Wrong VTI name</li><li>Route sending traffic somewhere else</li><li>Traffic never reaching the router</li></ul><h3>Phase 8: Verify the IPsec Tunnel</h3><p>On either router:</p><pre>sudo ipsec status</pre><p>For more detailed information:</p><pre>sudo ipsec statusall</pre><p>The tunnel should show an established IKE/IPsec session.</p><p>Also check the VTI:</p><pre>ip link show vti1</pre><p>And:</p><pre>ip addr show vti1</pre><p>If the VTI does not exist, the NAT and route configuration cannot work as expected.</p><h3>Phase 9: Verify the Routing Table</h3><p>On the OCI router:</p><pre>ip route</pre><p>Confirm that the AWS Shadow Network is reachable through the expected interface/path:</p><pre>10.20.10.0/24</pre><p>On the AWS router:</p><pre>ip route</pre><p>Confirm:</p><pre>10.10.10.0/24</pre><p>is reachable through the expected interface/path.</p><p>Also verify the production-side routes in OCI and AWS.</p><p>The complete chain must exist.</p><h3>The Complete Packet Flow</h3><p>We can now visualize the entire solution.</p><p>Suppose:</p><pre>OCI Server:<br>10.50.10.55</pre><pre>AWS Server:<br>10.50.10.55</pre><p>The OCI server wants to connect to the AWS server.</p><p>It does <strong>not</strong> send:</p><pre>10.50.10.55</pre><p>Instead it sends:</p><pre>10.20.10.55</pre><p>because 10.20.10.0/24 is the AWS Shadow Network.</p><p>The packet travels:</p><pre>OCI<br>                  |<br>        10.50.10.55<br>                  |<br>                  v<br>          OCI Production<br>                  |<br>                  v<br>               OCI DRG<br>                  |<br>                  v<br>           OCI Transit VCN<br>                  |<br>                  v<br>          OCI Linux Router<br>                  |<br>             NETMAP/NAT<br>                  |<br>                  | 10.10.10.55<br>                  v<br>            IPsec / VTI<br>                  |<br>                  v<br>          AWS Linux Router<br>                  |<br>             NETMAP/NAT<br>                  |<br>                  | 10.50.10.55<br>                  v<br>           AWS Production<br>                  |<br>                  v<br>            AWS Server</pre><p>The return packet follows the reverse translation path.</p><p>This is the fundamental trick.</p><p>We are not forcing two identical networks to become one routing domain.</p><p>We are creating <strong>unique representations of each network</strong> and translating between those representations and the real addresses at the network boundary.</p><h3>Troubleshooting: Where Can It Fail?</h3><p>There are several layers in this architecture.</p><p>When something fails, troubleshoot from the bottom upward.</p><h3>Layer 1 — Cloud Connectivity</h3><p>Check:</p><pre>AWS Security Group<br>AWS NACL<br>OCI Security List<br>OCI NSG</pre><p>Make sure the IPsec endpoint traffic is permitted.</p><h3>Layer 2 — IPsec</h3><p>Check:</p><pre>sudo systemctl status ipsec<br>sudo ipsec statusall</pre><p>If the tunnel is not established, do not troubleshoot NAT yet.</p><h3>Layer 3 — VTI</h3><p>Check:</p><pre>ip link show vti1<br>ip addr show vti1</pre><h3>Layer 4 — Linux Forwarding</h3><p>Check:</p><pre>sysctl net.ipv4.ip_forward</pre><p>Expected:</p><pre>net.ipv4.ip_forward = 1</pre><h3>Layer 5 — Routing</h3><p>Check:</p><pre>ip route</pre><p>Verify the Shadow Networks are routed toward the correct interface.</p><h3>Layer 6 — NAT</h3><p>Check:</p><pre>sudo iptables -t nat -L -n -v</pre><p>Look at the packet counters.</p><h3>Layer 7 — Reverse Path Filtering</h3><p>Check:</p><pre>sysctl net.ipv4.conf.all.rp_filter<br>sysctl net.ipv4.conf.default.rp_filter</pre><p>Also check the VTI-specific value if applicable.</p><h3>Layer 8 — Destination Server</h3><p>Finally, verify that the actual application server is listening:</p><pre>ss -lntp</pre><p>and that its host firewall permits the translated source address.</p><h3>The Final Architecture</h3><p>We have now built a complete cross-cloud architecture for overlapping private CIDRs.</p><pre>AWS CLOUD<br>        +-------------------------------+<br>        |                               |<br>        |  Production VPC               |<br>        |  10.50.10.0/24                |<br>        |          |                    |<br>        |          v                    |<br>        |  AWS Transit Gateway          |<br>        |          |                    |<br>        |          v                    |<br>        |  Transit VPC                  |<br>        |  10.1.0.0/16                  |<br>        |          |                    |<br>        |          v                    |<br>        |  AWS Linux Router             |<br>        |  10.1.1.x                     |<br>        |          |                    |<br>        +----------|--------------------+<br>                   |<br>                   | IPsec<br>                   | encrypted tunnel<br>                   |<br>        +----------|--------------------+<br>        |          |                    |<br>        |  OCI Linux Router             |<br>        |  10.2.2.x                     |<br>        |          |                    |<br>        |          v                    |<br>        |  Transit VCN                  |<br>        |  10.2.0.0/16                  |<br>        |          |                    |<br>        |          v                    |<br>        |  OCI DRG                      |<br>        |          |                    |<br>        |          v                    |<br>        |  Production VCN               |<br>        |  10.50.10.0/24                |<br>        |                               |<br>        +-------------------------------+<br>                    OCI CLOUD</pre><p>And the Shadow Networks provide the separation:</p><pre>Real OCI:<br>10.50.10.0/24<br>       |<br>       | translated<br>       v<br>OCI Shadow:<br>10.10.10.0/24<br></pre><pre>Real AWS:<br>10.50.10.0/24<br>       |<br>       | translated<br>       v<br>AWS Shadow:<br>10.20.10.0/24</pre><p>The overlapping CIDRs never need to be directly routed across the cloud boundary.</p><h3>Conclusion: Did We Really Break the Rules of Routing?</h3><p>Not really.</p><p>We didn’t break routing.</p><p>We changed the <strong>address space that routing sees</strong>.</p><p>That is the important distinction.</p><p>The routers still obey the fundamental rule:</p><blockquote><em>A destination must map to a reachable next hop.</em></blockquote><p>The problem was that both clouds claimed the same destination space:</p><pre>10.50.10.0/24</pre><p>So we introduced two unique namespaces:</p><pre>OCI Shadow → 10.10.10.0/24<br>AWS Shadow → 10.20.10.0/24</pre><p>The Linux routers translate between the Shadow Networks and the real production networks.</p><p>The result is:</p><pre>REAL                  SHADOW</pre><pre>OCI          10.50.10.0/24  ←→  10.10.10.0/24</pre><pre>AWS          10.50.10.0/24  ←→  10.20.10.0/24</pre><p>The production environments remain untouched.</p><p>No application server needs to be renumbered.</p><p>No production CIDR needs to be redesigned.</p><p>And the two cloud environments can communicate through a controlled, encrypted transit architecture.</p><p>That is the real trick behind connecting overlapping CIDRs across AWS and OCI.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=818a097bbd90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Breaking the Laws of Routing: How to Connect Overlapping CIDRs Across AWS and OCI — Part 01 of 02]]></title>
            <link>https://medium.com/@ssrinuwas.r/breaking-the-laws-of-routing-how-to-connect-overlapping-cidrs-across-aws-and-oci-part-01-of-02-d56d2f302305?source=rss-f7fcf9015ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d56d2f302305</guid>
            <category><![CDATA[overlapping-cidr-network]]></category>
            <category><![CDATA[network-connectivity]]></category>
            <category><![CDATA[cidr]]></category>
            <dc:creator><![CDATA[SriNu SaMEinI]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 11:04:57 GMT</pubDate>
            <atom:updated>2026-08-26T11:04:57.140Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k8XGHpejChyF9XtdOKbk8w.png" /></figure><h3><strong>Introduction &amp; The Core Issue</strong></h3><p>In modern cloud engineering, overlapping Classless Inter-Domain Routing (CIDR) blocks are generally considered a fatal architectural design flaw. Every networking textbook states that if your Amazon Web Services (AWS) VPC and your Oracle Cloud Infrastructure (OCI) VCN share the exact same IP subnet (such as 10.0.0.0/24<strong> </strong>), they cannot communicate.</p><p>When a server in AWS tries to connect to an IP address in an overlapping range, AWS stops the connection locally. The system assumes the destination is inside its own network and blocks it from going over the internet. This triggers an immediate error message: <strong>“Overlapping CIDR blocks detected.”</strong></p><p>For IT teams, this network conflict creates a major problem. It usually happens during company mergers, system migrations, or when connecting with third-party vendors. In the past, the only fix was <strong>IP Re-addressing</strong> (changing all the IP addresses), which is slow and risky. Changing an entire company’s IP system causes three main problems:</p><ul><li><strong>Broken Applications:</strong> Hardcoded settings, database links, and software licenses tied to specific private IPs will instantly stop working.</li><li><strong>Messy Firewall Settings:</strong> Thousands of security rules and network policies must be rewritten and checked by hand.</li><li><strong>Expensive Downtime:</strong> Rebuilding a network to use new IP blocks requires a lot of planning and forces services to be offline for a long time.</li></ul><h3><strong>Executive Summary</strong></h3><p>This article explains how to safely connect two different cloud accounts — one in Amazon Web Services (<strong>AWS</strong>) and one in Oracle Cloud (<strong>OCI</strong>) — even though they are using the exact same range of internal network addresses (10.0.0.0/24). Normally, this identical numbering prevents communication, but this setup fixes the problem without forcing you to change a single IP address on your active servers.</p><h4><strong>The Strategy</strong></h4><p>To get around the strict routing rules built into cloud platforms, the design builds a dedicated “go-between” network layer (called a <strong>Double-NAT Transit Network</strong>). It uses two separate, uniquely numbered transit networks (10.2.0.0/16 for Oracle and 10.1.0.0/16 for AWS) that do not conflict with each other or the main servers.</p><p>Inside these helper networks, you deploy standard Linux virtual servers running <strong>Libreswan</strong>, a free, open-source security tool.</p><p>How It Works</p><ul><li><strong>The Secure Bridge:</strong> The Linux servers connect to one another over the internet, creating a highly secure, direct VPN tunnel (a route-based VTI IPsec bridge) between AWS and Oracle.</li><li><strong>The Traffic Translation:</strong> When a server wants to send data across clouds, it directs the traffic toward a set of temporary, “fake” placeholder addresses (Shadow CIDRs).</li><li><strong>The Mid-Air Swap:</strong> As the data passes through the Linux servers, a standard firewall utility (iptables NETMAP / Firewalld) automatically swaps the conflicting network numbers on the fly, while keeping the specific machine numbers at the end of the address intact.</li></ul><p>Because this translation happens entirely inside the transit loop, the underlying business applications never notice a thing. They send and receive data smoothly, believing they are talking directly to the other side.</p><pre>[ OCI Workload ] 10.0.0.99 (Real IP)<br>       │<br>       ▼ (Targets AWS Alias: 10.11.11.99)<br>[ OCI Transit VM ] 10.2.2.2 ──► Translates Source to 10.22.22.99<br>       │<br>       ▼ (Encrypted VTI IPsec Tunnel over Internet)<br>[ AWS Transit VM ] 10.1.1.1 ──► Translates Source back to 10.22.22.99<br>       │                        └──► Translates Destination to 10.0.0.99<br>       ▼<br>[ AWS Workload ] 10.0.0.99 (Real IP)</pre><h3>The Technical Solution: Step-by-Step</h3><p>Since you cannot change the <strong>real IPs</strong> on the servers, you use a <strong>Network Address Translation (NAT)</strong> gateway to give each cloud a temporary, fake alias called a <strong>Shadow CIDR</strong>:</p><ul><li><strong>Realm A’s Alias:</strong> 10.11.11.0/24 (How Realm A looks when talking to Realm B)</li><li><strong>Realm B’s Alias:</strong> 10.22.22.0/24 (How Realm B looks when talking to Realm A)</li></ul><p><strong>How the packet travels:</strong></p><ol><li><strong>A server in Realm A wants to talk to Realm B.</strong> It sends the packet to the fake alias: 10.22.22.99.</li><li><strong>The packet hits a Linux gateway running Libreswan</strong> (a VPN software).</li><li><strong>The gateway quickly changes the sender’s real IP to Realm A’s fake alias (</strong><strong>10.22.22.99)</strong> and sends it through a secure internet tunnel.</li><li><strong>On the other side, the gateway translates the fake destination back to the real destination (</strong><strong>10.0.0.99).</strong></li></ol><p>The servers think they are talking normally, completely unaware that their traffic is being rewritten in transit.</p><h4><strong>Why This Is Hard (The 3 Layers of Silent Failure)</strong></h4><p>The main takeaway of the article is that setting this up is a trap for engineers because a single mistake causes traffic to drop with <strong>zero error messages</strong>. It usually fails across three different layers:</p><p><strong>Layer 1: The Cryptographic Layer (VPN)</strong></p><p>If the security keys or the encryption algorithms (ciphers) don’t match perfectly between the two cloud regions, the tunnel won’t open.</p><ul><li><em>The Fix:</em> Look directly at the live logs (journalctl) rather than trusting documentation templates.</li></ul><p><strong>Layer 2: The Linux Kernel Layer (</strong><strong>rp_filter)</strong></p><p>Linux has a built-in security feature called <strong>Reverse-Path Filtering (</strong><strong>rp_filter)</strong>. When the inbound packet emerges from the tunnel, Linux looks at it before the fake address is translated. It thinks the packet is a malicious spoofing attempt and <strong>silently deletes it</strong>.</p><ul><li><em>The Fix:</em> You must explicitly turn off rp_filter on the gateway&#39;s network interfaces.</li></ul><p><strong>Layer 3: The Cloud Routing Layer (OCI DRG)</strong></p><p>Even if the Linux gateway is perfect, Oracle Cloud’s internal routers (Dynamic Routing Gateways) do not automatically pass traffic between different subnets in a hub-and-spoke setup.</p><ul><li><em>The Fix:</em> You must manually build explicit route distribution rules inside the OCI console so the cloud knows where to forward the packets.</li></ul><h4>The “Before” vs. “After” Reality</h4><p><strong>WITHOUT This Solution (The Old Way)</strong></p><ul><li><strong>The Block:</strong> You cannot create a standard VPN or cloud peering connection. The cloud consoles will throw an error saying “Overlapping CIDR blocks detected” and reject the connection entirely.</li><li><strong>The Consequence:</strong> To make them talk, an engineer would have to completely delete one of the networks, rebuild it with a new CIDR (like 192.168.1.0/24), reconfigure every server, update all firewall rules, and endure days of business downtime.</li></ul><p><strong>WITH This Solution (The New Way)</strong></p><ul><li><strong>The Magic:</strong> You trick the routing system. Instead of trying to route to the conflicting IP directly, AWS servers talk to a completely fake, non-overlapping alias (the Shadow CIDR, like 10.11.11.0/24).</li><li><strong>The Connectivity:</strong> The Linux gateway transparently maps the fake IP back to the real identical IP right at the edge of the tunnel.</li><li><strong>The Result:</strong> For the first time, a server at 10.0.0.99 in AWS can seamlessly send a packet, query a database, or sync a file with a server sitting at 10.0.0.99 in OCI.</li></ul><p>It gives you full cross-cloud connectivity while letting you keep your matching subnets completely untouched.</p><p>Before this solution existed, if you had to merge two companies, move to a new cloud provider, or connect to a vendor with the same IP space, you had only one choice: <strong>IP Re-numbering</strong>.</p><p>IP Re-numbering is an operational nightmare because:</p><ul><li><strong>Hardcoded Software:</strong> Many older or enterprise applications have their specific IP addresses hardcoded directly into the software code, configuration files, or database strings.</li><li><strong>Security &amp; Firewalls:</strong> Firewall rules, security lists, and active monitoring tools are explicitly tied to those specific IPs. Changing the IP means rewriting thousands of firewall rules.</li><li><strong>Licensing Locks:</strong> Enterprise software licenses are often bound directly to a server’s specific IP address. Changing the IP breaks the license and takes the application offline.</li><li><strong>Downtime Windows:</strong> Changing a company’s entire IP structure requires months of planning and massive downtime windows, which businesses cannot afford.</li></ul><p>The Ultimate Value Proposition</p><p>By using this “Shadow CIDR” NAT pattern, you get a zero-downtime, completely invisible network bridge.</p><p>It allows you to lift an entire environment out of one cloud and drop it into another cloud (or connect two separate clouds) instantly. The servers on both sides have absolutely no idea they are talking across clouds or that an IP conflict even exists. They keep their original identities before, during, and after the migration.</p><p>This concludes the theoretical breakdown of the Shadow CIDR architecture, the real-world operational issues it prevents, and the network layers where traffic typically fails. In Part 2, we will cover the actual implementation and configuration steps required to deploy this setup. We will walk through provisioning the Linux gateways, configuring Libreswan for the secure IPsec tunnel, writing the necessary iptables and NAT rules to manage the overlapping IPs, and adjusting the cloud routing tables and kernel filters to allow traffic to flow cleanly between the environments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d56d2f302305" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux AuditD Configuration Guide — Root Activity & System Change Monitoring]]></title>
            <link>https://medium.com/@ssrinuwas.r/linux-auditd-configuration-guide-root-activity-system-change-monitoring-bb7a51458da2?source=rss-f7fcf9015ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb7a51458da2</guid>
            <dc:creator><![CDATA[SriNu SaMEinI]]></dc:creator>
            <pubDate>Mon, 13 Apr 2026 06:22:19 GMT</pubDate>
            <atom:updated>2026-04-13T06:22:19.050Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Security and compliance are critical for any Linux environment. Monitoring <strong>root user activity</strong>, <strong>configuration changes</strong>, and <strong>file modifications</strong> helps detect unauthorized access and maintain system integrity.</p><p>This guide walks through configuring <strong>AuditD</strong> to monitor:</p><ul><li>Root login activity</li><li>Root command execution</li><li>File modifications</li><li>Sudo usage</li><li>SSH configuration changes</li><li>Directory monitoring</li><li>Network configuration changes</li><li>Time changes</li></ul><p>By the end of this guide, you’ll have <strong>enterprise-level audit logging</strong> configured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*wePIGmG6hi2wsYHMbPX0XA.png" /></figure><p>Configure AuditD to capture:</p><ul><li>Root login activity</li><li>Root commands executed</li><li>File modifications</li><li>Configuration changes</li><li>Sudo usage</li><li>SSH configuration changes</li><li>Directory monitoring (/etc, /var, /usr, /opt)</li><li>Network configuration changes</li><li>Time changes</li></ul><h3>Prerequisites</h3><p>Ensure <strong>AuditD</strong> is installed:</p><pre>rpm -qa | grep audit</pre><p>If not installed:</p><pre>dnf install audit -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*NMirKEbQN4J7aB48EeTgnw.png" /></figure><h3>Verify AuditD Status</h3><p>Check if AuditD is running:</p><pre>auditctl -s</pre><p>Expected Output:</p><pre>enabled 1</pre><p>This means AuditD is enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*s2rphBY6pEWJiNq31EhZeg.png" /></figure><h3>Create Custom Audit Rule File</h3><p>Create a new rule file:</p><pre>vi /etc/audit/rules.d/root-audit.rules</pre><h3>Add Audit Rules</h3><p>Paste the following configuration:</p><pre>###############################<br># Root Login Monitoring<br>###############################<br>-w /var/log/secure -p wa -k root_login<br>-w /var/run/faillock -p wa -k login_failures<br><br></pre><pre>###############################<br># Root Command Monitoring<br>###############################<br>-a always,exit -F arch=b64 -S execve -F euid=0 -k root_commands<br>-a always,exit -F arch=b32 -S execve -F euid=0 -k root_commands</pre><pre>###############################<br># Sudo / Privilege escalation<br>###############################<br>-w /etc/sudoers -p wa -k sudo_changes<br>-w /etc/sudoers.d -p wa -k sudo_changes<br>-w /usr/bin/sudo -p x -k sudo_usage<br>-w /bin/su -p x -k su_usage</pre><pre>###############################<br># User &amp; Password Changes<br>###############################<br>-w /etc/passwd -p wa -k user_changes<br>-w /etc/shadow -p wa -k password_changes<br>-w /etc/group -p wa -k group_changes</pre><pre>###############################<br># SSH Changes<br>###############################<br>-w /etc/ssh/sshd_config -p wa -k ssh_changes</pre><pre>###############################<br># Directory Monitoring<br>###############################<br>-w /etc -p wa -k etc_changes<br>-w /var -p wa -k var_changes<br>-w /usr -p wa -k usr_changes<br>-w /opt -p wa -k opt_changes</pre><pre>###############################<br># Root File Changes in /opt<br>###############################<br>-a always,exit -F dir=/opt -F euid=0 -S open,openat,creat,unlink,rename -k root_opt_changes</pre><pre>###############################<br># Time Change Monitoring<br>###############################<br>-a always,exit -F arch=b64 -S adjtimex,settimeofday -k time_change</pre><pre>###############################<br># Network Configuration Changes<br>###############################<br>-w /etc/sysconfig/network -p wa -k network_changes<br>-w /etc/hosts -p wa -k network_changes<br>-w /etc/resolv.conf -p wa -k network_changes</pre><pre>###############################<br># Lock Audit Configuration<br>###############################<br>-e 2</pre><p>Save and exit the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*vYRzVezcg0pK7VXJUn3fVQ.png" /></figure><h3>Load Audit Rules</h3><p>Apply rules:</p><pre>augenrules --load</pre><p>OR</p><pre>systemctl restart auditd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*bFl74ocBSSnnSLJG65Q2sw.png" /></figure><h3>Verify Rules</h3><pre>auditctl -l</pre><p>This displays all configured audit rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*DUp6rI1Ye2Z8tyIprL3nQA.png" /></figure><h3>Verify Audit Status</h3><pre>auditctl -s</pre><p>Expected Output:</p><pre>enabled 2</pre><h3>What Does This Mean?</h3><p>Value — — — — — — — Meaning</p><p>0 — — — — — — — — — Disabled</p><p>1 — — — — — — — — — Enabled</p><p>2 — — — — — — — — — Enabled and Locked</p><p>When set to <strong>2</strong>, rules cannot be modified without reboot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*YRCcTztedtvN1aw5cwDMMw.png" /></figure><h3>Testing Audit Rules</h3><p>Test root command:</p><pre>touch /opt/testfile</pre><p>Verify logs:</p><pre>ausearch -k root_opt_changes</pre><h3>Check Audit Logs</h3><p>View logs in real-time:</p><pre>tail -f /var/log/audit/audit.log</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w37R_bAXVtMLCVas2dfAFA.png" /></figure><h3>Useful Audit Commands</h3><p>Check root commands:</p><pre>ausearch -k root_commands</pre><p>Check root login:</p><pre>ausearch -k root_login</pre><p>Check sudo usage:</p><pre>ausearch -k sudo_usage</pre><p>Check file changes:</p><pre>ausearch -k opt_changes</pre><h3>Enable AuditD on Boot</h3><pre>systemctl enable auditd</pre><h3>Log File Location</h3><p>Audit logs stored at:</p><pre>/var/log/audit/audit.log</pre><h3>Important Notes</h3><ul><li>Audit configuration is locked using -e 2</li><li>Requires reboot to disable audit</li><li>Recommended for production environments</li></ul><h3>Rollback Procedure</h3><p>To disable audit:</p><p>Remove:</p><pre>-e 2</pre><p>Then reboot:</p><pre>reboot</pre><h3>Check Audit Configuration Status</h3><pre>auditctl -s</pre><h3>Conclusion</h3><p>With this configuration, your Linux system now has <strong>enterprise-grade auditing</strong>:</p><ul><li>Root user monitoring</li><li>Configuration tracking</li><li>File integrity monitoring</li><li>Security auditing</li><li>Compliance readiness</li></ul><p>This setup is ideal for:</p><ul><li>Production servers</li><li>Security environments</li><li>Compliance requirements (PCI, ISO, SOC2)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb7a51458da2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Compartments Work in Oracle Cloud Infrastructure]]></title>
            <link>https://medium.com/@ssrinuwas.r/how-compartments-work-in-oracle-cloud-infrastructure-63f97a34a175?source=rss-f7fcf9015ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/63f97a34a175</guid>
            <dc:creator><![CDATA[SriNu SaMEinI]]></dc:creator>
            <pubDate>Tue, 31 Mar 2026 12:53:36 GMT</pubDate>
            <atom:updated>2026-03-31T12:53:36.568Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*R33hqgX20OcSsiGx.jpeg" /></figure><h3>What is a Compartment in OCI? (Proper Explanation First)</h3><p>In Oracle Cloud Infrastructure (OCI), a <strong>Compartment</strong> is a <strong>logical container used to organize and control access to cloud resources</strong>.</p><p>Think of compartments as <strong>folders</strong> inside your cloud environment where you keep related resources together.</p><h3>Why Compartments Are Used</h3><p>Compartments help you:</p><ul><li>Organize resources properly</li><li>Control access using IAM policies</li><li>Separate environments (Dev, Test, Prod)</li><li>Improve security</li><li>Track costs and billing</li></ul><h3>OCI Hierarchy (Very Important)</h3><p>OCI follows this structure:</p><pre>Region<br>  └── Tenancy<br>        └── Compartment<br>              └── Resources</pre><h3>Example:</h3><pre>Region: Mumbai<br>   │<br>   └── Tenancy: ABC Company<br>         │<br>         ├── Network Compartment<br>         ├── Production Compartment<br>         ├── Testing Compartment<br>         └── Development Compartment</pre><h3>Example with VCN</h3><p>Let’s say you create a <strong>Network Compartment</strong></p><p>Inside this compartment, you create:</p><pre>Network Compartment<br>     │<br>     ├── VCN (10.0.0.0/16)<br>     │     ├── Public Subnet<br>     │     └── Private Subnet<br>     │<br>     ├── Internet Gateway<br>     └── Route Tables</pre><h3>Example with Multiple Compartments</h3><pre>ABC Company Tenancy<br>│<br>├── Network Compartment<br>│     └── VCN<br>│<br>├── Production Compartment<br>│     ├── App Servers<br>│     └── Database<br>│<br>├── Testing Compartment<br>│     └── Test Servers<br>│<br>└── Development Compartment<br>      └── Dev Servers</pre><h3>Region Example</h3><p>Compartments exist <strong>inside Tenancy</strong>, and Tenancy exists <strong>inside Region</strong>.</p><p>You can use the same compartments in different regions:</p><pre>Region: Mumbai<br>Region: Hyderabad</pre><pre>Both can use:</pre><pre>- Network Compartment<br>- Production Compartment<br>- Testing Compartment</pre><h3>Sub-Compartments</h3><p>You can also create <strong>Sub-Compartments</strong> inside compartments.</p><p>Example:</p><pre>Production<br>│<br>├── App Servers<br>├── Database<br>└── Monitoring</pre><p>This helps in <strong>better organization and security</strong>.</p><h3>Real World Example</h3><p>Company Structure:</p><pre>Company Tenancy<br>│<br>├── Shared Services<br>│    └── VCN<br>│<br>├── Production<br>│    ├── Application<br>│    └── Database<br>│<br>└── Non-Production<br>     ├── Dev<br>     └── Test</pre><h3>Simple Definition</h3><p><strong>Compartments in OCI are logical containers used to organize, secure, and manage cloud resources.</strong></p><h3>5 Year Old Story Version</h3><p>Imagine you have a <strong>big house</strong></p><p>This house is your <strong>Cloud (OCI)</strong></p><p>Inside the house, you have <strong>many rooms</strong>:</p><ul><li>Bedroom</li><li>Kitchen</li><li>Playroom</li><li>Study room</li></ul><p>These <strong>rooms are Compartments</strong>.</p><p>Now inside each room, you keep different things:</p><p>Playroom → Toys<br>Study Room → Books<br>Kitchen → Food<br>Bedroom → Bed</p><p>Same way in OCI:</p><ul><li>Network Room → VCN</li><li>Production Room → Servers</li><li>Testing Room → Test Machines</li><li>Dev Room → Developers</li></ul><p>Now imagine:</p><p>Your <strong>house is in a city</strong> <br> That <strong>city is called Region</strong></p><p>Example:</p><ul><li>Mumbai Region</li><li>Hyderabad Region</li></ul><p>Full Story Example</p><p>You have:</p><p>City → Mumbai (Region)<br>House → Company Cloud (Tenancy)<br>Rooms → Compartments<br>Toys → Resources</p><pre>Mumbai City (Region)<br>   │<br>   House (Tenancy)<br>   │<br>   ├── Play Room (Dev)<br>   ├── Study Room (Test)<br>   ├── Work Room (Prod)<br>   └── Network Room (VCN)</pre><h3>One Line Story Version</h3><p><strong>Compartments in OCI are like rooms in a house where you keep your cloud resources organized.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63f97a34a175" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step-by-Step OCI VCN Creation: Mumbai Region Setup Guide]]></title>
            <link>https://medium.com/@ssrinuwas.r/step-by-step-oci-vcn-creation-mumbai-region-setup-guide-54597bf87a24?source=rss-f7fcf9015ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/54597bf87a24</guid>
            <category><![CDATA[oci]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[oci-networking]]></category>
            <category><![CDATA[oci-infras]]></category>
            <category><![CDATA[vcn]]></category>
            <dc:creator><![CDATA[SriNu SaMEinI]]></dc:creator>
            <pubDate>Tue, 31 Mar 2026 11:47:02 GMT</pubDate>
            <atom:updated>2026-03-31T11:47:02.676Z</atom:updated>
            <content:encoded><![CDATA[<p>Setting up a Virtual Cloud Network (VCN) in Oracle Cloud Infrastructure (OCI) is foundational for secure, scalable cloud deployments. This guide walks through creating a production-ready VCN with public/private subnets, tailored for Mumbai region compute workloads — perfect for DevOps teams managing OCI environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*puxP6eDxlaITsSE_" /></figure><p><strong>Oracle Cloud Infrastructure (OCI) VCN Creation and Networking Configuration Guide</strong></p><p><em>“Always verify the region and compartment before launching any resources. Ensure that you are working in the correct region and selecting the appropriate compartment every time.” — According to your scenario</em></p><p>1. Click on hamburger &gt; Navigate to Networking</p><p>From the left-side menu: <strong>Menu → Networking → Virtual Cloud Networks</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*yHrYOWzz5kA296xgTEdjhw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*PnsGjoag9aFiRkj28OfZ4Q.png" /></figure><p>2. <strong>Click on <em>Create VCN</em>.</strong><br> Provide the following details:</p><ul><li><strong>Name:</strong> Mumbai_Compute_VCN</li><li><strong>Compartment:</strong> Mumbai-Compute-Compartment<br> <em>(Select the appropriate compartment based on your environment.)</em></li><li><strong>IPv4 CIDR Block:</strong> 10.0.0.0/16<br> <em>(Use the CIDR block that matches your design. Make sure it does not overlap with existing networks.)</em></li><li>Leave all other settings at their <strong>default values</strong>, and then click <strong>Create VCN</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*M3FVC5KLlWqP-M-12lzUmg.png" /></figure><p>On the next page, you will see the VCN listed with its status shown as <em>Available</em>.</p><p>3. Click on Subnets (we will create subnets for our Network)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*lwQUHeSzrPULUVLqggmb2g.png" /></figure><p>· Click on Create Subnet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*Ee7V-lxaxu_ruqt6S8ZvRA.png" /></figure><p>Public Subnet Configuration Details</p><p>Provide the following details for creating the subnet:</p><ul><li>Subnet Name: Mumbai_Compute_VCN</li><li>Compartment: Mumbai-Compute_Compartment</li><li>Subnet Type: Regional <em>(Recommended)</em></li><li>IPv4 CIDR Block: 10.0.0.0/24</li><li>IPv6 Prefixes: <em>Default</em></li><li>Subnet Access: Public Subnet</li><li>Other Settings: Keep all remaining options at their default values</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*I1TtL9yoKuxAZIbj4cD6kA.png" /></figure><p>We have created Public Subnet now we will create Private Subnet</p><p>Private Subnet Configuration Details</p><p>Provide the following details for creating the subnet:</p><ul><li>Subnet Name: Mumbai_Compute_Subnet_Private</li><li>Compartment: Mumbai-Compute_Compartment</li><li>Subnet Type: Regional <em>(Recommended)</em></li><li>IPv4 CIDR Block: 10.0.1.0/24</li><li>IPv6 Prefixes: <em>Default</em></li><li>Subnet Access: Private Subnet</li><li>Other Settings: Keep all remaining options at their default values</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*Ft2RYsAr7iM46C4RLeKzOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*2jfAeFVaQQwYkUYnIBNWSw.png" /></figure><p><strong>4.</strong> <strong>Navigate to Security Lists in Your VCN</strong></p><p>Now we need to create <strong>Security Lists</strong> inside the VCN.<br> You must create <strong>separate Security Lists</strong> for both the <strong>Public Subnet</strong> and the <strong>Private Subnet</strong>.</p><p>Follow the navigation path below:</p><p>· Click on the <strong>Hamburger Menu</strong> (☰) in the OCI Console.</p><p>· Go to <strong>Networking</strong>.</p><p>· From the left‑side menu, select:<br> <strong>Menu → Networking → Virtual Cloud Networks (</strong>Check the compartment)</p><p>· Choose <strong>your VCN</strong>.</p><p>· Click on <strong>Security Lists</strong> from the VCN details page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*KjjM7aTdvpHxm_0PeSmMsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*E7kjGG9KEzRG0uFR1bSKfQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*xyUbWvKt2-EGSeqnIw9DOw.png" /></figure><p>In Security List Column we can see Default Security List Now we need to Create New SL</p><p>· Click on Create Security List</p><p><strong>Create Security List for Public Subnet</strong></p><p>Provide the following details to create the <strong>Public Subnet Security List</strong>:</p><p><strong>Security List Details</strong></p><ul><li><strong>Name:</strong> Mumbai_Compute_Public_SL</li><li><strong>Compartment:</strong> Mumbai_Compute_Compartment</li></ul><p><strong>Add Ingress Rules</strong></p><p>Configure the inbound traffic rules:</p><ul><li><strong>Source Type:</strong> CIDR</li><li><strong>Source CIDR:</strong> 0.0.0.0/0<br> <em>(This opens the subnet to all sources; you may restrict this based on your security policy.)</em></li><li><strong>IP Protocol:</strong> TCP</li><li><strong>Destination:</strong> All</li><li><strong>Description:</strong> <em>(Add a meaningful description as per your environment.)</em></li></ul><p>You can further customize ingress rules to allow only required ports such as:</p><ul><li>TCP 22 for SSH</li><li>TCP 80/443 for web traffic</li><li>ICMP for ping (optional)</li></ul><p><strong>Add Egress Rules</strong></p><p>Configure outbound traffic rules:</p><ul><li><strong>Destination Type:</strong> CIDR</li><li><strong>Destination CIDR:</strong> 0.0.0.0/0<br> <em>(Outbound should typically remain open for all.)</em></li><li><strong>IP Protocol:</strong> TCP</li><li><strong>Destination:</strong> All</li><li><strong>Description:</strong> <em>Outbound open for ALL</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*F0zx-ghPJoHsUJZJK7tobA.png" /></figure><p>Click on Security List</p><p><strong>Create Security List for Private Subnet</strong></p><p>Provide the following details to create the <strong>Private Subnet Security List</strong>:</p><p><strong>Security List Details</strong></p><ul><li><strong>Name:</strong> Mumbai_Compute_Private_SL</li><li><strong>Compartment:</strong> Mumbai_Compute_Compartment</li></ul><p><strong>Add Ingress Rules</strong></p><p>Configure inbound traffic allowed <em>within the VCN</em>:</p><ul><li><strong>Source Type:</strong> CIDR</li><li><strong>Source CIDR:</strong> 10.0.0.0/16<br> <em>(Use the VCN CIDR block. This allows internal communication between subnets.)</em></li><li><strong>IP Protocol:</strong> TCP</li><li><strong>Destination:</strong> All</li><li><strong>Description:</strong> <em>(Provide a meaningful description.)</em></li></ul><p><strong>Add Egress Rules</strong></p><p>Configure outbound traffic permissions:</p><ul><li><strong>Destination Type:</strong> CIDR</li><li><strong>Destination CIDR:</strong> 0.0.0.0/0<br> <em>(Outbound should remain open for all so private instances can reach the internet via NAT Gateway.)</em></li><li><strong>IP Protocol:</strong> TCP</li><li><strong>Destination:</strong> All</li><li><strong>Description:</strong> <em>Outbound open for ALL</em></li></ul><p>Click on Security List</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*T9Oa8L5EMqYYCuWWmwzetw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*f5A6caudLyo8PQg7gRvdJA.png" /></figure><p><strong>5.</strong> <strong>Navigate to Internet Gateway &amp; Nat Gateway in Your VCN</strong></p><p>Now we need to create <strong>Internet Gateway &amp; NAT Gateway</strong> inside the VCN.</p><p>Use the following navigation steps</p><p>· Click on the <strong>Hamburger Menu</strong> (☰) in the OCI Console.</p><p>· Go to <strong>Networking</strong>.</p><p>· From the left‑side menu, select:<br> <strong>Menu → Networking → Virtual Cloud Networks (</strong>Check the compartment)</p><p>· Choose <strong>your VCN</strong>.</p><p>· Click on <strong>Gateways </strong>from the VCN details page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*KjjM7aTdvpHxm_0PeSmMsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*tbknuFNBWsqgGP7rMp-6BQ.png" /></figure><p>Scroll down to search of Internet Gateways and NAT Gateways</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*i6P_a7zlVyYPBHgT1K-Wsw.png" /></figure><p><strong>Create Internet Gateway for Public Subnet</strong></p><p>Follow the steps below to create the Internet Gateway for your VCN:</p><p>· <strong>Name:</strong> Mumbai_Compute_IGW</p><p>· <strong>Public IP Type:</strong><br> You may choose either:</p><p>o <strong>Reserved Public IP</strong>, or</p><p>o <strong>Ephemeral Public IP</strong></p><p><em>(Select based on your requirement and network design.)</em></p><p>· Click <strong>Create</strong> to provision the Internet Gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*VoRfJmPfGGEVXovRUpSbbQ.png" /></figure><p><strong>Create NAT Gateway for Public Subnet</strong></p><p>Follow the steps below to create the NAT Gateway for your VCN:</p><p>· <strong>Name:</strong> Mumbai_Compute_NAT</p><p>· <strong>Public IP Type:</strong><br> You may choose either:</p><p>o <strong>Reserved Public IP</strong>, or</p><p>o <strong>Ephemeral Public IP</strong></p><p><em>(Select based on your requirement and network design.)</em></p><p>· Click <strong>Create</strong> to provision the NAT Gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Q0SXOfBbIq_7VQ6coJNQfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*06Sqr1orCxy3ximHGz0SQQ.png" /></figure><p>Now Need to Create two Routing Tables one for Public Routing and Private Routing</p><p><strong>6.</strong> <strong>Navigate to Routing in Your VCN</strong></p><p>Now we need to create <strong>Route Table</strong> inside the VCN.</p><p>Use the following navigation steps</p><p>· Click on the <strong>Hamburger Menu</strong> (☰) in the OCI Console.</p><p>· Go to <strong>Networking</strong>.</p><p>· From the left‑side menu, select:<br> <strong>Menu → Networking → Virtual Cloud Networks (</strong>Check the compartment)</p><p>· Choose <strong>your VCN</strong>.</p><p>· Click on <strong>Routing </strong>from the VCN details page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*OS7mBCCPSHuWow5qhP8vPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*mif0_dkmQwHniBz-FiYQmw.png" /></figure><p><strong>Create Route Table for Private Subnet</strong></p><p>Follow the steps below to create the <strong>Private Route Table</strong>, which will route outbound traffic from the private subnet to the NAT Gateway:</p><p>· Click on <strong>Create Route Table</strong>.</p><p>· Provide the following details:</p><ul><li><strong>Name:</strong> Mumbai_Compute_RT_Private</li><li><strong>Compartment:</strong> Mumbai_Compute_Compartment</li><li><strong>Target Type:</strong> <strong>NAT Gateway</strong></li><li><strong>Destination CIDR Block:</strong> 0.0.0.0/0<br> <em>(This sends all outbound internet traffic from the private subnet to the NAT Gateway.)</em></li><li><strong>Target NAT Gateway:</strong> Mumbai_Compute_NAT<br> <em>(The NAT Gateway you created earlier.)</em></li><li><strong>Description:</strong> <em>(Enter a suitable description based on your environment.)</em></li></ul><p>· Click <strong>Create</strong> to finalize the route table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*ofmDtabA_fkrZGSo_xO8-g.png" /></figure><p><strong>Create Route Table for Public Subnet</strong></p><p>Follow the steps below to create the <strong>Public Route Table</strong>, which will route outbound traffic from the private subnet to the NAT Gateway:</p><p>· Click on <strong>Create Route Table</strong>.</p><p>· Provide the following details:</p><ul><li><strong>Name:</strong> Mumbai_Compute_RT_Public</li><li><strong>Compartment:</strong> Mumbai_Compute_Compartment</li><li><strong>Target Type:</strong> <strong>Internet Gateway</strong></li><li><strong>Destination CIDR Block:</strong> 0.0.0.0/0<br> <em>(This sends all outbound internet traffic from the private subnet to the NAT Gateway.)</em></li><li><strong>Target NAT Gateway:</strong> Mumbai_Compute_IGW<br> <em>(The NAT Gateway you created earlier.)</em></li><li><strong>Description:</strong> <em>(Enter a suitable description based on your environment.)</em></li></ul><p>· Click <strong>Create</strong> to finalize the route table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*xWjlSQXa4mVbBLrbvUFWCg.png" /></figure><p>7. Add the Route Tables and Security List to respective Subnets</p><p>Click on hamburger &gt; Navigate to Networking</p><p>From the left-side menu: <strong>Menu → Networking → Virtual Cloud Networks à Your VCN à Subnets</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*POKPMKzupM4fadVSMokVPA.png" /></figure><p><strong>Updating Route Table for Public Subnet (Mumbai-Compute_VCN)</strong></p><p>· Navigate to the <strong>Public Subnet</strong> under <strong>Mumbai-Compute_VCN</strong>.</p><p>· Click on <strong>Actions</strong> and select <strong>Edit</strong>.</p><p>· In the <strong>Route Table</strong> section, change the selection from <strong>Default</strong> to <strong>Mumbai_Compute_RT_Public</strong> (the route table previously created).</p><p>· Keep all other settings at their <strong>default values</strong>.</p><p>· Click <strong>Save Changes</strong> to apply the update.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*VZD8vZFuiZrKRVkx5HBgIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*mCVKlbYjclbtjk8oRjg0yQ.png" /></figure><p><strong>Updating Route Table for Private Subnet (Mumbai-Compute_VCN)</strong></p><p>· Navigate to the <strong>Private Subnet</strong> under <strong>Mumbai-Compute_VCN</strong>.</p><p>· Click on <strong>Actions</strong> and select <strong>Edit</strong>.</p><p>· In the <strong>Route Table</strong> section, change the selection from <strong>Default</strong> to <strong>Mumbai_Compute_RT_Private</strong> (the route table previously created).</p><p>· Keep all other settings at their <strong>default values</strong>.</p><p>· Click <strong>Save Changes</strong> to apply the update.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*9c7pn9cCzeAmVm0fGrnGRQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*WLkP7fS-egZJTpJsGR_gqg.png" /></figure><p><strong>Adding Security List to Public Subnet (Mumbai_Compute_Subnet_Public)</strong></p><p>· Navigate to the <strong>Public Subnet</strong>:<br> <strong>Mumbai_Compute_Subnet_Public</strong>.</p><p>· Go to the <strong>Security</strong> section.</p><p>· Click on <strong>Add Security</strong>.</p><p>· Drill down through the list and select the <strong>Public Security List</strong>:<br> <strong>Mumbai_Compute_Public_SL</strong>.</p><p>· Click <strong>Add Security List</strong> to apply the configuration.</p><p>· Remove the Default Security List.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*v1cyl8r_Zh6qsK8Be2r8QQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*09qodhwq9thWWw1J-SzqAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*y9WpMmLDIE_lVuYoUI9UUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*hUFpBdoL6TCpVo64RMacpQ.png" /></figure><p><strong>Adding Security List to Private Subnet(Mumbai_Compute_Subnet_Private)</strong></p><p>· Navigate to the <strong>Private Subnet</strong>:<br> <strong>Mumbai_Compute_Subnet_Private</strong>.</p><p>· Go to the <strong>Security</strong> section.</p><p>· Click on <strong>Add Security</strong>.</p><p>· Drill down through the list and select the <strong>Private Security List</strong>:<br> <strong>Mumbai_Compute_Private_SL</strong>.</p><p>· Click <strong>Add Security List</strong> to apply the configuration.</p><p>· Remove the Default Security List.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*MMZEZFSbtAbAcagwK0KaJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*_I1m1UYgCn4I-fO62iHCYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*wD6P2Tkhpneo2O_1ygek0g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54597bf87a24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Serverless AI Chatbot with Amazon Bedrock Titan Model, AWS Lambda, API Gateway ,S3 &…]]></title>
            <link>https://medium.com/@ssrinuwas.r/building-a-serverless-ai-chatbot-with-amazon-bedrock-titan-model-aws-lambda-api-gateway-s3-16153add1efc?source=rss-f7fcf9015ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/16153add1efc</guid>
            <dc:creator><![CDATA[SriNu SaMEinI]]></dc:creator>
            <pubDate>Mon, 26 May 2025 14:01:57 GMT</pubDate>
            <atom:updated>2025-05-26T14:01:57.237Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Serverless AI Chatbot with Amazon Bedrock Titan Model, AWS Lambda, API Gateway ,S3 &amp; AWS Amplify</h3><p>Artificial Intelligence is transforming the way we build applications, and with the advent of foundation models via services like <strong>Amazon Bedrock</strong>, it’s now easier than ever to integrate powerful language models into your apps — without managing infrastructure or machine learning pipelines.</p><p>In this guide, we will build a <strong>serverless AI chatbot assistant</strong> using:</p><ul><li><strong>Amazon Bedrock</strong> with <strong>Titan Text G1 — Express</strong> model to generate responses</li><li><strong>AWS Lambda</strong> for backend logic</li><li><strong>Amazon API Gateway</strong> to serve as the API layer</li><li><strong>Amazon S3 and Amplify Hosting</strong> to host a simple frontend UI</li></ul><p>Whether you’re building an AI-powered FAQ bot, a customer service assistant, or an educational companion, this step-by-step tutorial will give you a solid foundation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*AYofRmnHDCRve4pHe02JGg.png" /></figure><h3>Architecture Overview: How Everything Works</h3><p>Before diving into implementation, let’s visualize how the architecture components interact.</p><h3>Flow of Interaction:</h3><ol><li>A user interacts with a chatbot via a <strong>web-based UI</strong> hosted on <strong>Amazon S3</strong>, connected via <strong>AWS Amplify Hosting</strong>.</li><li>When the user sends a message, it’s packaged as a <strong>POST request</strong> and sent over HTTPS to <strong>Amazon API Gateway</strong>.</li><li><strong>API Gateway</strong> securely routes the request to a <strong>Lambda function</strong> that contains the core logic.</li><li>The Lambda function:</li></ol><ul><li>Reads and handles the input message</li><li>Authenticates using <strong>IAM Role</strong></li><li>Invokes <strong>Amazon Bedrock</strong>, specifically the <strong>Titan Text G1 — Express</strong> model</li></ul><p>5. Amazon Bedrock returns a generated text response.</p><p>6. The Lambda function sends the response back through the API Gateway.</p><p>7. Finally, the frontend receives the reply and displays it to the user in the chat interface.</p><h3>Security Consideration</h3><ul><li>The <strong>IAM Role</strong> assigned to Lambda ensures <strong>fine-grained access</strong> only to Bedrock and CloudWatch.</li><li>All traffic flows through <strong>HTTPS</strong> for encrypted communication.</li><li>No servers are managed; it’s <strong>fully serverless</strong>, reducing attack surface and operational overhead.</li></ul><h3>Step-by-Step Implementation</h3><blockquote>Step 1: Enable Amazon Bedrock and Choose Titan Model</blockquote><ol><li><strong>Login to AWS Console</strong></li><li>In the Services search bar, type <strong>Amazon Bedrock</strong> and navigate to it.</li><li>Ensure you’re in a <strong>supported AWS region</strong> (e.g., us-east-1)</li><li>In the left navigation pane, click on <strong>Model access</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYikQC-uja02M6WIe7PsZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*uFJTPqe8uFPpPrhkT6mvvw.png" /></figure><p>5. You’ll see a list of foundation models from various providers (Anthropic, Cohere, Stability AI, Amazon, etc.).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7DDCKbWmyDrsMjo0sfv7tg.png" /></figure><p>6. Scroll to <strong>Amazon Titan</strong> and select <strong>Titan Text G1 — Express</strong>.</p><p>7. Enable access if it’s not already granted. This will allow your account to invoke this model from code.</p><blockquote><strong><em>Note:</em></strong><em> Bedrock models are available only in selected AWS regions. Be sure to deploy your Lambda function and API Gateway in the same region.</em></blockquote><blockquote>Step 2: Create IAM Role for Lambda Function</blockquote><ol><li>Navigate to <strong>IAM</strong> in AWS.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WxAdtpmim-7X3llhXQalJA.png" /></figure><p>2. Click on <strong>Roles</strong> → <strong>Create Role</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QMW6la80NbL3puq95eXThg.png" /></figure><p>3. Choose <strong>AWS Service</strong> as the trusted entity.</p><p>4. Under <strong>use case</strong>, select <strong>Lambda</strong>.</p><p>5. Attach the following policies:</p><ul><li><strong>AmazonBedrockFullAccess</strong> — Allows Lambda to invoke models in Bedrock.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNZ8bj-VSH-tfIFuoNyfnw.png" /></figure><ul><li><strong>CloudWatchLogsFullAccess</strong> — Enables Lambda to write execution logs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CCbRajjIi3uSQZiiTjcoog.png" /></figure><p>6. Click <strong>Next</strong>, then provide a Role Name: ChatBotLambdaRole.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*Qwltxsoznh9ll75dY8bODg.png" /></figure><p>7. Create the role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DUf_9p89DCpB7zf3btBjmA.png" /></figure><blockquote>This role will be assumed by your Lambda function. It is crucial for securely accessing Amazon Bedrock without embedding credentials.</blockquote><blockquote>Step 3: Create the Lambda Function to Talk to Bedrock</blockquote><h4>Create the Function:</h4><ol><li>Go to the <strong>Lambda</strong> service from AWS Console.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HEGHbyzquIRPo2tt8AO7UA.png" /></figure><p>2. Click <strong>Create Function</strong>.</p><ul><li>Choose:</li><li><strong>Author from Scratch</strong></li><li><strong>Function Name</strong>: chatbotlambda</li><li><strong>Runtime</strong>: Python 3.13 (or the version of your choice)</li><li>Under <strong>Permissions</strong>, choose <strong>Use existing role</strong> → Select ChatBotLambdaRole</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJDLdOw835e1ntECjSlljA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hv6_3ouSZvHmYOY4b69PVw.png" /></figure><ul><li>Click <strong>Create Function</strong>.</li></ul><h4>Update Function Configuration:</h4><ul><li>Navigate to the <strong>Configuration tab</strong> → <strong>General configuration</strong>.</li><li>Click <strong>Edit</strong>, update:</li><li><strong>Memory</strong>: 500 MB</li><li><strong>Timeout</strong>: 15 minutes (900 seconds)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-RSLZgC6qPmwqYbUxZJVRA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lM8mR4Eo--bm97ixsx5ayw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L_ythVUJJqPrdjEKKCW9oA.png" /></figure><p>This ensures the function doesn’t timeout during large or slow Bedrock responses.</p><h4>Paste Lambda Code:</h4><p>Inside the Lambda function editor:</p><ol><li>Open the <strong>Code</strong> tab</li></ol><pre>import json<br>import boto3<br><br>def lambda_handler(event, context):<br>    try:<br>        if event.get(&quot;httpMethod&quot;) == &quot;OPTIONS&quot;:<br>            return cors_response(&quot;CORS preflight successful&quot;)<br><br>        raw_body = event.get(&quot;body&quot;, &quot;{}&quot;)<br>        body = json.loads(raw_body) if isinstance(raw_body, str) else raw_body<br><br>        mode = body.get(&quot;mode&quot;, &quot;text&quot;)<br>        message = body.get(&quot;message&quot;, &quot;&quot;)<br>        history = body.get(&quot;history&quot;, [])<br><br>        if not message:<br>            return error_response(&quot;Message is required.&quot;)<br><br>        bedrock = boto3.client(&quot;bedrock-runtime&quot;)<br><br>        if mode == &quot;image&quot;:<br>            payload = {<br>                &quot;textToImageParams&quot;: { &quot;text&quot;: message },<br>                &quot;taskType&quot;: &quot;TEXT_IMAGE&quot;,<br>                &quot;imageGenerationConfig&quot;: {<br>                    &quot;cfgScale&quot;: 8,<br>                    &quot;seed&quot;: 42,<br>                    &quot;quality&quot;: &quot;standard&quot;,<br>                    &quot;width&quot;: 1024,<br>                    &quot;height&quot;: 1024,<br>                    &quot;numberOfImages&quot;: 1<br>                }<br>            }<br><br>            response = bedrock.invoke_model(<br>                modelId=&quot;amazon.titan-image-generator-v2:0&quot;,<br>                contentType=&quot;application/json&quot;,<br>                accept=&quot;application/json&quot;,<br>                body=json.dumps(payload)<br>            )<br><br>            result = json.loads(response[&#39;body&#39;].read())<br>            # ✅ Fix: Titan returns a list of base64 strings, not dictionaries<br>            base64_image = result[&#39;images&#39;][0]<br>            return success_response({ &quot;response&quot;: [{ &quot;base64&quot;: base64_image }] })<br><br>        else:<br>            payload = {<br>                &quot;inputText&quot;: message,<br>                &quot;textGenerationConfig&quot;: {<br>                    &quot;maxTokenCount&quot;: 512,<br>                    &quot;temperature&quot;: 0.5,<br>                    &quot;topP&quot;: 0.9<br>                }<br>            }<br><br>            response = bedrock.invoke_model(<br>                modelId=&quot;amazon.titan-text-express-v1&quot;,<br>                contentType=&quot;application/json&quot;,<br>                accept=&quot;application/json&quot;,<br>                body=json.dumps(payload)<br>            )<br><br>            result = json.loads(response[&#39;body&#39;].read())<br>            text = result[&#39;results&#39;][0][&#39;outputText&#39;]<br>            return success_response({ &quot;response&quot;: text })<br><br>    except Exception as e:<br>        return error_response(str(e))<br><br><br>def success_response(data):<br>    return {<br>        &quot;statusCode&quot;: 200,<br>        &quot;headers&quot;: { &quot;Content-Type&quot;: &quot;application/json&quot;, &quot;Access-Control-Allow-Origin&quot;: &quot;*&quot; },<br>        &quot;body&quot;: json.dumps(data)<br>    }<br><br>def error_response(message):<br>    return {<br>        &quot;statusCode&quot;: 500,<br>        &quot;headers&quot;: { &quot;Content-Type&quot;: &quot;application/json&quot;, &quot;Access-Control-Allow-Origin&quot;: &quot;*&quot; },<br>        &quot;body&quot;: json.dumps({ &quot;response&quot;: f&quot;Error: {message}&quot; })<br>    }<br><br>def cors_response(message):<br>    return {<br>        &quot;statusCode&quot;: 200,<br>        &quot;headers&quot;: {<br>            &quot;Access-Control-Allow-Origin&quot;: &quot;*&quot;,<br>            &quot;Access-Control-Allow-Methods&quot;: &quot;POST,OPTIONS&quot;,<br>            &quot;Access-Control-Allow-Headers&quot;: &quot;Content-Type&quot;<br>        },<br>        &quot;body&quot;: json.dumps(message)<br>    }</pre><ol><li>Paste your Python code (that calls Titan Text G1 — Express via Bedrock)</li><li>Click <strong>Deploy</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rFbGhg2GiRTdivk4wJFezQ.png" /></figure><blockquote>Step 4: Create and Configure API Gateway</blockquote><h4>Steps:</h4><ol><li>Navigate to <strong>API Gateway</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3rrlknyymkcGH1XK8Uj8Lw.png" /></figure><p>2. Click <strong>Create API</strong> → Choose <strong>REST API</strong> → <strong>Build</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-RXXqRzDGTv7mhhTNlxFCw.png" /></figure><ul><li>Name: chatbot-api</li><li>Leave defaults and click <strong>Create API</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7AoHZKTb58kcyfvdbsM97w.png" /></figure><h4>Create a Resource:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*7hRsI_20GTcbS3ttpCRp7Q.png" /></figure><p>Under your API, click <strong>Actions</strong> → <strong>Create Resource</strong></p><ul><li>Resource Name: chatbot</li><li>Enable <strong>CORS</strong> (Cross-Origin Resource Sharing)</li><li>Click <strong>Create Resource</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7GOZnoAl3Ah-dS29uFxjA.png" /></figure><h4>Create a POST Method:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cBUOgH9aaCdj8-zMaDYqcw.png" /></figure><ol><li>Click on /chatbot resource</li><li>Click <strong>Actions</strong> → <strong>Create Method</strong> → Select <strong>POST</strong></li><li>Set integration type to <strong>Lambda Function</strong></li><li>Enable <strong>Lambda Proxy Integration</strong></li><li>Select Region: us-east-1 and type the name of your Lambda function (chatbotlambda)</li><li>Click <strong>Save</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*Q7pTQgYVofWYdozXOAQnqw.png" /></figure><h4>Deploy the API:</h4><ol><li>Click <strong>Actions</strong> → <strong>Deploy API</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-TZOu2D5mLKYpmJLuCHEdg.png" /></figure><p>2. Choose <strong>New Stage</strong> → Stage name: DEV</p><p>3. Click <strong>Deploy</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*YrR7Xk90pR-KekLYLI-rjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*M9qvY_5tGHAcnVBOEi98UQ.png" /></figure><blockquote>Step 5: Test with Postman</blockquote><p>Let’s ensure everything is working before we connect the frontend.</p><ol><li>Open <strong>Postman</strong></li><li>Set the method to <strong>POST</strong></li><li>Paste the full invoke URL</li></ol><p><a href="https://s2lsdzwd60.execute-api.us-east-1.amazonaws.com/DEV/chatbot">https://s2lsdzwd60.execute-api.us-east-1.amazonaws.com/DEV/chatbot</a></p><ul><li>Under <strong>Body</strong>, select raw and JSON format.</li><li>Paste:</li></ul><pre>{<br>  &quot;message&quot;: &quot;Hello&quot;,<br>  &quot;history&quot;: []<br>}</pre><p>Click <strong>Send</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3uiTWNO9bPhcfJo8EV2FPg.png" /></figure><p>If successful, you should receive a chatbot reply generated by the <strong>Titan Text</strong> model</p><blockquote>Step 6 : Build the Chatbot Frontend UI</blockquote><p>Now let’s create a simple UI so users can chat with your bot.</p><h4>Sample: index.html</h4><p>This file will have:</p><ul><li>Input field for user messages</li><li>A button to send the message</li><li>An area to display chatbot responses</li><li>JavaScript code to call your API Gateway</li></ul><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;/&gt;<br>  &lt;title&gt;SmartHelp Assistant — AWS-Powered AI&lt;/title&gt;<br>  &lt;style&gt;<br>    body {<br>      margin: 0;<br>      font-family: &#39;Segoe UI&#39;, sans-serif;<br>      background-color: #f5f8fa;<br>      display: flex;<br>      flex-direction: column;<br>      height: 100vh;<br>    }<br><br>    header {<br>      background-color: #aee571;<br>      color: #222;<br>      padding: 1rem;<br>      text-align: center;<br>      font-size: 1.5rem;<br>      font-weight: bold;<br>    }<br><br>    #chatBox {<br>      flex: 1;<br>      padding: 1rem;<br>      overflow-y: auto;<br>      display: flex;<br>      flex-direction: column;<br>      gap: 1rem;<br>    }<br><br>    .message {<br>      max-width: 80%;<br>      padding: 0.75rem 1rem;<br>      border-radius: 12px;<br>      font-size: 1rem;<br>      line-height: 1.4;<br>      box-shadow: 0 2px 4px rgba(0,0,0,0.1);<br>    }<br><br>    .user {<br>      align-self: flex-end;<br>      background-color: #aee571;<br>      color: #000;<br>    }<br><br>    .bot {<br>      align-self: flex-start;<br>      background-color: #f0fbdc;<br>      color: #333;<br>    }<br><br>    .timestamp {<br>      display: block;<br>      font-size: 0.75rem;<br>      color: #666;<br>      margin-top: 4px;<br>      text-align: right;<br>    }<br><br>    footer {<br>      padding: 1rem;<br>      display: flex;<br>      gap: 0.5rem;<br>      background-color: white;<br>      border-top: 1px solid #ddd;<br>    }<br><br>    input[type=&quot;text&quot;] {<br>      flex: 1;<br>      padding: 0.75rem;<br>      font-size: 1rem;<br>      border: 1px solid #aee571;<br>      border-radius: 8px;<br>      outline: none;<br>    }<br><br>    select {<br>      padding: 0.75rem;<br>      border-radius: 8px;<br>      border: 1px solid #aee571;<br>    }<br><br>    button {<br>      padding: 0.75rem 1rem;<br>      background-color: #aee571;<br>      border: none;<br>      border-radius: 8px;<br>      color: #000;<br>      font-weight: bold;<br>      cursor: pointer;<br>      transition: background-color 0.3s ease;<br>    }<br><br>    button:hover {<br>      background-color: #9dd65c;<br>    }<br><br>    img.generated-image {<br>      max-width: 100%;<br>      border-radius: 12px;<br>      margin-top: 0.5rem;<br>    }<br><br>    @media (max-width: 600px) {<br>      input[type=&quot;text&quot;], button {<br>        font-size: 0.9rem;<br>      }<br>      button {<br>        padding: 0.5rem 1rem;<br>      }<br>    }<br>  &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br><br>  &lt;header&gt; AI ChatBot Assistant — AWS-Powered AI&lt;/header&gt;<br><br>  &lt;div id=&quot;chatBox&quot;&gt;&lt;/div&gt;<br><br>  &lt;footer&gt;<br>    &lt;select id=&quot;mode&quot;&gt;<br>      &lt;option value=&quot;text&quot;&gt;Text&lt;/option&gt;<br>      &lt;option value=&quot;image&quot;&gt;Image&lt;/option&gt;<br>    &lt;/select&gt;<br>    &lt;input type=&quot;text&quot; id=&quot;userInput&quot; placeholder=&quot;Type your message...&quot; onkeydown=&quot;handleKey(event)&quot; /&gt;<br>    &lt;button onclick=&quot;sendMessage()&quot;&gt;Send&lt;/button&gt;<br>  &lt;/footer&gt;<br><br>  &lt;script&gt;<br>    let history = [];<br><br>    async function sendMessage() {<br>      const userInput = document.getElementById(&#39;userInput&#39;);<br>      const mode = document.getElementById(&#39;mode&#39;).value;<br>      const message = userInput.value.trim();<br>      if (!message) return;<br><br>      addMessage(message, &#39;user&#39;);<br>      userInput.value = &#39;&#39;;<br><br>      const loadingMsg = addMessage(&#39;Typing...&#39;, &#39;bot&#39;);<br><br>      try {<br>        const response = await fetch(&#39;https://p4wg4cnzjg.execute-api.us-east-1.amazonaws.com/dev/chatbot&#39;, {<br>          method: &#39;POST&#39;,<br>          headers: { &#39;Content-Type&#39;: &#39;application/json&#39; },<br>          body: JSON.stringify({ message, history, mode })<br>        });<br><br>        const data = await response.json();<br>        loadingMsg.remove();<br><br>        if (mode === &#39;image&#39; &amp;&amp; Array.isArray(data.response)) {<br>          data.response.forEach(img =&gt; {<br>            const container = addMessage(&#39;&#39;, &#39;bot&#39;);<br>            const image = document.createElement(&#39;img&#39;);<br>            image.src = &#39;data:image/png;base64,&#39; + img.base64;<br>            image.className = &#39;generated-image&#39;;<br>            container.appendChild(image);<br>          });<br>        } else if (typeof data.response === &#39;string&#39;) {<br>          addMessage(data.response, &#39;bot&#39;);<br>          history.push({ user: message, assistant: data.response });<br>        } else {<br>          addMessage(&#39;Unexpected response format.&#39;, &#39;bot&#39;);<br>        }<br><br>      } catch (err) {<br>        loadingMsg.remove();<br>        addMessage(&quot;Error: &quot; + err.message, &#39;bot&#39;);<br>      }<br>    }<br><br>    function addMessage(text, sender) {<br>      const msg = document.createElement(&#39;div&#39;);<br>      msg.classList.add(&#39;message&#39;, sender);<br>      const timestamp = new Date().toLocaleTimeString();<br>      msg.innerHTML = `${text}&lt;span class=&quot;timestamp&quot;&gt;${timestamp}&lt;/span&gt;`;<br>      document.getElementById(&#39;chatBox&#39;).appendChild(msg);<br>      msg.scrollIntoView({ behavior: &#39;smooth&#39; });<br>      return msg;<br>    }<br><br>    function handleKey(event) {<br>      if (event.key === &#39;Enter&#39;) {<br>        event.preventDefault();<br>        sendMessage();<br>      }<br>    }<br>  &lt;/script&gt;<br><br>&lt;/body&gt;<br>&lt;/html&gt;</pre><blockquote>Step 7: Deploy Frontend Using S3 + Amplify Hosting</blockquote><ol><li>Navigate to <strong>Amazon S3</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cpZeshwc6mVOSg_vSv8mCw.png" /></figure><ol><li>Click <strong>Create Bucket</strong></li></ol><ul><li>Name: chatbot-ui-bucket</li><li>Region: Same as Bedrock and Lambda</li><li><strong>Uncheck</strong>: Block All Public Access</li><li>Leave other settings default and click <strong>Create Bucket</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PYxmXQS8OuGSPskDXttxxQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a2VdbHZvSPMb9YcZ12JNmg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yymcHLIRzwxa7ip5BrhZMg.png" /></figure><ul><li>Click into the bucket → Upload your index.html file</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o7TNlHY5zrnLC80KHJbw2w.png" /></figure><ul><li>Go to <strong>Properties</strong> → Scroll to <strong>Static Website Hosting</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kzqMhzjmtgDmo2u0T4qKg.png" /></figure><ul><li>Click <strong>Create Amplify App</strong></li><li>Set App Name</li><li>Choose this S3 bucket and file</li><li>Click <strong>Save and Deploy</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RS9463GGkTH0FqIgKYHMCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-oSvIVJDH1u3qJ0Oanauw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*TODbWc7cyuiHTnZqJj5O_A.png" /></figure><p>AWS Amplify will now deploy and host your frontend. After deployment, you’ll get a <strong>public domain link</strong> to access your chatbot UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y0jKqau1SDFLJl63tq-8Mg.png" /></figure><h3>End-to-End Flow:</h3><ol><li><strong>User Interface</strong>:<br> The journey begins with a user interacting with a chat UI hosted on a static website. This frontend is deployed on <strong>Amazon S3</strong> and optionally managed through <strong>AWS Amplify Hosting</strong> for easier deployment and versioning.</li><li><strong>API Gateway</strong>:<br> When a user types a message, the request is sent over the internet as an HTTPS <strong>POST request</strong> to <strong>Amazon API Gateway</strong>, which acts as a secure entry point into your backend.</li><li><strong>Lambda Function</strong>:<br> API Gateway forwards the message to an <strong>AWS Lambda function</strong>, which contains the backend logic. This is where the magic happens: the Lambda function receives the input, formats it, and prepares a request for Amazon Bedrock.</li><li><strong>Amazon Bedrock with Titan Model</strong>:<br> The Lambda function, using a secure <strong>IAM role</strong>, makes a call to <strong>Amazon Bedrock</strong>, specifically invoking the <strong>Titan Text G1 — Express</strong> model. This foundation model processes the input message and generates a human-like chatbot response.</li><li><strong>Response Flow</strong>:<br> The generated response from Bedrock is returned to the Lambda function, which then forwards it back to the user via API Gateway. The frontend receives the response and displays it in the chat interface in real time.</li></ol><h3>Conclusion</h3><p>We have just built a <strong>production-ready, serverless AI chatbot</strong> using Amazon Bedrock and other AWS services. This architecture is ideal for real-world use cases like customer support, knowledge base querying, virtual assistance, and more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16153add1efc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Bedrock :A Hands-On Guide to Amazon Bedrock with LLaMA 3, Nova, and Titan ( Visual Studio):2]]></title>
            <link>https://medium.com/@ssrinuwas.r/aws-bedrock-a-hands-on-guide-to-amazon-bedrock-with-llama-3-nova-and-titan-visual-studio-2-45e891a65e98?source=rss-f7fcf9015ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/45e891a65e98</guid>
            <dc:creator><![CDATA[SriNu SaMEinI]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 14:35:55 GMT</pubDate>
            <atom:updated>2025-04-14T14:44:15.176Z</atom:updated>
            <content:encoded><![CDATA[<h3>AWS Bedrock :A Hands-On Guide to Amazon Bedrock with LLaMA 3, Nova, and Titan ( Visual Studio):2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*QJ14ojNZOPnX6sCPrE0h5g.png" /></figure><p>In this blog, we’ll walk through the process of setting up a fresh development environment to work with <strong>Amazon Bedrock</strong>, starting from scratch. This setup will help you build and test generative AI applications using the Bedrock platform right from your local machine.<br>Step 1: Create Your Project Directory</p><p>Start by creating a new folder for your project. You can name it something like AWS Bedrock.</p><ol><li>Open your terminal or file explorer.</li></ol><p>2. Create a folder named AWSBedrock.<br>3. Open <strong>Visual Studio Code</strong> (or any code editor you prefer).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYlpWNdVCFmBK0PXTlkbsQ.png" /></figure><p>4.Use the <strong>File &gt; Open Folder</strong> option to open the newly created AWSBedrock folder.<br>(Note:- If you face any issue with conda command install the conda in your system and try again)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*m7BiBgOXSBiq2xDiM1mDzg.png" /><figcaption>This is the screenshot to check the conda version.</figcaption></figure><p>Step 2: Set Up a Virtual Environment with Conda</p><p>If you have <strong>Conda</strong> installed, it’s a good idea to create a separate virtual environment for this project. This keeps dependencies isolated and avoids conflicts with other Python projects.</p><pre>conda create -p ./venv python=3.11 -y</pre><p>This creates a virtual environment named venv inside your AWSBedrock folder, using Python version 3.11</p><p>To activate the environment, run:</p><pre>conda activate ./venv</pre><p>Your terminal prompt should now show that you’re working inside the venv environment.</p><p>Step 3: Create the Requirements File</p><p>Now it’s time to define the libraries your project needs.</p><p>Inside your AWSBedrock folder, create a new text file and name it:</p><pre>requirements.txt</pre><p>Open this file and add the following lines:</p><pre>boto3<br>awscli</pre><ul><li><strong>boto3</strong> is the official AWS SDK for Python, and it allows you to interact with AWS services, including Amazon Bedrock.</li><li><strong>awscli</strong> provides command-line tools to interact with AWS and is useful for configuration and quick tests.</li></ul><p>Save the file once you’ve added the dependencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DxkJPPScZSETsGEnUokNtQ.png" /></figure><p>Step 4: Install the Required Libraries</p><p>With the virtual environment activated and the requirements.txt file ready, you can now install your dependencies.</p><pre>pip install -r requirements.txt</pre><p>This will install boto3 and awscli into your virtual environment, making them available for your scripts and tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s3N1fVsL7a8PZiywCqq32g.png" /></figure><p>Step 5: Generate Access Keys from AWS Console</p><p>To begin, you’ll need access to the AWS IAM Console (Identity and Access Management). Here’s how to generate your credentials:</p><ol><li>Log in to the AWS Management Console.</li><li>In the search bar, type “IAM” and open the IAM dashboard.</li><li>Navigate to Users.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1KgEQrACdi1o2OVulj6pg.png" /></figure><p>4. You can either:</p><ul><li>Create a new user, or</li><li>Use an existing user account (commonly used for company or team projects).</li></ul><p>5. Once you’ve selected or created a user, click on the user’s name to open the details page.</p><p>6. Go to the Security Credentials tab.</p><p>7. Scroll down to the Access Keys section and click “Create access key.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UQI-U6Q8MmdDiknEFqzfvg.png" /></figure><p>8. For usage type, select “Command Line Interface (CLI)”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*8RvrttC3x8Y16ylG1Rsl9w.png" /></figure><p>9. Check the confirmation box and click Next.</p><p>10. Provide a description (e.g., <em>“Bedrock Project Access”</em>) and then click Create access key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zgc9A0Xjt6xjLTeNcHM6KA.png" /></figure><p>11. Download the .csv file containing your Access Key ID and Secret Access Key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7b5K6a35kDEFhDAPWb6DLQ.png" /></figure><blockquote><em>️ </em><strong><em>Keep this file secure — your Secret Access Key is only shown once.</em></strong></blockquote><p>Step 6: Configure AWS CLI with Your Keys</p><p>Now that you have your keys, open your terminal and run the following command:</p><pre>aws configure</pre><p>You’ll be prompted to enter the following:</p><ul><li><strong>AWS Access Key ID</strong> — from your downloaded .csv file</li><li><strong>AWS Secret Access Key</strong> — also from the .csv</li><li><strong>Default region name</strong> — for example, us-east-1 (make sure this matches the region where you’ve enabled Bedrock models)</li><li><strong>Default output format</strong> — you can enter json</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZNtf5n8t-QkRHpO_rQoyJw.png" /></figure><p>Once complete, your CLI and Python scripts will be authenticated and ready to interact with AWS services.</p><p>Now that your AWS credentials are configured and your environment is ready, it’s time to start working with <strong>foundation models</strong> in <strong>Amazon Bedrock</strong>. With everything set up, you can choose any of the available models and try out your first real task — whether it’s text generation, image creation, or a chatbot-style interaction.</p><ul><li>Login AWS Console &gt; Search AWS Bedrock &gt; Click on Model Catalog</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LLWREmQaR2sVOX68MQk3RA.png" /></figure><h3>A. Building Your First Script with Amazon Bedrock: Using LLaMA 3 Model</h3><p>Now that everything is set up and you’re authenticated with AWS, it’s time to run your first real task using Amazon Bedrock. For this example, we’ll use <strong>Meta’s LLaMA 3 70B Instruct model</strong>, one of the most advanced and capable foundation models currently available on Bedrock.</p><p>You can choose any model depending on your use case, but we’ll start with LLaMA 3 to walk through the complete process.</p><h3>Understanding the Model Invocation</h3><p>Each model on Amazon Bedrock comes with a set of API parameters such as:</p><ul><li><strong>Model ID</strong></li><li><strong>Content-Type</strong></li><li><strong>Accept type</strong></li><li><strong>Prompt structure</strong></li></ul><p>These details are required to form the API request properly when using boto3 in Python. You can find all of this information in the <strong>Amazon Bedrock console</strong> under the specific model&#39;s usage API section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*bxb-GVmaWkJneWka4gouwQ.png" /></figure><p>Step 1: Update Your requirements.txt</p><p>Make sure your requirements.txt file includes:</p><pre>boto3<br>awscli</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Of5ZV_1jmtKHnzZp1e82XQ.png" /><figcaption>requirements.txt</figcaption></figure><p>Step 2: Create test.json File</p><p>Right-click on your project folder and create a file named:</p><pre>test.json</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9qNc77p3SAFfl2fwMIfk4w.png" /><figcaption>test.json</figcaption></figure><pre>{<br>      &quot;modelId&quot;: &quot;meta.llama3-70b-instruct-v1:0&quot;,<br>      &quot;contentType&quot;: &quot;application/json&quot;,<br>      &quot;accept&quot;: &quot;application/json&quot;,<br>      &quot;body&quot;: &quot;{\&quot;prompt\&quot;:\&quot;this is where you place your input text\&quot;,\&quot;max_gen_len\&quot;:512,\&quot;temperature\&quot;:0.5,\&quot;top_p\&quot;:0.9}&quot;<br>    }</pre><p>Step 3: Create a Python Script File</p><p>Open your AWSBedrock project in Visual Studio Code.<br> Create a new file and name it:</p><pre>llama3.py</pre><p>This will be the main script where we build and send the API request to the LLaMA 3 model.</p><p>Step 3: Prepare the API Request Format</p><p>In your script, we’ll use Python to send a request using boto3. You’ll need to:</p><ul><li>Import necessary libraries: boto3 and json</li><li>Specify the <strong>model ID</strong> for LLaMA 3</li><li>Include content type as &quot;application/json&quot;</li><li>Format your prompt properly</li><li>Parse and print the response returned by the model</li><li>Write the Code in llama3.py</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XCYcycndlrfo6UMevlVeIA.png" /><figcaption>llama3.py</figcaption></figure><pre>import boto3<br>import json<br><br># Prompt for LLaMA 3<br>prompt_data = &quot;Write a poem about the mountains.&quot;<br><br># Set up Bedrock runtime client<br>bedrock = boto3.client(service_name=&quot;bedrock-runtime&quot;)<br><br># LLaMA 3 model ID<br>model_id = &quot;meta.llama3-70b-instruct-v1:0&quot;<br><br># Prepare payload<br>payload = {<br>    &quot;prompt&quot;: prompt_data,<br>    &quot;max_gen_len&quot;: 512,<br>    &quot;temperature&quot;: 0.5,<br>    &quot;top_p&quot;: 0.9<br>}<br>body = json.dumps(payload)<br><br># Invoke model<br>response = bedrock.invoke_model(<br>    body=body,<br>    modelId=model_id,<br>    accept=&quot;application/json&quot;,<br>    contentType=&quot;application/json&quot;<br>)<br><br># Read and print response<br>response_body = json.loads(response.get(&quot;body&quot;).read())<br>print(response_body.get(&quot;generation&quot;, response_body))</pre><p>Step 6: Run the Script</p><p>With everything in place, activate your environment if it’s not already active:</p><pre>conda activate ./venv</pre><pre>python llama3.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R0o484Q7GrHIjs2VE3DNRg.png" /><figcaption>Output of the Prompt — Write a poem about the mountains.</figcaption></figure><p>Within a few seconds, you should see the model’s response printed in your terminal — whether it’s a poem, explanation, or whatever you asked it to generate.</p><p><strong>{{{{ We’ll walk through a simple Python script that sends a request to Meta’s LLaMA 3 model hosted on Amazon Bedrock. The goal? Ask the AI to write a poem about the mountains.This step-by-step breakdown will help you understand what each part of the code does.</strong></p><p>1: Import Required Libraries</p><pre>import boto3<br>import json</pre><p>We begin by importing two important Python libraries:</p><ul><li><strong>boto3</strong> is the official AWS SDK for Python. It allows us to communicate with AWS services, including Bedrock.</li><li><strong>json</strong> helps us format our data so that AWS understands it. Think of it like turning our message into a structured digital language.</li></ul><p>2: Define the Prompt</p><pre>prompt_data = &quot;Write a poem for AWS&quot;</pre><p>This is the instruction we want to send to the AI. In this case, we’re asking it to <strong>write a poem about AWS</strong>. This will be passed to the model as the prompt.</p><p>3: Connect to Amazon Bedrok</p><pre>bedrock = boto3.client(service_name=&quot;bedrock-runtime&quot;)</pre><p>Here, we’re creating a connection to the Amazon Bedrock runtime. Think of this line as <strong>opening a chat window with the AI model</strong> — you’re now ready to send messages and receive responses.</p><p>4: Prepare the Request Payload</p><pre>payload = {<br>    &quot;prompt&quot;: prompt_data,<br>    &quot;max_gen_len&quot;: 512,<br>    &quot;temperature&quot;: 0.5,<br>    &quot;top_p&quot;: 0.9<br>}</pre><p>This dictionary holds all the settings for our request:</p><ul><li><strong>prompt</strong> – The task or message we’re sending to the AI.</li><li><strong>max_gen_len</strong> – The maximum length of the response, in tokens (words or word-like chunks).</li><li><strong>temperature</strong> – Controls the creativity of the response. Lower values are more factual; higher values are more imaginative. 0.5 is a nice balance.</li><li><strong>top_p</strong> – Another creativity control. 0.9 means the AI will consider the top 90% of possible word choices, offering a mix of focus and flexibility.</li></ul><p>5: Convert Payload to JSON</p><pre>body = json.dumps(payload)</pre><p>This line turns our Python dictionary into a JSON-formatted string — a format that AWS Bedrock expects. You can think of it like <strong>sealing the message in a digital envelope</strong>.</p><p>6: Specify the Model</p><pre>model_id = &quot;meta.llama3-70b-instruct-v1:0&quot;</pre><p>Here, we tell Bedrock which model we want to use. In this case, it’s Meta’s <strong>LLaMA 3</strong>, a powerful and instruction-tuned language model designed for complex tasks like writing, reasoning, and answering questions.</p><p>7 : Send the Request to Bedrock</p><pre>response = bedrock.invoke_model(<br>    body=body,<br>    modelId=model_id,<br>    accept=&quot;application/json&quot;,<br>    contentType=&quot;application/json&quot;<br>)</pre><p>This is where the magic happens. We <strong>send our prompt and settings to the model</strong> and ask for a response. Bedrock handles all the backend work — routing your request, running the model, and returning the output.</p><p>8: Read the Model’s Response</p><pre>response_body = json.loads(response.get(&quot;body&quot;).read())</pre><p>After receiving a reply from the model, this line <strong>reads the response</strong> and converts it back from JSON to a format Python can work with.</p><p>9: Extract the Generated Text</p><pre>response_text = response_body[&#39;generation&#39;]</pre><p>This pulls out the actual poem (or whatever the model wrote) from the structured response. The key &#39;generation&#39; contains the AI&#39;s reply.</p><p>10: Display the Output</p><pre>print(response_text)</pre><p>Finally, we print the result on the screen. You should now see a freshly generated poem about AWS — written by LLaMA 3! }}}}}</p><h3>B. Exploring Amazon Nova: A Multimodal Foundation Model on Bedrock</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*nqISa3qn6Ux1kidIhSzo3A.png" /></figure><p>After experimenting with the LLaMA 3 model, we now turn our attention to another powerful foundation model available in Amazon Bedrock — Amazon Nova. Unlike traditional text-only models, Amazon Nova is a multimodal model. In this demo, we’ll walk through how to set up and interact with the Amazon Nova model to process a simple text prompt using Python.</p><p>Step 1: Create an Json file with API Request for Amazon Nova</p><p>As with previous models, the first step is to understand and define the correct request format. Amazon Bedrock provides example API requests in the console, which you can copy and save in a .json file for reference.</p><p>In your project folder (AWSBedrock), we go with existing test.json file</p><p>Paste the example API structure into this file. This helps you verify the payload structure and can serve as a template for more advanced use cases later.</p><pre>    {<br>      &quot;modelId&quot;: &quot;meta.llama3-70b-instruct-v1:0&quot;,<br>      &quot;contentType&quot;: &quot;application/json&quot;,<br>      &quot;accept&quot;: &quot;application/json&quot;,<br>      &quot;body&quot;: &quot;{\&quot;prompt\&quot;:\&quot;this is where you place your input text\&quot;,\&quot;max_gen_len\&quot;:512,\&quot;temperature\&quot;:0.5,\&quot;top_p\&quot;:0.9}&quot;<br>    },<br>    {<br>      &quot;modelId&quot;: &quot;amazon.nova-pro-v1:0&quot;,<br>      &quot;contentType&quot;: &quot;application/json&quot;,<br>      &quot;accept&quot;: &quot;application/json&quot;,<br>      &quot;body&quot;: {<br>        &quot;inferenceConfig&quot;: {<br>          &quot;max_new_tokens&quot;: 1000<br>        },<br>        &quot;messages&quot;: [<br>          {<br>            &quot;role&quot;: &quot;user&quot;,<br>            &quot;content&quot;: [<br>              {<br>                &quot;text&quot;: &quot;this is where you place your input text&quot;<br>              }<br>            ]<br>          }<br>        ]<br>      }<br>    }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_-kBViHAguZSM50m4iUCHg.png" /><figcaption>test.json second para is for Amazon Nova</figcaption></figure><p>Step 2: Create the Python Script</p><p>Now, let’s write the code to call the Amazon Nova model. Inside your AWSBedrock folder, create a new Python file and name it:</p><pre>amazonNova.py</pre><p>Paste the following code into the file:</p><pre>import boto3<br>import json<br><br># Set your prompt<br>prompt_data = &quot;Generate a person working on a laptop in an office&quot;<br><br># Initialize Bedrock client<br>bedrock = boto3.client(service_name=&quot;bedrock-runtime&quot;)<br><br># Prepare payload for Amazon Nova<br>payload = {<br>    &quot;inferenceConfig&quot;: {<br>        &quot;max_new_tokens&quot;: 1000<br>    },<br>    &quot;messages&quot;: [<br>        {<br>            &quot;role&quot;: &quot;user&quot;,<br>            &quot;content&quot;: [<br>                {<br>                    &quot;text&quot;: prompt_data<br>                }<br>            ]<br>        }<br>    ]<br>}<br><br>body = json.dumps(payload)<br>model_id = &quot;amazon.nova-pro-v1:0&quot;<br><br>try:<br>    response = bedrock.invoke_model(<br>        body=body,<br>        modelId=model_id,<br>        accept=&quot;application/json&quot;,<br>        contentType=&quot;application/json&quot;<br>    )<br><br>    raw_body = response.get(&quot;body&quot;).read()<br>    print(&quot;\n🔹 Raw Response:\n&quot;, raw_body)<br><br>    parsed = json.loads(raw_body)<br>    print(&quot;\n🔹 Parsed Response:\n&quot;, parsed)<br><br>    if &#39;output&#39; in parsed and &#39;message&#39; in parsed[&#39;output&#39;]:<br>        message = parsed[&#39;output&#39;][&#39;message&#39;]<br>        if &#39;content&#39; in message and len(message[&#39;content&#39;]) &gt; 0:<br>            print(&quot;\n🔹 Output Text:\n&quot;, message[&#39;content&#39;][0][&#39;text&#39;])<br>        else:<br>            print(&quot;\n No text content found in the message.&quot;)<br>    else:<br>        print(&quot;\n &#39;output.message&#39; not found in response.&quot;)<br><br>except Exception as e:<br>    print(&quot;Error invoking model:&quot;, e)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eejr0G1EyscdeJFslh2cnA.png" /><figcaption>amazonTitan.py</figcaption></figure><p>What This Script Does</p><ul><li>Initializes a connection to <strong>Amazon Bedrock</strong>.</li><li>Sends a <strong>prompt</strong> to the Amazon Nova model:<br> <em>“Generate a person working on a laptop in an office”</em></li><li>Parses the model’s response and prints the generated output to your terminal.</li></ul><p>The script includes helpful logging and error handling so you can understand exactly what the model is returning — even if something goes wrong.<br>Now that your script is ready, it’s time to run it and see Amazon Nova in action.Make sure your <strong>virtual environment is activated</strong>. If it’s not, activate it by running:</p><pre>python amazonNova.py</pre><p>Within a few seconds, you should see the <strong>raw response</strong>, the <strong>parsed JSON</strong>, and finally the <strong>generated output</strong> based on your prompt:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8W7ZAY9RcjjHJO7LAeFrTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWrxs_cofqifTGm6hbhVoQ.png" /><figcaption>Output for amazonNova.py</figcaption></figure><p>This simple demo shows how easy it is to connect to Amazon Bedrock, send a structured prompt to Amazon Nova, and receive meaningful AI-generated content. You’re now well on your way to exploring more advanced, multimodal applications using foundation models on AWS!</p><h3>C. Generating Images Using Amazon Titan on Bedrock</h3><p>After working with language models like LLaMA 3 and Amazon Nova, let’s now explore a <strong>visual use case</strong>. Amazon Bedrock also supports <strong>image generation</strong> using the <strong>Amazon Titan Image Generator</strong> — a powerful model that can transform descriptive prompts into high-quality visuals.</p><p>In this demo, we’ll walk you through how to set up and invoke Titan to generate an image based on your prompt.</p><p>Step 1: Add Titan Image API Request in JSON Format</p><p>To start, we need to understand the structure of the Titan model request. Head to the <strong>Amazon Bedrock Console</strong>, locate the <strong>Titan Image Generator</strong>, and copy the example API payload provided.</p><p>Paste it into your existing test.json file or create a new one. Here’s what the JSON structure should look like:( you can create another .json file but for this i have use single json file for all the 3 cases.)</p><pre>[<br>    {<br>      &quot;modelId&quot;: &quot;meta.llama3-70b-instruct-v1:0&quot;,<br>      &quot;contentType&quot;: &quot;application/json&quot;,<br>      &quot;accept&quot;: &quot;application/json&quot;,<br>      &quot;body&quot;: &quot;{\&quot;prompt\&quot;:\&quot;this is where you place your input text\&quot;,\&quot;max_gen_len\&quot;:512,\&quot;temperature\&quot;:0.5,\&quot;top_p\&quot;:0.9}&quot;<br>    },<br>    {<br>      &quot;modelId&quot;: &quot;amazon.nova-pro-v1:0&quot;,<br>      &quot;contentType&quot;: &quot;application/json&quot;,<br>      &quot;accept&quot;: &quot;application/json&quot;,<br>      &quot;body&quot;: {<br>        &quot;inferenceConfig&quot;: {<br>          &quot;max_new_tokens&quot;: 1000<br>        },<br>        &quot;messages&quot;: [<br>          {<br>            &quot;role&quot;: &quot;user&quot;,<br>            &quot;content&quot;: [<br>              {<br>                &quot;text&quot;: &quot;this is where you place your input text&quot;<br>              }<br>            ]<br>          }<br>        ]<br>      }<br>    },<br>    {<br>      &quot;modelId&quot;: &quot;amazon.titan-image-generator-v1&quot;,<br>      &quot;contentType&quot;: &quot;application/json&quot;,<br>      &quot;accept&quot;: &quot;application/json&quot;,<br>      &quot;body&quot;: &quot;{\&quot;textToImageParams\&quot;:{\&quot;text\&quot;:\&quot;this is where you place your input text\&quot;},\&quot;taskType\&quot;:\&quot;TEXT_IMAGE\&quot;,\&quot;imageGenerationConfig\&quot;:{\&quot;cfgScale\&quot;:8,\&quot;seed\&quot;:42,\&quot;quality\&quot;:\&quot;standard\&quot;,\&quot;width\&quot;:1024,\&quot;height\&quot;:1024,\&quot;numberOfImages\&quot;:3}}&quot;<br>    }<br>  ]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iPksXxevIjjGQawa2xZ5yQ.png" /><figcaption>test.json</figcaption></figure><p>Step 2: Create the Python Script for Amazon Titan</p><p>Now that you have the API structure ready, create a new Python file in your project directory and name it:</p><pre>amazonTitan.py</pre><p>Paste the following code into that file:</p><pre>import boto3<br>import base64<br>import json<br>import re<br>from pathlib import Path<br><br># Titan client<br>bedrock = boto3.client(&quot;bedrock-runtime&quot;, region_name=&quot;us-east-1&quot;)<br><br># Prompt text<br>prompt_text = &quot;Lion with Eagle&quot;<br><br># Full request body<br>prompt = {<br>    &quot;textToImageParams&quot;: {<br>        &quot;text&quot;: prompt_text<br>    },<br>    &quot;taskType&quot;: &quot;TEXT_IMAGE&quot;,<br>    &quot;imageGenerationConfig&quot;: {<br>        &quot;cfgScale&quot;: 8,<br>        &quot;seed&quot;: 42,<br>        &quot;quality&quot;: &quot;standard&quot;,<br>        &quot;width&quot;: 1024,<br>        &quot;height&quot;: 1024,<br>        &quot;numberOfImages&quot;: 1<br>    }<br>}<br><br># Make the API call<br>response = bedrock.invoke_model(<br>    modelId=&quot;amazon.titan-image-generator-v1&quot;,<br>    contentType=&quot;application/json&quot;,<br>    accept=&quot;application/json&quot;,<br>    body=json.dumps(prompt)<br>)<br><br># Decode image<br>response_body = json.loads(response[&quot;body&quot;].read())<br>image_data = base64.b64decode(response_body[&quot;images&quot;][0])<br><br># Clean filename from prompt text<br>def clean_filename(text):<br>    return re.sub(r&#39;[^a-zA-Z0-9_]&#39;, &#39;&#39;, text.replace(&quot; &quot;, &quot;_&quot;))[:50]<br><br>filename = clean_filename(prompt_text) + &quot;.png&quot;<br><br># Ensure output folder exists<br>output_dir = Path(&quot;generated_images&quot;)<br>output_dir.mkdir(parents=True, exist_ok=True)<br><br># Write to file<br>output_path = output_dir / filename<br>with open(output_path, &quot;wb&quot;) as f:<br>    f.write(image_data)<br><br>print(f&quot;Image saved at: {output_path}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WeVZqwErwkAzUm97BsiWKw.png" /><figcaption>amazonTitan.py</figcaption></figure><h3>Explaining the Code: Generating an Image with Amazon Titan in Bedrock</h3><p>In this section, we’ll break down the Python script used to generate an image using the <strong>Amazon Titan Image Generator</strong> model through <strong>Amazon Bedrock</strong>.</p><h3>Importing Required Library</h3><pre>import boto3, base64, json, re<br>from pathlib import Path</pre><p>We begin by importing the necessary libraries:</p><ul><li><strong>boto3</strong> – The AWS SDK for Python that allows communication with Amazon Bedrock.</li><li><strong>base64</strong> – Used to decode the image returned from Titan (since it comes encoded in Base64 format).</li><li><strong>json</strong> – Helps parse JSON data for request formatting and response handling.</li><li><strong>re</strong> – Regular expressions used here to clean the filename (removing special characters).</li><li><strong>pathlib</strong> – Makes file system operations easy, like creating directories and handling file paths.</li></ul><h3>Initializing the Bedrock Client</h3><pre>bedrock = boto3.client(&quot;bedrock-runtime&quot;, region_name=&quot;us-east-1&quot;)</pre><p>This line initializes a client to connect with Amazon Bedrock in the <strong>us-east-1</strong> region. It allows your script to send requests to Bedrock models, including Titan.</p><h3>Setting the Prompt and Request Parameters</h3><pre>prompt_text = &quot;Lion with Eagle&quot;</pre><p>This is the <strong>text prompt</strong> that describes the image you want the model to generate</p><pre>prompt = {<br>    &quot;textToImageParams&quot;: {&quot;text&quot;: prompt_text},<br>    &quot;taskType&quot;: &quot;TEXT_IMAGE&quot;,<br>    &quot;imageGenerationConfig&quot;: {<br>        &quot;cfgScale&quot;: 8,<br>        &quot;seed&quot;: 42,<br>        &quot;quality&quot;: &quot;standard&quot;,<br>        &quot;width&quot;: 1024,<br>        &quot;height&quot;: 1024,<br>        &quot;numberOfImages&quot;: 1<br>    }<br>}</pre><p>This dictionary holds the configuration for the Titan model:</p><ul><li><strong>textToImageParams.text</strong> – The input prompt to guide the image generation.</li><li><strong>taskType</strong> – Specifies the task type (here it&#39;s text-to-image).</li><li><strong>cfgScale</strong> – Controls how closely the image matches your description (higher values = more faithful).</li><li><strong>seed</strong> – A fixed value to ensure the output is reproducible.</li><li><strong>quality</strong> – Image quality setting (standard is the default).</li><li><strong>width/</strong><strong>height</strong> – Image resolution.</li><li><strong>numberOfImages</strong> – Number of images to generate (we’re generating just one here).</li></ul><h3>Sending the Request to the Model</h3><pre>response = bedrock.invoke_model(<br>    modelId=&quot;amazon.titan-image-generator-v1&quot;,<br>    contentType=&quot;application/json&quot;,<br>    accept=&quot;application/json&quot;,<br>    body=json.dumps(prompt)<br>)</pre><p>This line sends your request to the <strong>Titan image model</strong> on Bedrock. The invoke_model function communicates with AWS, and in return, you’ll receive the generated image in <strong>Base64-encoded format</strong>.</p><h3>Decoding the Image Data</h3><pre>response_body = json.loads(response[&quot;body&quot;].read())<br>image_data = base64.b64decode(response_body[&quot;images&quot;][0])</pre><p>The model’s response contains the image encoded as a string. These lines decode it into <strong>binary image data</strong> that can be written to a .png file.</p><h3>Cleaning the Filename</h3><pre>def clean_filename(text):<br>    return re.sub(r&#39;[^a-zA-Z0-9_]&#39;, &#39;&#39;, text.replace(&quot; &quot;, &quot;_&quot;))[:50]</pre><pre>filename = clean_filename(prompt_text) + &quot;.png&quot;</pre><p>To safely save the image, this function:</p><ul><li>Replaces spaces with underscores</li><li>Removes special characters</li><li>Limits the length of the filename</li></ul><p>This ensures the filename is valid and clean, based on your prompt.</p><h3>Saving the Image to Disk</h3><pre>output_dir = Path(&quot;generated_images&quot;)<br>output_dir.mkdir(parents=True, exist_ok=True)</pre><p>This part checks if a folder called generated_images exists, and creates it if not.</p><pre>output_path = output_dir / filename<br>with open(output_path, &quot;wb&quot;) as f:<br>    f.write(image_data)</pre><p>These lines <strong>write the binary image data</strong> into a .png file, saving it locally inside the generated_images folder.</p><h3>Displaying the Output</h3><pre>print(f&quot;Image saved at: {output_path}&quot;)</pre><p>Finally, the script prints out the file path so you can easily locate and open the generated image.</p><p>Step 3: Run the script by entering the following command in your terminal:</p><pre>python amazonTitan.py</pre><p>After a short wait, you’ll see a message like:</p><pre>Image saved at: generated_images/Lion_with_Eagle.png</pre><p>You can now navigate to the generated_images folder in your project directory and open the image. It will be based on your prompt: <em>“Lion with Eagle”</em>—generated by AI in real time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tu3-WI3yBCLytNq58ItBfw.png" /></figure><h3>Summary</h3><p>In this guide, we went through a hands-on journey using <strong>Amazon Bedrock</strong>, starting from setting up our working environment to trying out different AI models.</p><p>First, we created a basic script using <strong>Meta’s LLaMA 3 model</strong> to generate text based on a prompt. Then, we explored <strong>Amazon Nova</strong>, a model that can understand and respond to text in a more structured way, and saw how to get useful results from it.</p><p>Lastly, we used <strong>Amazon Titan</strong> to generate an image from a text description. The script automatically saved the image as a .png file in a separate folder.</p><p>These three examples show how easy it is to use Amazon Bedrock for different AI tasks — like writing, understanding, and creating visuals — using just one platform. It’s a great starting point for building your own generative AI applications.</p><p>Git Hub: <a href="https://github.com/SrinuTrilok/Bedrock2.git">https://github.com/SrinuTrilok/Bedrock2.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45e891a65e98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Amazon Bedrock: 1]]></title>
            <link>https://medium.com/@ssrinuwas.r/getting-started-with-amazon-bedrock-1-0d669fb26f67?source=rss-f7fcf9015ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d669fb26f67</guid>
            <dc:creator><![CDATA[SriNu SaMEinI]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 11:25:10 GMT</pubDate>
            <atom:updated>2025-04-14T11:25:10.002Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Amazon Bedrock?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*wU5jTOsloUgntGNzFnug6Q.png" /></figure><p><strong>A Beginner-Friendly Guide to AWS’s Generative AI Platform</strong></p><p>Amazon Bedrock is a service offered by Amazon Web Services (AWS) that simplifies the use of powerful generative AI tools. It brings together models from leading AI companies like Anthropic (Claude), Meta (LLaMA), AI21 Labs, Cohere, Stability AI, and Amazon itself (Titan). These are called foundation models or large language models (LLMs), and they are used to generate text, answer questions, create images, and much more.</p><p>The biggest advantage of Amazon Bedrock is that it provides all these models on a single platform. Instead of dealing with different APIs, configurations, and services for each model provider, you can access everything through one consistent setup. This helps businesses and developers save time, avoid complexity, and focus more on building their applications.</p><p>Another important reason why companies choose Amazon Bedrock is because it’s a fully managed service. You don’t need to worry about managing servers, setting up infrastructure, or figuring out how to scale your AI applications. Everything runs on AWS’s infrastructure, and you only need to focus on using the models to solve your business problems.</p><p>While the cost of using Amazon Bedrock may be slightly higher than using a single provider like OpenAI directly, the convenience and flexibility it offers can easily outweigh the difference, especially for businesses that value time, security, and scalability.</p><p>Now, let’s talk about what you can do with Bedrock. You can generate text, summarize documents, create conversational chatbots, answer questions, or even generate images from a text description like “a lion flying with an eagle.” You can also fine-tune some models with your own data, so the model gives more relevant or customized outputs for your business needs.</p><p>One of the key features of Amazon Bedrock is its strong security and data privacy model. Your data stays in the AWS region you are working in. All data, including prompts and responses, is encrypted during transfer and at rest. If you’re connecting from your private network, you can even use AWS PrivateLink to keep the traffic off the public internet. And if you customize a model using your own data, AWS creates a private copy of that model just for you.</p><p>To get started, you can use the AWS Management Console. Inside Bedrock’s user-friendly interface, there’s a playground where you can test out different models, submit prompts, and see the results. You can also adjust parameters like temperature or response length to control how the model behaves. For developers, there’s also the option to use the Bedrock API via the AWS SDK to integrate these models into real applications or other AWS services.</p><h3>Key Settings That Shape AI Responses in Amazon Bedrock</h3><p><strong>Temperature</strong></p><ul><li>Controls how <strong>creative or predictable</strong> the model’s output is.</li><li><strong>Lower temperature</strong> = More focused, factual, and reliable answers.</li><li><strong>Higher temperature</strong> = More creative, imaginative, and varied responses.</li><li>Useful for switching between <strong>serious tasks</strong> and <strong>creative writing</strong>.</li><li>You can adjust this in AWS Bedrock when you’re testing or fine-tuning prompts for your application, depending on whether you want accuracy or creativity in the responses</li></ul><p><strong>Top P (Nucleus Sampling)</strong></p><ul><li>Determines how many <strong>word choices</strong> the model considers.</li><li><strong>High Top P</strong> = Considers a wider set of possible responses, more diverse.</li><li><strong>Low Top P</strong> = Picks from the top few likely options, more consistent and safe.</li><li>Helps balance between <strong>diversity</strong> and <strong>predictability</strong>.</li><li>You can tune this in AWS Bedrock when you want to control how risky or safe the model should be in generating responses.</li></ul><p><strong>Response Length</strong></p><ul><li>Sets the <strong>maximum length</strong> of the model’s output.</li><li>Shorter length for quick replies or summaries.</li><li>Longer length for detailed answers, stories, or full documents.</li></ul><h3>Foundation Models Available in Amazon Bedrock</h3><p>You can choose from various top-tier models, all accessible through a <strong>single API</strong>:</p><ul><li><strong>Amazon Titan</strong> — For generating text and images.</li><li><strong>Anthropic Claude</strong> — Excellent for conversational and reasoning tasks.</li><li><strong>Meta LLaMA</strong> — Open-source language model ideal for customization.</li><li><strong>Stability AI</strong> — Great for generating high-quality AI images.</li></ul><p>Each model serves different needs — pick the one that suits your task best(there are more FMs apart from this).</p><h3>How to Get Started with Amazon Bedrock: A Quick Walkthrough</h3><p>If you’re just getting started with Amazon Bedrock, here’s a simple step-by-step guide to help you navigate the console, access models</p><h3>Step 1: View the Model Catalog</h3><p>Once you’re inside the <strong>Amazon Bedrock console</strong>, the first thing you should do is click on the <strong>“View Model Catalog”</strong> option. This section gives you an overview of all the foundation models currently supported by Amazon Bedrock.</p><p>You’ll see models from various leading AI providers, such as:</p><ul><li><strong>Amazon Titan</strong> (text and image generation)</li><li><strong>Anthropic Claude</strong> (conversational intelligence)</li><li><strong>Meta’s LLaMA</strong> (open-source large language model)</li><li>And many others like AI21 Labs, Cohere, Stability AI, and Mistral</li></ul><p>This catalog helps you understand what each model does and which one might be best suited for your use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XX64mkd66RGsnw2vKPpD1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MvgM6ftJvHR8vs9sHfRwDw.png" /></figure><h3>Step 2: Enable Model Access</h3><p>Before you can use any of the models in Bedrock, you need to <strong>request access</strong>. This step is essential and takes just a few minutes.</p><p>You have two options:</p><h4>a. Enable All Models</h4><p>This is the fastest way to get started.</p><ol><li>Click <strong>“Model Access”</strong> in the sidebar.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GOadS01nmbhhL69UiyaVbQ.png" /></figure><p>2. Choose <strong>“Enable All Models”</strong> to request access to every available foundation model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MYkfZuvDtcZv0vIXzxQHA.png" /></figure><p>3. Click <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UX8sMi-vt7EqWuFwxKamIg.png" /></figure><p>4. When prompted for use case details (e.g., for <strong>Anthropic Claude</strong>), fill in your purpose. For this demo, you can write something like:<br> <em>“Exploring model capabilities for educational and internal AI development use.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-EBxImjZdWGI04_bi2x2LA.png" /></figure><p>5. Click <strong>Next</strong>, then <strong>Submit</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4JCumOUU0x3ZF0C6fd0h0w.png" /></figure><p>Once submitted, you’ll be able to <strong>see which models have been approved</strong>. This usually takes just a few minutes. You’ll notice their access status update automatically once it’s granted.</p><h4>b. Enable a Specific Model</h4><p>If you only need access to a particular model:</p><ol><li>Click <strong>“Enable Specific Model”</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F4JV-y-W9PHoNLgqHYRl6w.png" /></figure><p>2. Select the desired model (for example, Titan Text G1- lite)</p><p>3. Click <strong>Next</strong>, then provide your use case details.</p><p>4. Finally, click <strong>Submit</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ubvNLW612aISMDfM0o8bWg.png" /></figure><p>This option is helpful if you are working on a project that requires a particular model and you don’t need access to all the others. you’ll be able to <strong>see which models have been approved</strong>. This usually takes just a few minutes. You’ll notice their access status update automatically once it’s granted.</p><h3>Image Generation Demo Using Titan Image Generator in Amazon Bedrock</h3><p>Once you’ve enabled model access in Amazon Bedrock, you’re ready to try out real-world use cases. One of the simplest and most visual examples is generating images using a text prompt. For this, we’ll use <strong>Amazon’s Titan Image Generator G1</strong>.<br>Step-by-Step: Generate an Image with Titan</p><p>To begin your image generation journey in Amazon Bedrock, follow these easy steps:</p><ol><li><strong>Open the Playground</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*fKW8TXGhayVTKjtK3-PvJg.jpeg" /></figure><ul><li>Head to the <strong>“Playground”</strong> section in the Amazon Bedrock console.</li><li>Click on <strong>“Image”</strong> to switch to the image generation interface.</li></ul><p><strong>2. Choose Your Model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*JBxQiq_rJ88na5wZLLH9_Q.png" /></figure><ul><li>From the dropdown menu, select <strong>Titan Image Generator G1</strong> by Amazon.</li><li>Click <strong>“Apply”</strong> to confirm your selection.</li></ul><p><strong>3. Use Default Settings</strong></p><ul><li>For a simple test, leave the configuration settings as they are (default values work well for general image generation tasks).</li></ul><p><strong>4. Enter Your Prompt</strong></p><ul><li>In the prompt box, type something descriptive like:<br> <em>“Generate an image of an ancient stone fort nestled in the mountains, surrounded by mist and pine trees.”</em></li></ul><p><strong>5. Generate the Image</strong></p><ul><li>Click on the generate button and wait for a few seconds.</li><li>The model will process your prompt and create an image that reflects the scene you’ve described.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hazdlAHJim1iWlOGCMuIKw.png" /></figure><p>This task gives you visual feel for how text-to-image models work. The generated image should match your prompt as closely as possible, depending on the model’s capabilities.</p><h3>Summary</h3><p>In this demo, we walked through the basic steps to start using Amazon Bedrock. First, we explored the <strong>Model Catalog</strong> to see the various foundation models available, such as Amazon Titan, Anthropic Claude, and Meta’s LLaMA. We then enabled access to all models by going through the <strong>Model Access</strong> section and submitting a simple use case.</p><p>After access was granted, we performed a small task using the <strong>Titan Image Generator G1</strong>. Through the <strong>Playground</strong>, we selected the image model, kept the default configuration, and entered a prompt:<br> <em>“Generate an image of an ancient stone fort nestled in the mountains, surrounded by mist and pine trees.”</em><br> Within a few seconds, the model generated an image based on the description.</p><p>This demo was a simple, hands-on introduction to using Amazon Bedrock’s capabilities — focusing on enabling models and testing a basic image generation use case.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d669fb26f67" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>