<?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 Mathan K on Medium]]></title>
        <description><![CDATA[Stories by Mathan K on Medium]]></description>
        <link>https://medium.com/@mathan.k_30422?source=rss-3889411be6df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mnszHnigFQfWn3mW</url>
            <title>Stories by Mathan K on Medium</title>
            <link>https://medium.com/@mathan.k_30422?source=rss-3889411be6df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 01:22:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mathan.k_30422/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[Migrating Data from Redshift to BigQuery (CLI-Based Guide)]]></title>
            <link>https://blog.thecloudside.com/migrating-data-from-redshift-to-bigquery-cli-based-guide-fcefd59b5a36?source=rss-3889411be6df------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcefd59b5a36</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[redshift]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Mathan K]]></dc:creator>
            <pubDate>Mon, 17 Feb 2025 16:35:41 GMT</pubDate>
            <atom:updated>2025-02-17T16:35:41.333Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide covers the end-to-end process of migrating data from AWS Redshift to Google Big Query, leveraging AWS S3 as an intermediary and Google Cloud Storage (GCS) for the final staging before loading the data into Big Query. The transfer process is fully CLI-based, making it ideal for automation, repeatability, and scripting within cloud environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*vk3gvr11IlgDOk01" /><figcaption>Migration from Redshift to Big Query Architecture</figcaption></figure><h3>AWS Redshift to S3</h3><p>Extract data from AWS Redshift and store it in an Amazon S3 bucket. Using the<strong> UNLOAD</strong> command, data can be efficiently moved from Redshift tables into S3 as CSV files, ensuring optimal storage and compatibility for the next steps in GCS and BigQuery.</p><h3>1. Set Up IAM Role for Redshift</h3><p>The IAM role enables Redshift to access and store data in S3. First, create a trust policy JSON file to define the permissions for Redshift’s access to S3.</p><h4>Create trust-policy.json</h4><p>This policy allows Redshift to assume the role and perform required actions in S3. Make sure to save this file as `trust-policy.json`.</p><pre>{<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;: { &quot;Service&quot;: &quot;redshift.amazonaws.com&quot; },<br>&quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>}<br>]<br>}</pre><p>Save this policy as a trust policy. json</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*wl6XXqfoxP7GxcHu" /></figure><h4>Create IAM Role</h4><p>After saving the trust policy file, you can create an IAM role with the following command:</p><pre>aws iam create-role - role-name RedshiftS3Role - assume-role-policy-document file://trust-policy.json</pre><p>Attach the S3 policy to enable Redshift data access to S3:</p><p>Next, attach the AmazonS3FullAccess policy to this role, which grants Redshift permission to store data in the specified S3 bucket.</p><pre>aws iam attach-role-policy - role-name RedshiftS3Role - policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*9pHLCcwZKk3rEVfZ" /></figure><h3>2. Create and Configure Redshift Cluster</h3><p>Now, set up your Redshift cluster. This guide uses a single-node cluster configuration with essential specifications for simplicity. This can be easily modified based on the scale and performance requirements of your database.</p><pre>aws redshift create-cluster \<br>cluster-identifier my-redshift-cluster \<br>node-type dc2.large \<br> - master-username admin \<br> - master-user-password YourPasswordHere \<br>cluster-type single-node \<br>iam-roles arn:aws:iam::&lt;AWS_ACCOUNT_ID&gt;:role/RedshiftS3Role</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3dyQVVzsV84xQrcw" /></figure><h4>Get Cluster Endpoint</h4><p>Retrieve the endpoint to connect to the Redshift cluster for loading and unloading data.</p><pre>aws redshift describe-clusters - cluster-identifier my-redshift-cluster - query &quot;Clusters[0].Endpoint.Address&quot;-output&quot;text</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*q28UYd23io-RrKPB" /></figure><h3>3. Setting Up Security for Redshift Cluster Access</h3><p>Ensure that Redshift is accessible by configuring security settings, making it publicly accessible, and adjusting Security Group rules to allow access on the necessary ports.</p><p><strong>Make the Cluster Publicly Accessible</strong>:</p><pre>aws redshift modify-cluster - cluster-identifier my-redshift-cluster - publicly-accessible</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*ccSVupdYnd0Xyt-h" /></figure><p><strong>Configure Security Group Ingress Rules</strong> <strong>for Redshift</strong>:</p><pre>aws ec2 authorize-security-group-ingress \<br>group-id &lt;SECURITY_GROUP_ID&gt; \<br>protocol tcp - port 5439 \<br> - cidr &lt;YOUR_IP_ADDRESS&gt;/32</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*1lE0l7RkkALifKDu" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*1OpMctENILx0JOD5" /></figure><p>Verify the subnet and Route the Redshift cluster has a proper route to the internet (for a public cluster).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/0*xL9SWHasju9pLvCN" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/0*v2taSBGsEKkTJ-V4" /></figure><p>To ensure secure access to your AWS Redshift cluster, you need to verify the cluster status and configure security groups with appropriate inbound rules. These steps will allow access from specific IPs, such as those of EC2 instances or other resources that need to communicate with the Redshift cluster.</p><h4>Checking Cluster Status</h4><p>Before configuring security groups, confirm that your Redshift cluster is in an active state. This ensures that it is accessible and ready for connections.</p><p>Use the following command to check the status:</p><pre>aws redshift describe-clusters \<br>cluster-identifier my-redshift-cluster \<br>query &#39;Clusters[0].ClusterStatus&#39;</pre><h4>Creating a Security Group for Redshift</h4><p>Security groups act as virtual firewalls, controlling inbound and outbound traffic to AWS resources. To create a dedicated security group for Redshift access, use the following command. Be sure to replace &lt;your-vpc-id&gt; with the ID of the VPC where your Redshift cluster is hosted:</p><pre>aws ec2 create-security-group \<br>group-name MySecurityGroup \<br> - description &quot;My security group for Redshift access&quot; \<br> - vpc-id &lt;your-vpc-id&gt;</pre><h4>Adding Inbound Rules to Security Group</h4><p>Once the security group is created, you need to authorize inbound access to the Redshift cluster port (port 5439). This step allows connections only from specific IP addresses, such as an EC2 instance’s private IP, ensuring restricted access.</p><pre>aws ec2 authorize-security-group-ingress \<br>group-id &lt;security-group-id&gt; \<br>protocol tcp \<br> - port 5439 \<br>cidr &lt;your-ip-address&gt;/32</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*XD4MMCl2FIYpf_Kk" /></figure><p>User interface</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*fNbQg2SJEZS7L11c" /></figure><h4>Connect to Redshift</h4><pre>psql \<br>host=&lt;cluster-endpoint&gt; \<br> - port=5439 \<br> - username=admin \<br> - password \<br> - dbname=my_sample_db</pre><p>Connect to AWS Redshift cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*XaaLlzChz7qt_Ubx" /></figure><h3>4. Create Tables in Redshift and Load Data to S3</h3><p>Once connected to the Redshift cluster, you can begin creating tables and populating them with data for migration.</p><h4>Create and populate tables</h4><p>Define the table structure and insert data as required:</p><p>CREATE TABLE your_table (…);</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*x6ktqhmyfWFiD-H6" /></figure><p>INSERT INTO your_table VALUES (...);</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*XY-TjWGWlxdNXxqd" /></figure><h4>AWS CLI Configuration</h4><p>The AWS Command Line Interface (CLI) allows you to interact with AWS services using command-line. Configuring the AWS CLI involves setting up your AWS credentials and region preferences to authorize access and specify defaults for AWS services.</p><p>Make sure the AWS CLI is installed on your system. You can verify it with</p><pre>aws --version</pre><p>Create an access key for the your_User</p><pre>aws iam create-access-key --user-name your-username</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*UQz-8mDmHZ5JNyZjcDMkew.png" /></figure><p>Start the configuration process by running</p><pre>aws configure</pre><p>Provide the Required Information</p><p>AWS Access Key ID associated with your AWS account or IAM user with necessary permissions</p><pre>AWS Access Key ID [None]: YOUR_ACCESS_KEY_ID</pre><p>Secret Access Key corresponding to your Access Key ID</p><pre>AWS Secret Access Key [None]: Your Secret Access Key</pre><p>Specify the default AWS region where your resources will be created</p><pre>Default region name [None]: your_region_name</pre><p>Set the default output format for AWS CLI responses</p><pre>Default output format [None]:</pre><p>Verifying Configuration</p><p>Contains your AWS Access Key ID and Secret Access Key</p><pre>cat ~/.aws/credentials</pre><p>Stores your region and output format settings</p><pre>cat ~/.aws/config</pre><h4>Move data to S3 Bucket</h4><p><strong>Create an S3 Bucket</strong>:</p><pre>aws s3api create-bucket, bucket yourbucketname, region your_region</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*f9p8oO9tICHMsu9_" /></figure><p><strong>Unload data to S3</strong>:</p><p>Now, unload the data from Redshift to S3:</p><pre>sql<br>UNLOAD (&#39;SELECT * FROM your_table&#39;)<br>TO &#39;s3://yourbucketname/redshift_data&#39;<br>IAM_ROLE &#39;arn:aws:iam::&lt;AWS_ACCOUNT_ID&gt;:role/RedshiftS3Role&#39;<br>ALLOWOVERWRITE<br>REGION &#39;your_region&#39;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*zv_GQr6x6lDLINyx" /></figure><h3>5. AWS S3 to Google Cloud Storage (GCS)</h3><p>Transfer data from S3 to GCS using <strong>Transfer jobs</strong>. This step requires configuration for cross-cloud transfer, including access permissions and API usage, enabling the data to securely move between AWS and Google Cloud.</p><h3>Configure GCP Authentication</h3><p>To interact with GCP services, authenticate your Google Cloud account.</p><p><strong>Authenticate gcloud</strong>:</p><pre>gcloud auth login<br>Set GCP Project and Region:<br>gcloud config set project &lt;YOUR_PROJECT_ID&gt;<br>gcloud config set compute/region your_region</pre><h3>Create a GCS Bucket</h3><p>Create a GCS bucket to store your data transferred from S3.</p><pre>gsutil mb -l your_region gs://your_gcs_bucket</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/0*HLrcG7XDBH5A2rI6" /></figure><h3>Transfer S3 data to GCS</h3><p>Using `transfer jobs`, set up a cross-cloud transfer job from S3 to GCS. This step requires an AWS credentials JSON file to authorize the transfer.</p><pre>gcloud transfer jobs create \<br>s3://yourbucketname gs://your_gcs_bucket \<br> - source-creds-file=&quot;path/to/creds.json&quot;</pre><p><em>Note</em>: Replace path/to/creds.json with the path to your AWS credentials JSON file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*KWwCnLqzRs2csNyL" /></figure><h3>6. Load data from GCS to BigQuery</h3><p>Load data from GCS directly into BigQuery using bq commands. Here, you can set data formats, perform schema autodetection, and manage dataset creation in BigQuery, transforming the raw S3 data into ready-to-query tables within your BigQuery environment.</p><h3>Enable BigQuery Data Transfer API</h3><p>Enable the required APIs to allow data transfer and loading into BigQuery.</p><pre>gcloud services enable storagetransfer.googleapis.com<br>bigquery.googleapis.com storage.googleapis.com</pre><h3>Create a BigQuery Dataset</h3><p>Set up a dataset in BigQuery as the destination for your transferred data.</p><pre>bq - location=your_region mk - dataset &lt;PROJECT_ID&gt;:your_dataset_id</pre><h3>Load Data from GCS to BigQuery</h3><p>Load the data into BigQuery with schema autodetection and CSV as the source format.</p><pre>bq load \<br> - source_format=CSV \<br>autodetect \<br>&lt;PROJECT_ID&gt;:your_dataset_id.table_name \<br>gs://your_gcs_bucket/redshift_data</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Nq6NxNvQ1DwTtik6" /></figure><p><strong>Conclusion</strong></p><p>I hope you found this guide useful for migrating your data from Amazon Redshift to Google BigQuery.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcefd59b5a36" width="1" height="1" alt=""><hr><p><a href="https://blog.thecloudside.com/migrating-data-from-redshift-to-bigquery-cli-based-guide-fcefd59b5a36">Migrating Data from Redshift to BigQuery (CLI-Based Guide)</a> was originally published in <a href="https://blog.thecloudside.com/">The Cloudside View</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>