title: How can I connect to endpoint when attempting to export data from RDS to S3?
body: <h2>Objective</h2>
  <p>My objective is to export data from a Postgres RDS Instance to an s3 Bucket. I just want to prove that the concept works on my VPC, so I am using dummy data.</p>
  <h2>What I have tried so far</h2>
  <p>I followed the docs <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/postgresql-s3-export.html#postgresql-s3-export-examples-prerequisites" rel="nofollow noreferrer">here</a> using the console and cli.</p>
  <ol>
  <li><p>Created an s3 bucket (I chose to block all public access)</p>
  </li>
  <li><p>Created an RDS Instance with the following settings:</p>
  <ul>
  <li>Created on 2 public subnets</li>
  <li>Public accessibility: No</li>
  <li>Security group rules for outbound: CIDR/IP - Inbound   0.0.0.0/0</li>
  <li>Security group rules for inbound: CIDR/IP - Inbound    0.0.0.0/0</li>
  </ul>
  </li>
  <li><p>Created a policy as shown in the example:</p>
  </li>
  </ol>
  <pre><code>    aws iam create-policy  --policy-name rds-s3-export-policy  --policy-document '{
           &quot;Version&quot;: &quot;2012-10-17&quot;,
           &quot;Statement&quot;: [
             {
               &quot;Sid&quot;: &quot;s3export&quot;,
               &quot;Action&quot;: [
                 &quot;S3:PutObject&quot;
               ],
               &quot;Effect&quot;: &quot;Allow&quot;,
               &quot;Resource&quot;: [
                 &quot;arn:aws:s3:::your-s3-bucket/*&quot;
               ] 
             }
           ] 
         }'
  </code></pre>
  <ol start="4">
  <li>Created an IAM Role like:</li>
  </ol>
  <pre><code>aws iam create-role  --role-name rds-s3-export-role  --assume-role-policy-document '{
       &quot;Version&quot;: &quot;2012-10-17&quot;,
       &quot;Statement&quot;: [
         {
           &quot;Effect&quot;: &quot;Allow&quot;,
           &quot;Principal&quot;: {
              &quot;Service&quot;: &quot;rds.amazonaws.com&quot;
            },
           &quot;Action&quot;: &quot;sts:AssumeRole&quot;
         }
       ] 
     }'
  </code></pre>
  <ol start="5">
  <li>Attached the policy to the role like:</li>
  </ol>
  <pre><code>aws iam attach-role-policy  --policy-arn your-policy-arn  --role-name rds-s3-export-role  
  </code></pre>
  <ol start="6">
  <li>Added the IAM Role to the DB like:</li>
  </ol>
  <pre><code>aws rds add-role-to-db-instance \
     --db-instance-identifier my-db-instance \
     --feature-name s3Export \
     --role-arn your-role-arn   \
     --region your-region
  </code></pre>
  <ol start="7">
  <li>Did all the requirements within PSQL like:</li>
  </ol>
  <pre><code>CREATE EXTENSION IF NOT EXISTS aws_s3 CASCADE;
  
  CREATE TABLE sample_table (bid bigint PRIMARY KEY, name varchar(80));
  
  INSERT INTO sample_table (bid,name) VALUES (1, 'Monday'), (2,'Tuesday'), (3, 'Wednesday');
  
  SELECT aws_commons.create_s3_uri(
     'dummy-data-bucket-path',
     '',
     'us-west-2'
  ) AS s3_uri_1 \gset
  </code></pre>
  <h3>What does not work</h3>
  <p>When I try to make the actual export by:</p>
  <pre><code>SELECT * FROM aws_s3.query_export_to_s3('SELECT * FROM sample_table', :'s3_uri_1');
  </code></pre>
  <p>I get the error:</p>
  <pre><code>ERROR:  could not upload to Amazon S3
  DETAIL:  Amazon S3 client returned 'Unable to connect to endpoint'.
  CONTEXT:  SQL function &quot;query_export_to_s3&quot; statement 1
  </code></pre>
  <h3>Other things I have tried:</h3>
  <p>I have tried using <code>Access analyzer for S3</code> but my bucket does not seem to appear in the list. I believe as the bucket itself does not have a policy attached to it.</p>
  <p>How can I debug this issue? What am I doing wrong? I am happy to share further details if needed.</p>