<?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 Hemanth Gutlapalli on Medium]]></title>
        <description><![CDATA[Stories by Hemanth Gutlapalli on Medium]]></description>
        <link>https://medium.com/@hemanthgutlapalli0301?source=rss-f736402be382------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*l2jPGtVnpxqhm8tK</url>
            <title>Stories by Hemanth Gutlapalli on Medium</title>
            <link>https://medium.com/@hemanthgutlapalli0301?source=rss-f736402be382------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 22:01:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hemanthgutlapalli0301/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[Incremental Load from Postgres SQL RDS to S3 Using AWS DMS and Change Data Capture (CDC)]]></title>
            <link>https://medium.com/@hemanthgutlapalli0301/incremental-load-from-postgres-sql-rds-to-s3-using-aws-dms-and-change-data-capture-cdc-37636b312f2?source=rss-f736402be382------2</link>
            <guid isPermaLink="false">https://medium.com/p/37636b312f2</guid>
            <category><![CDATA[aws-rds-postgresql]]></category>
            <category><![CDATA[aws-dms-to-s3]]></category>
            <category><![CDATA[aws-data-pipeline]]></category>
            <category><![CDATA[snowpipe]]></category>
            <category><![CDATA[incremental-data-load]]></category>
            <dc:creator><![CDATA[Hemanth Gutlapalli]]></dc:creator>
            <pubDate>Thu, 07 Sep 2023 22:37:59 GMT</pubDate>
            <atom:updated>2023-09-08T09:55:24.529Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Data Pipeline Architecture" src="https://cdn-images-1.medium.com/max/1024/1*PulDL8FWebA7_YBH9x8s3Q.png" /></figure><p>Change Data Capture (CDC) is a technique used to identify and capture changes made to the source data. It plays a crucial role when there’s a need to synchronize data warehouses, like Snowflake, with source systems without the burden of reloading the entire dataset.</p><p>In this comprehensive guide, I’ll delineate the steps to incrementally load data from a PostgreSQL RDS instance to Amazon S3 using AWS Database Migration Service (DMS) with CDC enabled. Subsequently, we’ll touch upon ingesting this data into Snowflake leveraging the Snowpipe feature.</p><h3>Prerequisites</h3><ul><li>AWS Account</li><li>Postgres SQL RDS instance populated with data</li><li>Snowflake account</li><li>Basic knowledge of AWS services, PostgreSQL, and Snowflake</li></ul><h3>Step 1: Setting Up the PostgreSQL RDS for CDC</h3><h4>1. Creating a Parameter Group for PostgreSQL 12:</h4><ol><li>Create a parameter group for PostgreSQL 12 or respective version.</li><li>Provide a name and description for the group.</li><li>Once the parameter group is created, access it and modify the parameter “<strong>rds.logical_replication = 1</strong>” by setting its value to <strong>1</strong> in the corresponding column.</li><li>Proceed to the Database instance, click on the “Modify” option, and locate the DB parameter group section. Attach the recently created parameter group to the instance.</li><li>Initiate a reboot of the DB instance for them to take effect.</li><li>Ensure the Parameter Group should be in Sync.</li></ol><h4>Permissions required:</h4><p>The following IAM policy should be granted to users requiring the ability to modify RDS instances and parameter groups:</p><blockquote>(If you have a DB instance named <strong>mydbinstance</strong> in the <strong>us-west-2</strong> region and your account ID is <strong>XXXXXXXXXXX</strong>, the ARN for that DB instance would be:</blockquote><blockquote><strong>Note</strong>: Follow this for all policies to be role specific.</blockquote><blockquote>arn:aws:rds:us-west-2:XXXXXXXXXXX:db:mydbinstance)</blockquote><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;rds:ModifyDBInstance&quot;,<br>                &quot;rds:RebootDBInstance&quot;,<br>                &quot;rds:CreateDBParameterGroup&quot;,<br>                &quot;rds:DeleteDBParameterGroup&quot;,<br>                &quot;rds:ModifyDBParameterGroup&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:rds:us-west-2:XXXXXXXXXXX:db:mydbinstance&quot;<br>        }<br>    ]<br>}</pre><h3>Step 2: Setting Up AWS DMS for CDC</h3><h4>2.1 Creating an IAM Role for DMS</h4><ul><li>Navigate to IAM dashboard and create a new role. <em>(If you’re not an administrator, you’ll need permissions to do this.)</em></li><li>Attach policies: AmazonRDSFullAccess, AmazonS3FullAccess, and DMSFullAccess.</li></ul><p><em>For DMS-specific permissions, either of the following policy structures can be used::</em></p><pre><br>//Option A<br>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;dms:CreateEndpoint&quot;,<br>                &quot;dms:CreateReplicationInstance&quot;,<br>                &quot;dms:CreateReplicationSubnetGroup&quot;,<br>                &quot;dms:CreateReplicationTask&quot;,<br>                &quot;dms:DeleteEndpoint&quot;,<br>                &quot;dms:DeleteReplicationInstance&quot;,<br>                &quot;dms:DeleteReplicationSubnetGroup&quot;,<br>                &quot;dms:DeleteReplicationTask&quot;,<br>                &quot;dms:Describe*&quot;,<br>                &quot;dms:List*&quot;,<br>                &quot;dms:ModifyEndpoint&quot;,<br>                &quot;dms:ModifyReplicationInstance&quot;,<br>                &quot;dms:ModifyReplicationSubnetGroup&quot;,<br>                &quot;dms:ModifyReplicationTask&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}<br><br>//Option B<br><br>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;dms:*&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><p><em>For an exhaustive list of permissions, refer AWS Documentation :</em></p><p><a href="https://docs.aws.amazon.com/dms/latest/userguide/security_iam_id-based-policy-examples.html">AWS Database Migration Service identity-based policy examples</a></p><h4>2.2 Creating Subnet Group:</h4><blockquote>This group is essential to ensure that your DMS resources are in the correct network.</blockquote><p>Here’s how to create a subnet group in DMS:</p><ol><li><strong>Open the AWS Management Console</strong>: Navigate to the DMS dashboard.</li><li>Under “<em>Resource groups</em>”, select “<em>Subnet groups</em>” and then click “<em>Create subnet group</em>”.</li><li><strong>Provide Subnet Group Details</strong>:</li></ol><ul><li><strong>Name</strong>: Provide a name for the subnet group.</li><li><strong>Description</strong>: (Optional) Add a description.</li><li><strong>VPC</strong>: Choose the VPC in which you want to create the subnet group.(default VPC)</li><li><strong>Subnets</strong>: Choose the subnets to include in the subnet group. Remember to choose at least two subnets in different Availability Zones for high availability.(Choose all if its development)</li></ul><p>5<strong>. Create</strong>: After filling out all the details, click on the “Create” button.</p><p>Once the subnet group is created, you can then associate it with your replication instance or any other DMS resource that requires a subnet group.</p><h4>2.3 Creating a Replication Instance:</h4><p>Once you have a subnet group ready, create a replication instance:(<em>Allocate resources depending on the size of your database)</em>:</p><ol><li><strong>Open the AWS Management Console</strong>: Navigate to the DMS dashboard.</li><li>Select “<em>Replication instances</em>” and then “<em>Create replication instance</em>”.</li><li><strong>Specify replication instance details</strong>:</li></ol><ul><li><strong>Name</strong>: Provide a name for your replication instance.</li><li><strong>Description</strong>: (Optional) Add a description.</li><li><strong>Instance class</strong>: Choose an instance type based on your migration requirements. For large migrations or ongoing replications, choose a larger instance type.<strong>(Check DMS Pricing as its expensive)</strong></li><li><strong>Engine version</strong>: By default, DMS will use the latest available engine version, but you can select a specific version if needed.(latest version)</li></ul><p><strong>5. Network &amp; Security</strong>:</p><ul><li><strong>VPC</strong>: If it’s not auto-selected, choose the VPC in which you created the subnet group.</li><li><strong>Replication subnet group</strong>: Choose the subnet group you created earlier in <strong>Step 1</strong>.</li><li><strong>Availability Zone</strong>: Optionally</li><li><strong>Publicly accessible</strong>: If you set this to “Yes”, the replication instance will have a public IP. (Without Public IP DMS Service may not be working.)</li></ul><p>6<strong>. Security groups</strong>: You can either create a new VPC security group or choose an existing one.( <em>Ensure that the security group allows inbound traffic from the source database and outbound traffic to the target database)</em>.</p><p>7<strong>. KMS key</strong>: If you want to encrypt the storage associated with the replication instance, you can choose a KMS key.</p><p>8<strong>. Advanced</strong>:</p><ul><li><strong>Allocated storage</strong>: Specify the amount of storage to be allocated to the replication instance.(<em>Allocate resources depending on the size of your database.</em>)</li><li><strong>Maintenance</strong>: You can choose when the maintenance window occurs if AWS needs to perform maintenance on the replication instance.</li><li><strong>Enable CloudWatch logs</strong>: If you want to monitor the replication tasks more closely, enable CloudWatch logs.</li></ul><p>9<strong>. </strong>Your replication instance will then be created. It might take a few minutes for the instance to become available.</p><h4>2.4 Setting Up Endpoints::</h4><p>Endpoints facilitate the connection between your source (RDS) and destination (S3):</p><h4>2.4.1 Setting Up the Source Endpoint (Postgres RDS):</h4><ol><li>Access the DMS dashboard and choose “<strong><em>Endpoints</em></strong>”..</li><li><strong>Endpoint type</strong>: Select “Source endpoint”.</li><li><strong>Endpoint settings</strong>:</li></ol><ul><li><strong>Select RDS DB instance[Check BOX]</strong>: Once we select RDS instance it will list all the RDS instance that are in that region(DMS created region)</li><li><strong>Endpoint identifier</strong>: Provide a name for your endpoint.</li><li><strong>Source engine</strong>: Automatically identifies.</li><li><strong>Access to endpoint databaseInfo: </strong>Use AWS Secret Manager or Provide Credentials Manually</li><li><strong>Server name</strong>: Provide the DNS endpoint of your RDS instance.</li><li><strong>Port</strong>: 5432</li><li><strong>Username</strong> &amp; <strong>Password</strong>: Provide the credentials to connect to the RDS database.</li><li><strong>SSL mode</strong>: None</li></ul><p>6. Remaining all settings keep it to default.</p><p>7.<strong> Test the connection</strong>: Before saving, you can test the connection to make sure DMS can connect to the RDS database. Choose the replication instance you’ve created to test the connection(<strong>In Step 2.3</strong>).</p><p>8. <strong>Create endpoint</strong>: Once everything is set up correctly, click on the “Create endpoint” button.</p><h4>2.4.2 Setting Up the Target Endpoint (S3):</h4><ol><li>Again, navigate to “Endpoints” and select “Create endpoint”. Select “Target endpoint”.</li><li><strong>Endpoint settings</strong>:</li></ol><ul><li><strong>Endpoint identifier</strong>: Provide a name for your endpoint.</li><li><strong>Target engine</strong>: Choose “s3”.</li><li><strong>Bucket name</strong>: Provide the name of your S3 bucket.</li><li><strong>Service Access Role ARN</strong>: Provide the ARN of an IAM role that has permissions to access the S3 bucket. This role should have the necessary permissions for DMS to read and write to the S3 bucket.<br>- It should be the role ARN which have either full S3 bucket Access or Specific Bucket Access.<br>- And In Trust relationships with access to DMS service</li></ul><pre>//In trust relationships of role<br><br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Service&quot;: [<br>          &quot;transfer.amazonaws.com&quot;,<br>          &quot;events.amazonaws.com&quot;,<br>          &quot;textract.amazonaws.com&quot;,<br>          &quot;glue.amazonaws.com&quot;,<br>          &quot;rds.amazonaws.com&quot;,<br>          &quot;lambda.amazonaws.com&quot;,<br>          &quot;dms.amazonaws.com&quot;<br>        ]<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}</pre><p><strong>4. Advanced settings</strong> (Optional):</p><ul><li>Here, you can provide additional settings like data format (CSV, Parquet), folder partitioning, etc.</li></ul><h4>2.5 Create Migration Task(Creating a Replication Task with CDC enabled):</h4><ol><li>Select “Database migration tasks” and then “Create task”..</li><li><strong>Task settings</strong>:</li></ol><ul><li><strong>Task identifier</strong>: Provide a name for your migration task.</li><li><strong>Replication instance</strong>: Choose the replication instance you created.</li><li><strong>Source endpoint</strong>: Choose the RDS source endpoint.</li><li><strong>Target endpoint</strong>: Choose the S3 target endpoint.</li><li><strong>Migration type</strong>: Choose the appropriate migration type (e.g., Migrate existing data, Migrate existing data and replicate ongoing changes, etc.).(CDC = Replicate Data Changes Only)</li></ul><p><strong>4. Table mappings</strong>: Define the rules for how source tables and schemas are mapped to target tables and schemas. You can either select specific tables or use wildcards to include multiple tables.(if you keep % under source table name it will copy all the tables stored in mentioned schema).</p><p>Once you’ve set up the endpoints and migration task, you can start the migration task. The data will be migrated from your RDS database to the specified S3 bucket.</p><h3>Step 3: Loading Data into Snowflake using Snowpipe:</h3><ul><li>Ensure your migrated data is correctly structured in the Amazon S3 bucket.</li><li>Configure event notifications on the S3 bucket to trigger Snowflake about new data ready for ingestion.</li></ul><h4><em>3.1. Configure Snowflake for Snowpipe:</em></h4><p><em>a. Create a Stage: </em>Inside Snowflake, define a stage that references the Amazon S3 bucket. This stage should also include credentials for accessing the bucket. (Refer <a href="https://docs.snowflake.com/en/sql-reference/sql/create-stage">Snowflake Documentation</a>)</p><p><em>b. Define a File Format (if necessary):</em></p><p>Should your S3 files not align with Snowflake’s default formats, set up a file format in Snowflake to map them correctly.</p><h4><em>3.2. Construct the Snowpipe:</em></h4><pre>// Auto Ingest must be TRUE<br><br>CREATE PIPE database.schema.pipe_name <br>auto_ingest = TRUE<br>AS<br>COPY INTO target_table<br>FROM source_location<br>FILE_FORMAT = (format_type = &#39;file_type&#39;);</pre><h4><em>3.3. Enable Continuous Data Load:</em></h4><p><em>Activate Auto-Ingest:</em></p><ul><li>As above <strong>step 2 </strong>generates new files of CDC and will be inserted into S3 bucket.</li><li>With the S3 notifications as a trigger, Snowpipe will autonomously move the new data into the designated Snowflake table.</li></ul><h4>3.4 Setting up AWS S3 Event Notifications</h4><p>To have Snowpipe automatically ingest data when new files arrive in an S3 bucket, you need to set up S3 event notifications:</p><p><em>2.1. Configuring the Snowflake SQS Queue</em>:</p><pre>DESC pipe pipe_name</pre><p>Snowflake provides a standard AWS CloudFormation template that you can use to create the required AWS resources for Snowpipe auto-ingest. Once Pipe object is created if we describe the pipe object using above command you will be able to see a <strong>notifiction_channel</strong> details. It outputs the ARN for the SQS queue, which you need for the S3 bucket event notification(<em>Copy the ARN</em>).</p><p><em>2.2. In the AWS Management Console</em>:</p><ol><li>Navigate to the S3 service and select your bucket.</li><li>Click on the Properties tab.</li><li>Navigate to the Event notifications section and click on Create event notification.</li><li>Name the event and choose the All object create events option.</li><li>In the Send to section, select SQS Queue and then select Enter SQS queue ARN option and paste the ARN from the above step.</li><li>Save the changes.</li></ol><p>In conclusion, leveraging AWS DMS with CDC offers an efficient way to maintain data synchronization between source systems and data warehouses. With Snowpipe, Snowflake users can effortlessly ingest this data, ensuring real-time analytics and business intelligence operations are always up-to-date.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37636b312f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up and Connecting an Existing dbt Project with Snowflake on Your Local Machine]]></title>
            <link>https://medium.com/@hemanthgutlapalli0301/setting-up-and-connecting-an-existing-dbt-project-with-snowflake-on-your-local-machine-4a7716cd0655?source=rss-f736402be382------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a7716cd0655</guid>
            <category><![CDATA[dbt-tutorial]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[dbt-and-snowflake]]></category>
            <dc:creator><![CDATA[Hemanth Gutlapalli]]></dc:creator>
            <pubDate>Mon, 28 Aug 2023 15:26:52 GMT</pubDate>
            <atom:updated>2023-08-29T07:17:19.697Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4YcX16Ih-0elxLQ-NTe8Sg.png" /></figure><p>In this comprehensive guide, we’ll walk through the process of cloning an existing DBT (Data Build Tool) repository from GitHub, connecting it to your Snowflake account, and initiating our model implementation.</p><p>Data Build Tool (dbt) is an open-source software tool that enables data analysts and engineers to transform and load data in the data warehouse. In this guide, I will walk you through the process of setting up dbt with the Snowflake database.</p><h3>Prerequisites</h3><ul><li>A working Snowflake account credentials (We can create a free trial account).</li><li>Python installed on your machine.</li><li>Basic understanding of dbt and Snowflake.</li></ul><h3>Installation Process</h3><h3>1. Clone the Repository</h3><ol><li>Open Visual Studio Code.</li><li>Press Ctrl + Shift + P (or Cmd + Shift + P on macOS) to open the command palette.</li><li>Type Git: Clone and select the command.</li><li>Paste the GitHub repository URL and press Enter.</li><li>Choose a directory to save the cloned repository and click “Select Repository Location”.</li></ol><p>Alternatively, you can clone the dbt project repository directly to your local system using:</p><pre>git clone [Your Repository URL]</pre><blockquote>Example : <a href="https://github.com/gutlapallihemanth/DBT">https://github.com/gutlapallihemanth/DBT</a></blockquote><h3>2. Setting Up a Virtual Environment</h3><p>Navigate to the cloned repo directory and create a new virtual environment:</p><ul><li>MacOS and Linux:</li></ul><pre>python -m venv venv_name<br><br>. venv_name/bin/activate</pre><ul><li>Windows:</li></ul><pre>python -m venv venv_name<br><br>.\venv_name\Scripts\activate</pre><h3>3. Install Dependencies</h3><p>With the virtual environment activated, install the required dependencies that are in the requirements.txt file :</p><pre>pip install -r requirements.txt</pre><h3>4. Upgrade dbt and Snowflake Adapter</h3><p>Ensure both dbt and the Snowflake adapter are up-to-date:</p><pre>pip install dbt --upgrade<br>pip install dbt-snowflake --upgrade</pre><h3>5. Creating a profiles file</h3><p>dbt uses the profiles.yml file to manage connections to your data warehouse. This file should be stored in a directory named .dbt in your user&#39;s home directory.</p><h4>a). Create the .dbt Directory</h4><ul><li>Mac:</li></ul><pre>mkdir ~/.dbt</pre><ul><li>Windows:</li></ul><pre>mkdir %USERPROFILE%\.dbt</pre><h4>b). Configuring Snowflake Connection:</h4><ol><li>Create a file named profiles.yml in the ~/.dbt/ directory (if it doesn&#39;t already exist).</li><li>In the profiles.yml file, add the following configuration (replace placeholders with your Snowflake credentials):</li></ol><pre>my-snowflake-db:<br>  target: dev<br>  outputs:<br>    dev:<br>      type: snowflake<br>      account: [account id]<br>      user: [username]<br>      password: [password]<br>      role: [user role]<br>      database: [database name]<br>      warehouse: [warehouse name]<br>      schema: [dbt schema]<br>      threads: [1 or more]<br>      client_session_keep_alive: False<br>      query_tag: [anything]<br>      # Additional optional configurations...</pre><p>Replace the placeholders ([...]) with your actual Snowflake credentials and configurations.</p><p>Create a profiles.yml file and have the details as mentioned above and place the file in .dbt directory</p><p>You can also view your profiles.yml file directly:</p><ul><li>Mac:</li></ul><pre>open ~/.dbt</pre><ul><li>Windows:</li></ul><pre>start %USERPROFILE%\.dbt</pre><h4>c). Test the Snowflake Connection:</h4><p>Navigate to your dbt project directory and run the following commands to ensure everything is set up correctly:</p><pre>dbt debug<br><br>dbt debug --config-dir</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*NLQzhcjbFsqKMFaFsATR5A.png" /></figure><h4>d). Initialize the dbt Project</h4><p>Run the following command in your dbt project directory:</p><pre>dbt deps</pre><p>This will install any project dependencies defined in your dbt_project.yml file.</p><h3>6. Working with dbt in Your Project</h3><h4>Running Models:</h4><ul><li>Run all models:</li></ul><pre>dbt run</pre><ul><li>Run specific model:</li></ul><pre>dbt run --select model_name</pre><ul><li>To test all models:</li></ul><pre>dbt test</pre><h3>Enhancing the dbt Experience in VS Code</h3><p>For a better development experience in VS Code, consider using the vscode-dbt-power-user extension.</p><p>Make sure to keep this extension updated and configure it properly by updating the settings.json in VS Code.</p><p>This guide provides a step-by-step process for setting up dbt with Snowflake. With the configurations in place, you can leverage dbt’s powerful functionalities to transform and load data efficiently in your Snowflake data warehouse.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a7716cd0655" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>