Before Amazon Relational Database Service (RDS) existed, teams would painstakingly configure
PostgreSQL, MySQL, or other popular databases on their own. Setting up automatic failover, read replicas, backups, encryption,
and handling upgrades are all non-trivial and AWS recognized they could implement these features according to best practices
themselves, sparing customers the time and cost of doing it themselves.
Behind the scenes, RDS runs on EC2 Instances located in subnets and protected by security groups you specify.
Backups are handled by a snapshot taken on a nightly basis, but you can initiate a manual snapshot whenever you want. If
you select the Multi-AZ option, RDS will
synchronously copy every write to a standby and, in the event of a failure in the master server, automatically fail over
to the standby server.
In addition, if you wish to reduce the load on your primary database, one option is to add Read Replicas and direct all
read queries to them. RDS streamlines the process of adding and maintaining Read Replicas.
Common Gotcha's
All RDS upgrades (version upgrades, instance type upgrades, etc.) require a few minutes of scheduled downtime.
If an RDS instance that uses Multi-AZ fails, Amazon will automatically kick off a fail-over, but you will still experience
about 3 - 5 minutes of downtime.
Based on the above, make sure you've written your app to gracefully handle database downtime.
An RDS instance that runs out of disk space will stop working, so be sure to monitor and set an alert on the FreeStorageSpace
CloudWatch Metric. Consider monitoring other RDS CloudWatch Metrics
as well.
Primary endpoint: The endpoint for the primary DB. You should always use this URL for writes, as it points to
the primary.
Read replica endpoints: A comma-separated list of read replica URLs.
Port: The port to use to connect to the endpoints above.
You can programmatically extract these variables in your Terraform templates and pass them to other resources (e.g.
pass them to User Data in your EC2 instances). You'll also see the variables at the end of each terraform apply call
or if you run terraform output.
Note that the database is likely behind a Bastion Host, so you may need to first connect to the Bastion Host (or use SSH
Tunneling) before you can connect to the database.
How do you scale this database?
Storage: Use the allocated_storage variable.
Vertical scaling: To scale vertically (i.e. bigger DB instances with more CPU and RAM), use the instance_type,
storage_type, and iops input variables. For a list of AWS RDS server types, see DB Instance
Class
Horizontal scaling: To scale horizontally, you can add more replicas using the num_read_replicas input variable,
and RDS will automatically deploy the new instances, begin asynchronous replication, and make them available as read
replicas. FOr more info, see Working with PostgreSQL, MySQL, and MariaDB Read
Replicas.
How do you configure this module?
This module allows you to configure a number of parameters, such as backup windows, maintenance window, port number,
and encryption. For a list of all available variables and their descriptions, see vars.tf.
Minor version upgrades
RDS supports automatically installing minor version upgrades: e.g., automatically updating a MySQL database from 5.7.10
to 5.7.11. To enable this functionality:
Set the auto_minor_version_upgrade parameter to true.
Set the engine_version parameter to MAJOR.MINOR and omit the PATCH: e.g., use 5.7 instead of 5.7.11. If you
include the PATCH number, you'll get state drift each time the minor version is updated. See the engine_version
parameter docs for details.
Questions? Ask away.
We're here to talk about our services, answer any questions, give advice, or just to chat.
{"treedata":{"name":"root","toggled":true,"children":[{"name":".circleci","children":[{"name":"config.yml","path":".circleci/config.yml","sha":"e161caf8ec8e50bf9bc8412104db4130a18fc76f"}]},{"name":".gitignore","path":".gitignore","sha":"b221764008a74751a75f9ba58821c7e7bd7422b2"},{"name":".pre-commit-config.yaml","path":".pre-commit-config.yaml","sha":"dd17d910687309b3ad64bae6e967df72e5417357"},{"name":"CODEOWNERS","path":"CODEOWNERS","sha":"f6e0666fa0dee5df6743291167734a2bcfbb359b"},{"name":"LICENSE.txt","path":"LICENSE.txt","sha":"f4e3d9bd4717a044ed31ad847a300eee74371a78"},{"name":"README.adoc","path":"README.adoc","sha":"683afbce72ea0c7b626932bd314b9c2ae992c207"},{"name":"_docs","children":[{"name":"aurora-serverless.png","path":"_docs/aurora-serverless.png","sha":"5a53145be56705c76f7f7aa6a25aa0ddee78e4a3"},{"name":"aurora.png","path":"_docs/aurora.png","sha":"fc218831bfa34097a56f1b0e47fe05521bdb4a8a"},{"name":"data-backup-architecture.png","path":"_docs/data-backup-architecture.png","sha":"fcc7ce8753e28c19af87ea5cea96e6ded648d429"},{"name":"data-backup.png","path":"_docs/data-backup.png","sha":"116b10f231073f8c52255ca98e48cc228c48a2c3"},{"name":"mariadb.png","path":"_docs/mariadb.png","sha":"d540d3d3ff8797c4a4c3a62c65e7d3f63621568f"},{"name":"mysql.png","path":"_docs/mysql.png","sha":"73b55bd0d517dcba53c878712544abf96be3a66e"},{"name":"oracle.png","path":"_docs/oracle.png","sha":"b5f1ca801f5af4a30f1b812eea17cec516c1fe6c"},{"name":"postgresql.png","path":"_docs/postgresql.png","sha":"fd9c7ec282aef38a5813e8542d92227b96bd5be8"},{"name":"rds-architecture.png","path":"_docs/rds-architecture.png","sha":"8f2b1b5b4015a5777032c6aa64627ceee24330fc"},{"name":"sqlserver.png","path":"_docs/sqlserver.png","sha":"a800d188398262593f4f89f27c8f3ce2ce1e76a4"}]},{"name":"examples","children":[{"name":"aurora-global-cluster","children":[{"name":"README.md","path":"examples/aurora-global-cluster/README.md","sha":"bbefa516493669a8134131aa4f6c9892ca17a932"},{"name":"main.tf","path":"examples/aurora-global-cluster/main.tf","sha":"86f00cb270ff79546ce995fb6c2e204016745d28"},{"name":"outputs.tf","path":"examples/aurora-global-cluster/outputs.tf","sha":"105d706d41684b4c7be092ebd43bf6ba8ebf6f80"},{"name":"vars.tf","path":"examples/aurora-global-cluster/vars.tf","sha":"29b33911054fde667cd778658a7bc63f3a61bedd"}]},{"name":"aurora-serverless","children":[{"name":"README.md","path":"examples/aurora-serverless/README.md","sha":"073a25d4190dc28f64d2e1675c30e60eb255d306"},{"name":"main.tf","path":"examples/aurora-serverless/main.tf","sha":"059474ef6c778717ede7bdc2367453ac41d11c53"},{"name":"outputs.tf","path":"examples/aurora-serverless/outputs.tf","sha":"7da44a91e9ac6e14a5c7c144c60c5ad0ceb5ce1b"},{"name":"vars.tf","path":"examples/aurora-serverless/vars.tf","sha":"be0acaabd7f525d00ded7bb8ace8a3e54b03e160"}]},{"name":"aurora-with-cross-region-replica","children":[{"name":"README.md","path":"examples/aurora-with-cross-region-replica/README.md","sha":"17c93f6fc01e4df4bc8014f33773dc5f05ab8017"},{"name":"main.tf","path":"examples/aurora-with-cross-region-replica/main.tf","sha":"d7afff3c426686203b179446cda4bdbc12f51d71"},{"name":"outputs.tf","path":"examples/aurora-with-cross-region-replica/outputs.tf","sha":"58a3862180d107c3d0501ec9b289b08ed09af3a8"},{"name":"vars.tf","path":"examples/aurora-with-cross-region-replica/vars.tf","sha":"0890cddb1b6aac72b378632e9ed131a9bd177e04"}]},{"name":"aurora","children":[{"name":"README.md","path":"examples/aurora/README.md","sha":"8190444c83829a5b7a4e9acad31414e0dced277a"},{"name":"main.tf","path":"examples/aurora/main.tf","sha":"e92bd5e6c1bcdd18b482eaf326a35d7a8c3bc20a"},{"name":"outputs.tf","path":"examples/aurora/outputs.tf","sha":"142569b7d9772c741ee28846de617f5a4b7f0d84"},{"name":"vars.tf","path":"examples/aurora/vars.tf","sha":"e046db594a501fcb4ff0252a2ac5e187dd382ccf"}]},{"name":"efs","children":[{"name":"README.md","path":"examples/efs/README.md","sha":"5b883e1deac79fb511a39fa062bd854f2a903579"},{"name":"main.tf","path":"examples/efs/main.tf","sha":"b79d5ebd7d310957e67c834f7464e47a86c94b08"},{"name":"outputs.tf","path":"examples/efs/outputs.tf","sha":"b5a6400d4a67e1e6f6773c513acaa8784ceda46b"},{"name":"vars.tf","path":"examples/efs/vars.tf","sha":"db0919b5bbfca3fee37baf1d35272ed2108d5405"}]},{"name":"lambda-rds-snapshot-multiple-schedules","children":[{"name":"README.md","path":"examples/lambda-rds-snapshot-multiple-schedules/README.md","sha":"c76bcf6ba6865fe2a9e4a7d9b47d231ae7822e47"},{"name":"main.tf","path":"examples/lambda-rds-snapshot-multiple-schedules/main.tf","sha":"ffab74de147c8db13f4bc1ad2ee9fb5096460bbd"},{"name":"outputs.tf","path":"examples/lambda-rds-snapshot-multiple-schedules/outputs.tf","sha":"7a8f966782c659d1568f35684197f232939ea9ec"},{"name":"vars.tf","path":"examples/lambda-rds-snapshot-multiple-schedules/vars.tf","sha":"f6ae16692c02a1ae6ed95d58e16bd3e02b98f703"}]},{"name":"lambda-rds-snapshot","children":[{"name":"README.md","path":"examples/lambda-rds-snapshot/README.md","sha":"d7422ca3a039c7e1056c17fc73fbbddfddce6741"},{"name":"main.tf","path":"examples/lambda-rds-snapshot/main.tf","sha":"75251ca7c930bcb08c445fb54c3aa020c1cedc43"},{"name":"outputs.tf","path":"examples/lambda-rds-snapshot/outputs.tf","sha":"375c8bb979dd4133c3675d9e6263e1138c448973"},{"name":"vars.tf","path":"examples/lambda-rds-snapshot/vars.tf","sha":"b777711ea9860aa43f766a5e5edf8b817e994885"}]},{"name":"rds-mariadb","children":[{"name":"README.md","path":"examples/rds-mariadb/README.md","sha":"6540229dddcb38071d37b6697762d27a54e28cc8"},{"name":"main.tf","path":"examples/rds-mariadb/main.tf","sha":"4e5f33f401105871a290f413648ead0627da1ff1"},{"name":"outputs.tf","path":"examples/rds-mariadb/outputs.tf","sha":"bd45b0035943021763d0365da3fe0d1e9f9b16b9"},{"name":"vars.tf","path":"examples/rds-mariadb/vars.tf","sha":"6a8212a3c4e8d4bbd1fe6f000bb699b9f5ecf1e0"}]},{"name":"rds-mysql-with-cross-region-replica","children":[{"name":"README.md","path":"examples/rds-mysql-with-cross-region-replica/README.md","sha":"4671d1e9a47e6179c5dc809bf27cffc3468b3460"},{"name":"main.tf","path":"examples/rds-mysql-with-cross-region-replica/main.tf","sha":"c311da161b96fefb50c7f0d585238236447c3fa7"},{"name":"outputs.tf","path":"examples/rds-mysql-with-cross-region-replica/outputs.tf","sha":"2d79e34b6bc52c934a62e40e38e3cdcace5196a0"},{"name":"vars.tf","path":"examples/rds-mysql-with-cross-region-replica/vars.tf","sha":"e29f844891c30bb88097a66328081dde94b2e611"}]},{"name":"rds-mysql","children":[{"name":"README.md","path":"examples/rds-mysql/README.md","sha":"6a7fb5d5560cc42ec9a6ac830358aa7ab7ca502d"},{"name":"main.tf","path":"examples/rds-mysql/main.tf","sha":"e86671206fa3089c64d24076c80b0f261096bf93"},{"name":"outputs.tf","path":"examples/rds-mysql/outputs.tf","sha":"e2ae2afdbcc0d27baa5d50be333f9d0a717e1a33"},{"name":"vars.tf","path":"examples/rds-mysql/vars.tf","sha":"0ee52281448e95f13fcaacf427bed62600a32c23"}]},{"name":"rds-postgres","children":[{"name":"README.md","path":"examples/rds-postgres/README.md","sha":"ab4e18c200fc749a54ee700223d27261c731e436"},{"name":"main.tf","path":"examples/rds-postgres/main.tf","sha":"e122b2ad8421c1ed31d8381c0e9dc7cac89e374c"},{"name":"outputs.tf","path":"examples/rds-postgres/outputs.tf","sha":"5371c2284c0ea3d4de5790077ba45d9d445c2965"},{"name":"vars.tf","path":"examples/rds-postgres/vars.tf","sha":"0f2541c42ceef4f29fcfdc4aa8141d18b854f7f5"}]},{"name":"rds-sqlserver","children":[{"name":"README.md","path":"examples/rds-sqlserver/README.md","sha":"26bf52d347c247e5f63bc113476e87d75375ba84"},{"name":"main.tf","path":"examples/rds-sqlserver/main.tf","sha":"376fd7e96798604d81c1a8526f204114500ff835"},{"name":"outputs.tf","path":"examples/rds-sqlserver/outputs.tf","sha":"a1726fd73528af38b436c053128f24a17da740c3"},{"name":"vars.tf","path":"examples/rds-sqlserver/vars.tf","sha":"dabccb3da2548b8a9e302ed5e9be01b18c275ca9"}]},{"name":"rds-with-replicas","children":[{"name":"README.md","path":"examples/rds-with-replicas/README.md","sha":"327357a98e9b2bbf650d91a207bd96fc4a6f452f"},{"name":"main.tf","path":"examples/rds-with-replicas/main.tf","sha":"d8079695d12f3ac41c447f5c1375877d87a7a369"},{"name":"outputs.tf","path":"examples/rds-with-replicas/outputs.tf","sha":"991d5436a635194fec1ad1476eb7be6616032c7a"},{"name":"vars.tf","path":"examples/rds-with-replicas/vars.tf","sha":"a1ab0eaadeaee910d4b81265ba28524917926e6c"}]}]},{"name":"modules","children":[{"name":"aurora","children":[{"name":"README-Aurora-Serverless.adoc","path":"modules/aurora/README-Aurora-Serverless.adoc","sha":"9029de222f9bcf675ff37d7e97b9eae29664fb34"},{"name":"README-Aurora.adoc","path":"modules/aurora/README-Aurora.adoc","sha":"89ebb7a7c5aa8632a930c34993fc6c4cebe7efb4"},{"name":"README.adoc","path":"modules/aurora/README.adoc","sha":"d0e19665bb22ad2a62968f6ae047d1685f984d80"},{"name":"core-concepts.md","path":"modules/aurora/core-concepts.md","sha":"c359faf7ca9789e73296433b9c5fdb19956fa16a"},{"name":"main.tf","path":"modules/aurora/main.tf","sha":"82c263652f421f934dd9f2c0771a46e7bab39f33"},{"name":"outputs.tf","path":"modules/aurora/outputs.tf","sha":"f27a9f761484528ef8d6cdfc687dbb936307bf48"},{"name":"vars.tf","path":"modules/aurora/vars.tf","sha":"fb9bf14db0a05facdb07197e916ea42d189c3431"}]},{"name":"efs","children":[{"name":"README.adoc","path":"modules/efs/README.adoc","sha":"165387a5ef2015a3f3a930ea3d4f1703453254bd"},{"name":"main.tf","path":"modules/efs/main.tf","sha":"163d66587f1372cd7ad28e32aab43afb552fa7ce"},{"name":"outputs.tf","path":"modules/efs/outputs.tf","sha":"b505b3d3c4ade32e06286ebea60be1a5f67ce77a"},{"name":"vars.tf","path":"modules/efs/vars.tf","sha":"ada809d408ec9a125e372dd4f04b1b1c30e28d82"}]},{"name":"lambda-cleanup-snapshots","children":[{"name":"README.md","path":"modules/lambda-cleanup-snapshots/README.md","sha":"2c491aeca99fac0536e6c86ef850e00146ac7259"},{"name":"cleanup-rds-snapshots","children":[{"name":"index.py","path":"modules/lambda-cleanup-snapshots/cleanup-rds-snapshots/index.py","sha":"9e651d2d57310054e21d891aec481d02c9d79489"}]},{"name":"main.tf","path":"modules/lambda-cleanup-snapshots/main.tf","sha":"0cc60eb6b3491ff144ecf64d078b9a962f993f7b"},{"name":"outputs.tf","path":"modules/lambda-cleanup-snapshots/outputs.tf","sha":"a99c0265d859dd0c87a6eba62aaf2b013e224873"},{"name":"vars.tf","path":"modules/lambda-cleanup-snapshots/vars.tf","sha":"6a8d68f55cf51d75ec84caed75ebcb2ea25a5dab"}]},{"name":"lambda-copy-shared-snapshot","children":[{"name":"README.md","path":"modules/lambda-copy-shared-snapshot/README.md","sha":"9953dc7e2429ffa95751d868b725018fedc03a4e"},{"name":"copy-shared-rds-snapshot","children":[{"name":"index.py","path":"modules/lambda-copy-shared-snapshot/copy-shared-rds-snapshot/index.py","sha":"6b1a0331ee9ffc57c95e0923a4b1db46dec0b2c5"}]},{"name":"main.tf","path":"modules/lambda-copy-shared-snapshot/main.tf","sha":"3cadd2f4a757bc5284a994266ef2cf9ab574ac0d"},{"name":"outputs.tf","path":"modules/lambda-copy-shared-snapshot/outputs.tf","sha":"f4833d96fa6d47190b9d2c3af243142aefc59d59"},{"name":"vars.tf","path":"modules/lambda-copy-shared-snapshot/vars.tf","sha":"167544053dc243f447befed6b576c3b515bc6d58"}]},{"name":"lambda-create-snapshot","children":[{"name":"README.adoc","path":"modules/lambda-create-snapshot/README.adoc","sha":"4c6a9c7fa49b66aeeeae492b895bb98d97ab3062"},{"name":"core-concepts.md","path":"modules/lambda-create-snapshot/core-concepts.md","sha":"3b0830d9d0af865d78d5014d4bd2d57c25eb4bf0"},{"name":"create-rds-snapshot","children":[{"name":"index.py","path":"modules/lambda-create-snapshot/create-rds-snapshot/index.py","sha":"16bc7d1b67dcee20577808cdbf39b1938972c5cb"}]},{"name":"main.tf","path":"modules/lambda-create-snapshot/main.tf","sha":"4293138b27a0f883d75510a360c89eba356f0deb"},{"name":"outputs.tf","path":"modules/lambda-create-snapshot/outputs.tf","sha":"a0f5ffafa8ef11d00b72f1858b81e182ab2471dd"},{"name":"vars.tf","path":"modules/lambda-create-snapshot/vars.tf","sha":"f18942d85d2e7c5dc4c629b1503a1c32a52e4b56"}]},{"name":"lambda-share-snapshot","children":[{"name":"README.md","path":"modules/lambda-share-snapshot/README.md","sha":"f00a0ab9745632e85d5f4c8e7a9389e1a8608b6b"},{"name":"main.tf","path":"modules/lambda-share-snapshot/main.tf","sha":"51bcabb9cca3400b0fd42cf0ff8be63592b1c926"},{"name":"outputs.tf","path":"modules/lambda-share-snapshot/outputs.tf","sha":"c0d2854f967a6c963662c660d6ae96d8cabe471a"},{"name":"share-rds-snapshot","children":[{"name":"index.py","path":"modules/lambda-share-snapshot/share-rds-snapshot/index.py","sha":"b4e784ff72172d1f3e84f0f97a48fdf60405ed27"}]},{"name":"vars.tf","path":"modules/lambda-share-snapshot/vars.tf","sha":"683571dbf98c2fb4f8077e7adadcb4df4241b9b4"}]},{"name":"rds","children":[{"name":"README-MariaDb.adoc","path":"modules/rds/README-MariaDb.adoc","sha":"52c88eedb3410b14c6ccc4db8ea3eaa484b7c13a"},{"name":"README-MySQL.adoc","path":"modules/rds/README-MySQL.adoc","sha":"75a2e92b04368988ffe7fb405a99155881f2c4f7"},{"name":"README-Oracle.adoc","path":"modules/rds/README-Oracle.adoc","sha":"a9f084cfbd084413bbcc818fd9f438a4faee367b"},{"name":"README-PostgreSQL.adoc","path":"modules/rds/README-PostgreSQL.adoc","sha":"2486401acaa724eba2f0a8814ef9dfa19c510ae0"},{"name":"README-SqlServer.adoc","path":"modules/rds/README-SqlServer.adoc","sha":"76d7220a727d84567e819102617bd01a3bda0cb2"},{"name":"README.adoc","path":"modules/rds/README.adoc","sha":"fa2c8270106116804fa8ee61a7b5885ab8a4833f"},{"name":"core-concepts.md","path":"modules/rds/core-concepts.md","sha":"29463161611168b652ba94e011604f23395cde9a","toggled":true},{"name":"main.tf","path":"modules/rds/main.tf","sha":"1afe15825f438b1dcfb64c7414504027e8e772ff"},{"name":"outputs.tf","path":"modules/rds/outputs.tf","sha":"ffd8da9da933ee678f56befbf8ee7edcc19cd6cf"},{"name":"vars.tf","path":"modules/rds/vars.tf","sha":"d03e3df258908ee7c3cf712aeae83fbd17872280"}],"toggled":true}],"toggled":true},{"name":"test","children":[{"name":"README.md","path":"test/README.md","sha":"ebcf2313b7664113168ca7e73d01acbd232d8f39"},{"name":"example_aurora_global_test.go","path":"test/example_aurora_global_test.go","sha":"12cd47486d7f62a862f36265fb41c08fb598404a"},{"name":"example_aurora_test.go","path":"test/example_aurora_test.go","sha":"14485405d1f5899ca61bea11ba4b7f41d6234d6e"},{"name":"example_aurora_with_cross_region_replica_test.go","path":"test/example_aurora_with_cross_region_replica_test.go","sha":"2fe4b909abbeebfc4cddff2237d6b2470982cd8a"},{"name":"example_efs_test.go","path":"test/example_efs_test.go","sha":"c84d706017cb7ca512c4a4070b470ecc586ffc89"},{"name":"example_lambda_rds_snapshot_create_resources_test.go","path":"test/example_lambda_rds_snapshot_create_resources_test.go","sha":"1af623cab68b918b65fe3e7389377ce08a7bf98c"},{"name":"example_lambda_rds_snapshot_multiple_schedules_test.go","path":"test/example_lambda_rds_snapshot_multiple_schedules_test.go","sha":"094a8a691f259f79943e7fbf672d2ff8b40b65e4"},{"name":"example_lambda_rds_snapshot_test.go","path":"test/example_lambda_rds_snapshot_test.go","sha":"092e678c8f1297d2767141295933ea4e5795aae1"},{"name":"example_rds_mariadb_test.go","path":"test/example_rds_mariadb_test.go","sha":"bdfeed4be219420de6fe37471d9f3231cdd5a829"},{"name":"example_rds_mysql_test.go","path":"test/example_rds_mysql_test.go","sha":"cfc6ef03fb0a9ae01f889f6a5db83ed49b008ed2"},{"name":"example_rds_mysql_with_cross_region_replica_test.go","path":"test/example_rds_mysql_with_cross_region_replica_test.go","sha":"048a9b1ec7ca8fd9acce6f9022e178312b5b2b68"},{"name":"example_rds_postgres_test.go","path":"test/example_rds_postgres_test.go","sha":"d301ebc1542294b294eb299038abff9d305da804"},{"name":"example_rds_sqlserver_test.go","path":"test/example_rds_sqlserver_test.go","sha":"96ae522976ae664c9e74cbd29293f49d7ed2fa26"},{"name":"example_rds_with_replicas_test.go","path":"test/example_rds_with_replicas_test.go","sha":"ed3c82e66d48c8388a04363cab2e1b3458f4a7fb"},{"name":"go.mod","path":"test/go.mod","sha":"3245f043b6d05e295fb010ff8886971e4bf1a26a"},{"name":"go.sum","path":"test/go.sum","sha":"de745a2994481da56e437d25c745cea5c7d7fd9f"},{"name":"util.go","path":"test/util.go","sha":"a29464ed90a313f6182d38126198a9069b8a1262"}]}]},"detailsContent":"<h1 class=\"preview__body--title\" id=\"core-rds-concepts\">Core RDS Concepts</h1><div class=\"preview__body--border\"></div><h2 class=\"preview__body--subtitle\" id=\"what-is-amazon-rds\">What is Amazon RDS?</h2>\n<p>Before <a href=\"https://aws.amazon.com/rds/\" class=\"preview__body--description--blue\" target=\"_blank\">Amazon Relational Database Service</a> (RDS) existed, teams would painstakingly configure\nPostgreSQL, MySQL, or other popular databases on their own. Setting up automatic failover, read replicas, backups, encryption,\nand handling upgrades are all non-trivial and AWS recognized they could implement these features according to best practices\nthemselves, sparing customers the time and cost of doing it themselves.</p>\n<p>Behind the scenes, RDS runs on EC2 Instances located in subnets and protected by security groups you specify.</p>\n<p>Backups are handled by a snapshot taken on a nightly basis, but you can initiate a manual snapshot whenever you want. If\nyou select the <a href=\"http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.MultiAZ.html\" class=\"preview__body--description--blue\" target=\"_blank\">Multi-AZ</a> option, RDS will\nsynchronously copy every write to a standby and, in the event of a failure in the master server, automatically fail over\nto the standby server.</p>\n<p>In addition, if you wish to reduce the load on your primary database, one option is to add Read Replicas and direct all\nread queries to them. RDS streamlines the process of adding and maintaining Read Replicas.</p>\n<h2 class=\"preview__body--subtitle\" id=\"common-gotchas\">Common Gotcha's</h2>\n<ul>\n<li>All RDS upgrades (version upgrades, instance type upgrades, etc.) require a few minutes of scheduled downtime.</li>\n<li>If an RDS instance that uses Multi-AZ fails, Amazon will automatically kick off a fail-over, but you will still experience\nabout 3 - 5 minutes of downtime.</li>\n<li>Based on the above, make sure you've written your app to gracefully handle database downtime.</li>\n<li>An RDS instance that runs out of disk space will stop working, so be sure to monitor and set an alert on the <code>FreeStorageSpace</code>\nCloudWatch Metric. Consider monitoring other <a href=\"http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/rds-metricscollected.html\" class=\"preview__body--description--blue\" target=\"_blank\">RDS CloudWatch Metrics</a>\nas well.</li>\n</ul>\n<h2 class=\"preview__body--subtitle\" id=\"how-do-you-connect-to-the-database\">How do you connect to the database?</h2>\n<p>This module provides the connection details as <a href=\"https://www.terraform.io/intro/getting-started/outputs.html\" class=\"preview__body--description--blue\" target=\"_blank\">Terraform output\nvariables</a>:</p>\n<ol>\n<li><strong>Primary endpoint</strong>: The endpoint for the primary DB. You should always use this URL for writes, as it points to\nthe primary.</li>\n<li><strong>Read replica endpoints</strong>: A comma-separated list of read replica URLs.</li>\n<li><strong>Port</strong>: The port to use to connect to the endpoints above.</li>\n</ol>\n<p>You can programmatically extract these variables in your Terraform templates and pass them to other resources (e.g.\npass them to User Data in your EC2 instances). You'll also see the variables at the end of each <code>terraform apply</code> call\nor if you run <code>terraform output</code>.</p>\n<p>Note that the database is likely behind a Bastion Host, so you may need to first connect to the Bastion Host (or use SSH\nTunneling) before you can connect to the database.</p>\n<h2 class=\"preview__body--subtitle\" id=\"how-do-you-scale-this-database\">How do you scale this database?</h2>\n<ul>\n<li><strong>Storage</strong>: Use the <code>allocated_storage</code> variable.</li>\n<li><strong>Vertical scaling</strong>: To scale vertically (i.e. bigger DB instances with more CPU and RAM), use the <code>instance_type</code>,\n<code>storage_type</code>, and <code>iops</code> input variables. For a list of AWS RDS server types, see <a href=\"http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html\" class=\"preview__body--description--blue\" target=\"_blank\">DB Instance\nClass</a></li>\n<li><strong>Horizontal scaling</strong>: To scale horizontally, you can add more replicas using the <code>num_read_replicas</code> input variable,\nand RDS will automatically deploy the new instances, begin asynchronous replication, and make them available as read\nreplicas. FOr more info, see <a href=\"https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ReadRepl.html#USER_ReadRepl.Overview\" class=\"preview__body--description--blue\" target=\"_blank\">Working with PostgreSQL, MySQL, and MariaDB Read\nReplicas</a>.</li>\n</ul>\n<h2 class=\"preview__body--subtitle\" id=\"how-do-you-configure-this-module\">How do you configure this module?</h2>\n<p>This module allows you to configure a number of parameters, such as backup windows, maintenance window, port number,\nand encryption. For a list of all available variables and their descriptions, see <a href=\"/repos/v0.18.1/module-data-storage/modules/rds/vars.tf\" class=\"preview__body--description--blue\">vars.tf</a>.</p>\n<h2 class=\"preview__body--subtitle\" id=\"minor-version-upgrades\">Minor version upgrades</h2>\n<p>RDS supports automatically installing minor version upgrades: e.g., automatically updating a MySQL database from 5.7.10\nto 5.7.11. To enable this functionality:</p>\n<ol>\n<li>Set the <code>auto_minor_version_upgrade</code> parameter to <code>true</code>.</li>\n<li>Set the <code>engine_version</code> parameter to <code>MAJOR.MINOR</code> and omit the <code>PATCH</code>: e.g., use 5.7 instead of 5.7.11. If you\ninclude the <code>PATCH</code> number, you'll get state drift each time the minor version is updated. See the <a href=\"https://www.terraform.io/docs/providers/aws/r/db_instance.html#engine_version\" class=\"preview__body--description--blue\" target=\"_blank\"><code>engine_version</code>\nparameter docs</a> for details.</li>\n</ol>\n","repoName":"module-data-storage","repoRef":"v0.13.0","serviceDescriptor":{"serviceName":"RDS","serviceRepoName":"module-data-storage","serviceRepoOrg":"gruntwork-io","serviceMainReadmePath":"/modules/rds/foo","cloudProviders":["aws"],"description":"Terraform code and scripts for deploying data-storage resources (e.g. databases, cache) in AWS","imageUrl":"amazon_rds.png","licenseType":"subscriber","technologies":["Terraform","Bash"],"compliance":[],"tags":[""],"noDisplayInUI":true},"serviceCategoryName":"Database","fileName":"core-concepts.md","filePath":"/modules/rds/core-concepts.md","title":"Repo Browser: RDS","description":"Browse the repos in the Gruntwork Infrastructure as Code Library."}