Skip to content

How do I integrate Amazon S3 with my Aurora PostgreSQL-Compatible DB cluster?

2 minute read
0

I want to turn on the Amazon Simple Storage Solution (Amazon S3) integration feature in my Amazon Aurora PostgreSQL-Compatible Edition DB cluster.

Resolution

Install the aws_s3 extension

To install the aws_s3 extension that allows you to connect to the database, run the following command:

postgres=> CREATE EXTENSION aws_s3 CASCADE;

To verify that aws_s3 is installed, run the psql\dx meta-command. Or use the following query from any DB client tool:

select * from pg_available_extensions where installed_version is not null;

Set up access to an S3 bucket

To give your Aurora PostgreSQL-Compatible cluster access to Amazon S3, create an AWS Identity and Access Management (IAM) policy. The IAM policy provides the bucket and object permissions that allow your DB cluster to access the S3 bucket.

In the IAM policy, include the following required actions to transfer files from the S3 bucket to your DB cluster:

  • s3:GetObject
  • s3:ListBucket
  • s3:PutObject
  • s3:AbordMultipartUpload

For more information, see Using an IAM role to access an Amazon S3 bucket.

Add the IAM role to the Aurora cluster

Use either the Amazon Relational Database Service (Amazon RDS) console or the AWS Command Line Interface (AWS CLI) to add an IAM role to your cluster.

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshoot AWS CLI errors. Also, make sure that you're using the most recent AWS CLI version.

Import or export data from the database

Import data to your PostgreSQL cluster from the S3 bucket, or export data to your S3 bucket from your PostgreSQL cluster. For more information, see Export and import data from Amazon S3 to Amazon Aurora PostgreSQL.

AWS OFFICIALUpdated 2 years ago
2 Comments

There are a few things missing in this post. 1 VPC endpoint set up to allow RDS (typically in private subnet) connect to S3 (in public) 2 IAM role grant to the cluster as this post leading to or IAM role grant to RDS instance

aws rds add-role-to-db-instance \
   --db-instance-identifier test-db-1-s3-copy \
   --feature-name s3Import \
   --role-arn arn:aws:iam::1234567890:role/rds-s3-import-role \
   --region eu-west-1

As I posted in https://repost.aws/questions/QU9UIDaEE4ToyMNZdhEfYUmQ that IAM role grant to the cluster doesn't allow the RDS instance access S3. I have a thought that it is AWS' cunning plan to stop Aurora DBs become a competitor to Redshift.

replied 2 years ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

AWS
MODERATOR

replied 2 years ago