This folder contains examples of how to use the RDS module to create an Amazon
Relational Database Service (RDS) cluster that can run MySQL, Postgres, or MariaDB. The cluster is managed by AWS and
automatically handles leader election, replication, failover, backups, patching, and encryption.
The templates show an example of using RDS to run MySQL with one read replica.
Open up vars.tf and set secrets at the top of the file as environment variables and fill in any other variables in
the file that don't have defaults.
terraform init.
terraform plan.
If the plan looks good, run terraform apply.
When the templates are applied, Terraform will output the IP address of the cluster endpoint (which points to the
master) and the instance endpoints (which point to the master and all replicas).
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":"3febc0568334062c8b19707fc4dbcb3d6ab5450b"},{"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":"7d62dc3c8cd0e96131ee4e31a4b54829fa052166"},{"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","children":[{"name":"README.md","path":"examples/aurora/README.md","sha":"5113121e2255b63fa7609fe25dfb9b2555715655"},{"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":"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","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","toggled":true},{"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"}],"toggled":true}],"toggled":true},{"name":"modules","children":[{"name":"aurora","children":[{"name":"README-Aurora-Serverless.adoc","path":"modules/aurora/README-Aurora-Serverless.adoc","sha":"7a28bba029bd95affa541548ac19cb5c49a07e27"},{"name":"README-Aurora.adoc","path":"modules/aurora/README-Aurora.adoc","sha":"89ebb7a7c5aa8632a930c34993fc6c4cebe7efb4"},{"name":"README.adoc","path":"modules/aurora/README.adoc","sha":"f1717f1c088760357ec7b87edce843360aef6924"},{"name":"core-concepts.md","path":"modules/aurora/core-concepts.md","sha":"a3bdce9f1bb2a1d8b68c61856073cc01944d0b81"},{"name":"main.tf","path":"modules/aurora/main.tf","sha":"c7022c3ca7d29b209344dc13279509394556d453"},{"name":"outputs.tf","path":"modules/aurora/outputs.tf","sha":"337ff97e3beb8771c7a41ae482e8dc4432ebff37"},{"name":"vars.tf","path":"modules/aurora/vars.tf","sha":"f1f9979afadcb583f4a42f7be6053de7ed5ece13"}]},{"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":"11bfb303642008e506c4e822089b284e10626275"},{"name":"main.tf","path":"modules/rds/main.tf","sha":"09325b30c79c7e014dce2a4770b4a629884c6120"},{"name":"outputs.tf","path":"modules/rds/outputs.tf","sha":"f86cf8efcb26ce2338b04502fb192879e2722b5b"},{"name":"vars.tf","path":"modules/rds/vars.tf","sha":"e219adfc60d5b0377de6e0b675d0f0245cdc091c"}]}]},{"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":"f75d67c2fbb83804b46412d6d22180fa78995cce"},{"name":"example_lambda_rds_snapshot_create_resources_test.go","path":"test/example_lambda_rds_snapshot_create_resources_test.go","sha":"0155080d384bd257c68b7fd5ff563fa9a2dce679"},{"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":"20b652c6c16e86b5f449ab49429ca27c503ee78b"},{"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_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":"9379d0d2d712cd1efd870e7388327cf0ffa5d375"}]}]},"detailsContent":"<h1 class=\"preview__body--title\" id=\"rds-with-read-replicas-example\">RDS with Read Replicas Example</h1><div class=\"preview__body--border\"></div><p>This folder contains examples of how to use the <a href=\"/repos/v0.12.21/module-data-storage/modules/rds\" class=\"preview__body--description--blue\">RDS module</a> to create an Amazon\nRelational Database Service (RDS) cluster that can run MySQL, Postgres, or MariaDB. The cluster is managed by AWS and\nautomatically handles leader election, replication, failover, backups, patching, and encryption.</p>\n<p>The templates show an example of using RDS to run MySQL with one read replica.</p>\n<h2 class=\"preview__body--subtitle\" id=\"how-do-you-run-this-example\">How do you run this example?</h2>\n<p>To run this example, you need to:</p>\n<ol>\n<li>Install <a href=\"https://www.terraform.io/\" class=\"preview__body--description--blue\" target=\"_blank\">Terraform</a>.</li>\n<li>Open up <code>vars.tf</code> and set secrets at the top of the file as environment variables and fill in any other variables in\nthe file that don't have defaults.</li>\n<li><code>terraform init</code>.</li>\n<li><code>terraform plan</code>.</li>\n<li>If the plan looks good, run <code>terraform apply</code>.</li>\n</ol>\n<p>When the templates are applied, Terraform will output the IP address of the cluster endpoint (which points to the\nmaster) and the instance endpoints (which point to the master and all replicas).</p>\n","repoName":"module-data-storage","repoRef":"v0.12.13","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":"README.md","filePath":"/examples/rds-with-replicas","title":"Repo Browser: RDS","description":"Browse the repos in the Gruntwork Infrastructure as Code Library."}