{"id":13789,"date":"2020-03-26T14:22:31","date_gmt":"2020-03-26T13:22:31","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/"},"modified":"2020-03-26T14:22:31","modified_gmt":"2020-03-26T13:22:31","slug":"sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/","title":{"rendered":"Sending PostgreSQL data to AWS S3 by using AWS Kinesis data streams"},"content":{"rendered":"<p>Before we really start with this post: This is just an experiment and you should not implement it like this in real life. The goal of this post is just to show what is possible and I am not saying that you should do it (the way it is implemented here will be catastrophic for your database performance and it is not really secure). As I am currently exploring a lot of <a href=\"https:\/\/aws.amazon.com\/products\/\" target=\"_blank\" rel=\"noopener noreferrer\">AWS services<\/a> I wanted to check if there is an easy way to send data from PostgreSQL into an <a href=\"https:\/\/aws.amazon.com\/kinesis\/\" target=\"_blank\" rel=\"noopener noreferrer\">AWS Kinesis<\/a> data stream for testing purposes and it turned out that this is actually quite easy if you have the <a href=\"https:\/\/aws.amazon.com\/cli\/\" target=\"_blank\" rel=\"noopener noreferrer\">AWS Command Line Interface<\/a> installed and configured on the database server. <\/p>\n<p>Creating a new Kinesis stream in AWS is actually a matter of a few clicks (of course you can do that with the command line utilities as well):<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_1.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_1.jpg\" alt=\"\" width=\"1000\" height=\"526\" class=\"aligncenter size-full wp-image-38495\" \/><\/a><br \/>\nWhat I want is a simple data stream where I can put data into:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_2.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_2.jpg\" alt=\"\" width=\"1000\" height=\"762\" class=\"aligncenter size-full wp-image-38496\" \/><\/a><br \/>\nObviously the new stream needs a name and as I will not do any performance or stress testing one shard is absolutely fine:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_3.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_3.jpg\" alt=\"\" width=\"800\" height=\"754\" class=\"aligncenter size-full wp-image-38497\" \/><\/a><br \/>\nThat&#8217;s all what needs to be done, the new stream is ready:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_4.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_4.jpg\" alt=\"\" width=\"1000\" height=\"205\" class=\"aligncenter size-full wp-image-38498\" \/><\/a><\/p>\n<p>An AWS Kinesis stream is not persistent by default. That means, if you want to permanently store the output of a stream you need to connect the stream to a consumer that processes, eventually transforms, and finally stores the data somewhere. For this you can use <a href=\"https:\/\/aws.amazon.com\/kinesis\/data-firehose\/\" target=\"_blank\" rel=\"noopener noreferrer\">AWS Kinesis Firehose<\/a> and this is what I&#8217;ll be doing here:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_5.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_5.jpg\" alt=\"\" width=\"1000\" height=\"223\" class=\"aligncenter size-full wp-image-38499\" \/><\/a><br \/>\nAs I want to use <a href=\"https:\/\/aws.amazon.com\/s3\/\" target=\"_blank\" rel=\"noopener noreferrer\">AWS S3<\/a> as the target for my data I need to use a delivery stream:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_6.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_6.jpg\" alt=\"\" width=\"800\" height=\"433\" class=\"aligncenter size-full wp-image-38500\" \/><\/a><br \/>\nThe delivery stream needs a name as well and we will use the stream just created above as the source:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_7.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_7.jpg\" alt=\"\" width=\"1000\" height=\"662\" class=\"aligncenter size-full wp-image-38501\" \/><\/a><br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_8.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_8.jpg\" alt=\"\" width=\"800\" height=\"395\" class=\"aligncenter size-full wp-image-38502\" \/><\/a><br \/>\nWe could go ahead and transform the data with an <a href=\"https:\/\/aws.amazon.com\/lambda\/\" target=\"_blank\" rel=\"noopener noreferrer\">AWS Lambda<\/a> function but we&#8217;re going to keep it simple for now and skip this option:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_9.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_9.jpg\" alt=\"\" width=\"1000\" height=\"661\" class=\"aligncenter size-full wp-image-38503\" \/><\/a><br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_10.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_10.jpg\" alt=\"\" width=\"800\" height=\"339\" class=\"aligncenter size-full wp-image-38504\" \/><\/a><br \/>\nThe next screen is about the target for the data. This could be <a href=\"https:\/\/aws.amazon.com\/redshift\/\" target=\"_blank\" rel=\"noopener noreferrer\">AWS Redshift<\/a>, <a href=\"https:\/\/aws.amazon.com\/elasticsearch-service\/\" target=\"_blank\" rel=\"noopener noreferrer\">AWS Elasticsearch<\/a>, <a href=\"https:\/\/www.splunk.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Splunk<\/a> or <a href=\"https:\/\/aws.amazon.com\/s3\/\" target=\"_blank\" rel=\"noopener noreferrer\">AWS S3<\/a>, what we&#8217;ll be doing here:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_11.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_11.jpg\" alt=\"\" width=\"1000\" height=\"712\" class=\"aligncenter size-full wp-image-38505\" \/><\/a><br \/>\nFinally specifying the target S3 bucket:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_12.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_12.jpg\" alt=\"\" width=\"800\" height=\"756\" class=\"aligncenter size-full wp-image-38507\" \/><\/a><br \/>\nThe settings for buffering at not really important for this test but will matter for real systems as these settings determine how fast your data is delivered to S3 (we also do not care about encryption and compression for now):<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_13.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_13.jpg\" alt=\"\" width=\"1000\" height=\"718\" class=\"aligncenter size-full wp-image-38508\" \/><\/a><br \/>\nError logging should of course be enabled and we need an <a href=\"https:\/\/aws.amazon.com\/iam\/\" target=\"_blank\" rel=\"noopener noreferrer\">IAM role<\/a> with appropriate permissions:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_14.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_14.jpg\" alt=\"\" width=\"800\" height=\"728\" class=\"aligncenter size-full wp-image-38509\" \/><\/a><br \/>\nFinal review:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_15.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_15.jpg\" alt=\"\" width=\"1000\" height=\"694\" class=\"aligncenter size-full wp-image-38510\" \/><\/a><br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_16.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_16.jpg\" alt=\"\" width=\"800\" height=\"573\" class=\"aligncenter size-full wp-image-38511\" \/><\/a><br \/>\n&#8230; and the stream and delivery stream are ready to use:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_17.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_17.jpg\" alt=\"\" width=\"1000\" height=\"244\" class=\"aligncenter size-full wp-image-38512\" \/><\/a><\/p>\n<p>That&#8217;s it for the setup on the AWS side and we can continue with configuring PostgreSQL to call the AWS command line utility to write data to the stream. Callling system commands from inside PostgreSQL can be done in various ways, we&#8217;ll be using <a href=\"https:\/\/www.postgresql.org\/docs\/current\/plperl.html\" target=\"_blanK\" rel=\"noopener noreferrer\">pl\/Perl<\/a> for that, and even the <a href=\"https:\/\/www.postgresql.org\/docs\/current\/plperl-trusted.html\" target=\"_blank\" rel=\"noopener noreferrer\">untrusted<\/a> version so only superusers will be able to do that:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres=# create extension plperlu;\nCREATE EXTENSION\npostgres=# \\dx\n                      List of installed extensions\n  Name   | Version |   Schema   |              Description               \n---------+---------+------------+----------------------------------------\n plperlu | 1.0     | pg_catalog | PL\/PerlU untrusted procedural language\n plpgsql | 1.0     | pg_catalog | PL\/pgSQL procedural language\n(2 rows)\n<\/pre>\n<p>Next we need a table that will contain the data we want to send to the stream:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres=# create table stream_data ( id serial primary key\n                                    , stream text );\n<\/pre>\n<p>A trigger will fire each time a new row is inserted and the trigger function will call the AWS command line interface:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\ncreate or replace function f_send_to_kinesis()\nreturns trigger\nlanguage plperlu\nAS $$\n     system('aws kinesis put-record --stream-name postgres-to-kinesis --partition-key 1 --data '.$_TD-&gt;{new}{stream});\n     return;\n$$;\n\ncreate trigger tr_test\nafter insert or update\non stream_data\nfor each row\nexecute procedure f_send_to_kinesis();\n<\/pre>\n<p>This is all we need. Let&#8217;s insert a row into the table and check if it arrives in AWS S3 (remember that it will take up to 300 seconds or 5MB of data):<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres=# insert into stream_data (stream) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');\nINSERT 0 1\npostgres=# insert into stream_data (stream) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');\nINSERT 0 1\npostgres=# insert into stream_data (stream) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');\nINSERT 0 1\npostgres=# insert into stream_data (stream) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');\nINSERT 0 1\npostgres=# insert into stream_data (stream) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');\nINSERT 0 1\npostgres=# insert into stream_data (stream) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');\nINSERT 0 1\npostgres=# insert into stream_data (stream) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');\nINSERT 0 1\npostgres=# insert into stream_data (stream) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');\nINSERT 0 1\npostgres=# insert into stream_data (stream) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');\nINSERT 0 1\npostgres=# select * from stream_data;\n id |              stream              \n----+----------------------------------\n  1 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n  2 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n  3 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n  4 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n  5 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n  6 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n  7 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n  8 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n  9 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n(9 rows)\n<\/pre>\n<p>You will also notice that the insert takes quite some time because calling the AWS command line utility and waiting for the result takes ages compared to a normal insert.<\/p>\n<p>While waiting for the data to arrive you can check the monitoring section of both, the stream and the delivery stream:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_18.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_18.jpg\" alt=\"\" width=\"1000\" height=\"351\" class=\"aligncenter size-full wp-image-38515\" \/><\/a><br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_19.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_19.jpg\" alt=\"\" width=\"1000\" height=\"383\" class=\"aligncenter size-full wp-image-38516\" \/><\/a><\/p>\n<p>After a while the data appears in S3 and it is organized in [YEAR]\/[MONTH]\/[DAY]\/[HOUR]:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_20.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_20.jpg\" alt=\"\" width=\"800\" height=\"424\" class=\"aligncenter size-full wp-image-38520\" \/><\/a><br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_21.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_21.jpg\" alt=\"\" width=\"800\" height=\"444\" class=\"aligncenter size-full wp-image-38521\" \/><\/a><br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_22.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_22.jpg\" alt=\"\" width=\"800\" height=\"425\" class=\"aligncenter size-full wp-image-38522\" \/><\/a><br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_23.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_23.jpg\" alt=\"\" width=\"800\" height=\"427\" class=\"aligncenter size-full wp-image-38523\" \/><\/a><br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_24.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_24.jpg\" alt=\"\" width=\"1000\" height=\"250\" class=\"aligncenter size-full wp-image-38524\" \/><\/a><\/p>\n<p>Looking at the file itself all our data is there:<br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_25.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_25.jpg\" alt=\"\" width=\"1000\" height=\"118\" class=\"aligncenter size-full wp-image-38526\" \/><\/a><\/p>\n<p>So, actually it is quite easy to send data to an AWS Kinesis stream. If you really need to send data out of PostgreSQL I probably would go for <a href=\"https:\/\/www.postgresql.org\/docs\/current\/sql-listen.html\" target=\"_blank\" rel=\"noopener noreferrer\">listen<\/a>\/<a href=\"https:\/\/www.postgresql.org\/docs\/current\/sql-notify.html\" target=\"_blank\" rel=\"noopener noreferrer\">notify<\/a> to make the calls to the AWS command line utility not blocking the inserts or updates to the table that holds the data for the stream. Anyway, currently I am not aware of a good use case for sending streams of data out of PostgreSQL directly to AWS Kinesis. Maybe you do something like that and how?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Before we really start with this post: This is just an experiment and you should not implement it like this in real life. The goal of this post is just to show what is possible and I am not saying that you should do it (the way it is implemented here will be catastrophic for&hellip;&nbsp;<\/p>\n","protected":false},"author":28,"featured_media":13790,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","neve_meta_reading_time":"","_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[955,4133],"tags":[],"class_list":["post-13789","post","type-post","status-publish","format-standard","has-post-thumbnail","category-cloud","category-database"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.9 (Yoast SEO v28.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Sending PostgreSQL data to AWS S3 by using AWS Kinesis data streams - dbi services Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sending PostgreSQL data to AWS S3 by using AWS Kinesis data streams\" \/>\n<meta property=\"og:description\" content=\"Before we really start with this post: This is just an experiment and you should not implement it like this in real life. The goal of this post is just to show what is possible and I am not saying that you should do it (the way it is implemented here will be catastrophic for&hellip;&nbsp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi services Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/dbiservices\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-26T13:22:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"526\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Open source Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:site\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Open source Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/\"},\"author\":{\"name\":\"Open source Team\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/0b4548362cac3eeff8b3eaf329e3530a\"},\"headline\":\"Sending PostgreSQL data to AWS S3 by using AWS Kinesis data streams\",\"datePublished\":\"2020-03-26T13:22:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/\"},\"wordCount\":741,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/aws_kinesis_1.jpg\",\"articleSection\":[\"Cloud\",\"Database\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/\",\"name\":\"Sending PostgreSQL data to AWS S3 by using AWS Kinesis data streams - dbi services Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/aws_kinesis_1.jpg\",\"datePublished\":\"2020-03-26T13:22:31+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/aws_kinesis_1.jpg\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/aws_kinesis_1.jpg\",\"width\":1000,\"height\":526},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Sending PostgreSQL data to AWS S3 by using AWS Kinesis data streams\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi services Blog\",\"description\":\"#BeSharing\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\",\"name\":\"dbi services\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"width\":512,\"height\":512,\"caption\":\"dbi services\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/dbiservices\\\/\",\"https:\\\/\\\/x.com\\\/dbiservices\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/dbi-services\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/dbiservices\"],\"description\":\"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.\",\"email\":\"info@dbi-services.com\",\"telephone\":\"+41 32 422 96 00\",\"legalName\":\"dbi services SA\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/0b4548362cac3eeff8b3eaf329e3530a\",\"name\":\"Open source Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/open-source-author.png\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/open-source-author.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/open-source-author.png\",\"caption\":\"Open source Team\"},\"description\":\"Posts published under the Open source Team account are collective contributions by the dbi services open infrastructure consultants. The practice covers open-source databases and platforms, PostgreSQL first of all, along with MySQL, MariaDB, and Linux, from architecture, replication, and high availability to performance tuning and operations under service level agreements, and contributes actively to the PostgreSQL community.\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/open-source-team\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Sending PostgreSQL data to AWS S3 by using AWS Kinesis data streams - dbi services Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/","og_locale":"en_US","og_type":"article","og_title":"Sending PostgreSQL data to AWS S3 by using AWS Kinesis data streams","og_description":"Before we really start with this post: This is just an experiment and you should not implement it like this in real life. The goal of this post is just to show what is possible and I am not saying that you should do it (the way it is implemented here will be catastrophic for&hellip;&nbsp;","og_url":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/","og_site_name":"dbi services Blog","article_publisher":"https:\/\/www.facebook.com\/dbiservices\/","article_published_time":"2020-03-26T13:22:31+00:00","og_image":[{"width":1000,"height":526,"url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_1.jpg","type":"image\/jpeg"}],"author":"Open source Team","twitter_card":"summary_large_image","twitter_creator":"@dbiservices","twitter_site":"@dbiservices","twitter_misc":{"Written by":"Open source Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/"},"author":{"name":"Open source Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/0b4548362cac3eeff8b3eaf329e3530a"},"headline":"Sending PostgreSQL data to AWS S3 by using AWS Kinesis data streams","datePublished":"2020-03-26T13:22:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/"},"wordCount":741,"commentCount":0,"publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_1.jpg","articleSection":["Cloud","Database"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/","url":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/","name":"Sending PostgreSQL data to AWS S3 by using AWS Kinesis data streams - dbi services Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_1.jpg","datePublished":"2020-03-26T13:22:31+00:00","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_1.jpg","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/aws_kinesis_1.jpg","width":1000,"height":526},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/sending-postgresql-data-to-aws-s3-by-using-aws-kinesis-data-streams\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Sending PostgreSQL data to AWS S3 by using AWS Kinesis data streams"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi services Blog","description":"#BeSharing","publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.dbi-services.com\/#organization","name":"dbi services","url":"https:\/\/www.dbi-services.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","width":512,"height":512,"caption":"dbi services"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/dbiservices\/","https:\/\/x.com\/dbiservices","https:\/\/www.linkedin.com\/company\/dbi-services\/","https:\/\/www.youtube.com\/user\/dbiservices"],"description":"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.","email":"info@dbi-services.com","telephone":"+41 32 422 96 00","legalName":"dbi services SA"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/0b4548362cac3eeff8b3eaf329e3530a","name":"Open source Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/05\/open-source-author.png","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/05\/open-source-author.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/05\/open-source-author.png","caption":"Open source Team"},"description":"Posts published under the Open source Team account are collective contributions by the dbi services open infrastructure consultants. The practice covers open-source databases and platforms, PostgreSQL first of all, along with MySQL, MariaDB, and Linux, from architecture, replication, and high availability to performance tuning and operations under service level agreements, and contributes actively to the PostgreSQL community.","url":"https:\/\/www.dbi-services.com\/blog\/author\/open-source-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/13789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=13789"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/13789\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media\/13790"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=13789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=13789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=13789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}