Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied when trying to load into Postgres RDS from S3 with a path that contains the equals sign

I'm trying to load data into Postgres RDS from S3 using the method aws_s3.table_import_from_s3 as explained here: Importing Data into PostgreSQL on Amazon RDS

The file path in S3 contains the equals sign '=' and because of it I'm getting the following error:

ERROR:  HTTP 403. Permission denied. Check bucket or provided credentials as they may no longer be valid.

When replacing the equals sign with another character like underscore '_', the import succeeds.

Example:

SELECT aws_s3.table_import_from_s3(
     'my_table',
     'col1,col2',
     '(format csv)',
     'my_bucket',
     'date=20191031/my_data.csv',
     'eu-west-2'
);

Throws the error mentioned above. (HTTP 403...)

While:

SELECT aws_s3.table_import_from_s3(
     'my_table',
     'col1,col2',
     '(format csv)',
     'my_bucket',
     'date_20191031/my_data.csv',
     'eu-west-2'
);

Succeeds without any problem

Is there any escape char I should add to the equals sign? Any other solution?

like image 791
dvainrub Avatar asked Nov 04 '19 12:11

dvainrub


1 Answers

I didn't test it, but should work. Just encode = with %3D.

SELECT aws_s3.table_import_from_s3(
 'my_table',
 'col1,col2',
 '(format csv)',
 'my_bucket',
 'date%3D20191031/my_data.csv',
 'eu-west-2');
like image 200
Red Boy Avatar answered Oct 13 '22 11:10

Red Boy