memcached: Deploy an ElastiCache memcached cluster.
What is ElastiCache?
Elasticache is Amazon's implementation of a best-practices setup for two popular caching engines, memcached and redis.
It allows for easy establishment of a redundant caching cluster, backup and restore (redis only), and other popular
features. You pay a moderate premium over running the services yourself and everything is pre-configured for you.
How to Choose Redis vs. Memcached?
Amazon ElastiCache supports the Memcached and Redis cache engines. Each engine provides some advantages. Use the
information from the following references to help you choose the engine and version that best meets your requirements:
At Gruntwork, we've taken the thousands of hours we spent building infrastructure on AWS and
condensed all that experience and code into pre-built packages or modules. Each module is a battle-tested,
best-practices definition of a piece of infrastructure, such as a VPC, ECS cluster, or an Auto Scaling Group. Modules
are versioned using Semantic Versioning to allow Gruntwork clients to keep up to date with the
latest infrastructure best practices in a systematic way.
To use a module in your Terraform templates, create a module resource and set its source field to the Git URL of
this repo. You should also set the ref parameter so you're fixed to a specific version of this repo, as the main
branch may have backward incompatible changes (see module
sources).
For example, to use v1.0.8 of one of the data-cache modules, you would add the following:
module"redis_prod" {
source = "git::git@github.com:gruntwork-io/terraform-aws-cache.git//modules/redis?ref=v1.0.8"// set the parameters for the redis module
}
Note: the double slash (//) is intentional and required. It's part of Terraform's Git syntax (see module
sources).
See the module's documentation and vars.tf file for all the parameters you can set. Run terraform get -update to
pull the latest version of this module from this repo before running the standard terraform plan and
terraform apply commands.
NOTE: To automatically enforce terraform best practices, we recommend
using terragrunt.
Using scripts & binaries
You can install the scripts and binaries in the modules folder of any repo using the Gruntwork
Installer. For example, if the scripts you want to install are
in the modules/ecs-scripts folder of the https://github.com/gruntwork-io/terraform-aws-ecs repo, you could install
them
as follows:
See the docs for each script & binary for detailed instructions on how to use them.
Developing a module
Versioning
We are following the principles of Semantic Versioning. During initial development, the major
version is to 0 (e.g., 0.x.y), which indicates the code does not yet have a stable API. Once we hit 1.0.0, we will
follow these rules:
Increment the patch version for backwards-compatible bug fixes (e.g., v1.0.8 -> v1.0.9).
Increment the minor version for new features that are backwards-compatible (e.g., v1.0.8 -> 1.1.0).
Increment the major version for any backwards-incompatible changes (e.g. 1.0.8 -> 2.0.0).
The version is defined using Git tags. Use GitHub to create a release, which will have the effect of adding a git tag.
{"treedata":{"name":"root","toggled":true,"children":[{"name":".circleci","children":[{"name":"config.yml","path":".circleci/config.yml","sha":"9b7082a3e59f0ee119b255d798e3fb30546804e1"},{"name":"post-upgrade-test-results.sh","path":".circleci/post-upgrade-test-results.sh","sha":"a4867e8fbdc334b7a90259568ee41ea577fbe764"},{"name":"set-upgrade-test-vars.sh","path":".circleci/set-upgrade-test-vars.sh","sha":"9fa789c75021b87a65e658ac4ffc655511d42412"}]},{"name":".github","children":[{"name":"ISSUE_TEMPLATE","children":[{"name":"bug_report.md","path":".github/ISSUE_TEMPLATE/bug_report.md","sha":"d2e87e27c601e423865ed660ec697082470ca60f"},{"name":"feature_request.md","path":".github/ISSUE_TEMPLATE/feature_request.md","sha":"023a33099be2336476930c96e17ff1ba5dc55348"}]},{"name":"pull_request_template.md","path":".github/pull_request_template.md","sha":"6b100e40e323b5b07f40ed30616277c51c9f4b9e"}]},{"name":".gitignore","path":".gitignore","sha":"c816ce0f0e5ac5aeb14bcc0cc0ad002381f8bc99"},{"name":".pre-commit-config.yaml","path":".pre-commit-config.yaml","sha":"23068872ca60d7f40ae10c05ea8e5915d04056dc"},{"name":"CODEOWNERS","path":"CODEOWNERS","sha":"5d60e0a7033480ec2fe36250c1d8f3f47c37d1d0"},{"name":"LICENSE.txt","path":"LICENSE.txt","sha":"f4e3d9bd4717a044ed31ad847a300eee74371a78"},{"name":"README.md","path":"README.md","sha":"1521cd21f08f906dab626526813093bbbc158f5a","toggled":true},{"name":"examples","children":[{"name":"elasticache_bastion_host","children":[{"name":"README.md","path":"examples/elasticache_bastion_host/README.md","sha":"2f79a6de2c864125ebc059ac08d9ef053306ecfc"},{"name":"main.tf","path":"examples/elasticache_bastion_host/main.tf","sha":"095255c2472c43aa031474553ee43500d56b87ff"},{"name":"outputs.tf","path":"examples/elasticache_bastion_host/outputs.tf","sha":"ed63b2572f3813bd183dc5c48d21ce606ac6392e"},{"name":"redis-cli-install.sh","path":"examples/elasticache_bastion_host/redis-cli-install.sh","sha":"2ccd53ce730eb639413f26422fdac7a7eaeedffa"},{"name":"vars.tf","path":"examples/elasticache_bastion_host/vars.tf","sha":"8c5aba4d0fd661eee1fcd6c6bd5cf3943ff4cd73"}]},{"name":"memcached","children":[{"name":"README.md","path":"examples/memcached/README.md","sha":"25f3220196a9df56803eb2beb96d7ecca03f71ac"},{"name":"main.tf","path":"examples/memcached/main.tf","sha":"ac9357c9fab554ac9978b1fa78147c1f87e529c3"},{"name":"outputs.tf","path":"examples/memcached/outputs.tf","sha":"bc090567ef708bed42c4a64aaef937e8ae27b67a"},{"name":"vars.tf","path":"examples/memcached/vars.tf","sha":"eadad613f832bc0d23b1e45cafe241f94135d12d"}]},{"name":"redis","children":[{"name":"README.md","path":"examples/redis/README.md","sha":"4fa42b734382a224e1b296e0dc1c7120a193211d"},{"name":"main.tf","path":"examples/redis/main.tf","sha":"c484c6d8daef3e516806e7bf6a114ced0f96eec5"},{"name":"outputs.tf","path":"examples/redis/outputs.tf","sha":"c52d0992fa05f0687d5583cb27e0b34f04c19f71"},{"name":"vars.tf","path":"examples/redis/vars.tf","sha":"85fec2b3d209b6186e32d580c63520a6de763ebe"}]},{"name":"redis_copy_snapshot","children":[{"name":"README.md","path":"examples/redis_copy_snapshot/README.md","sha":"ff193cc8f6e0d2a796bc6d7c6ba97c147a27a238"},{"name":"main.tf","path":"examples/redis_copy_snapshot/main.tf","sha":"b1dbc4793bdcfbdfaa7638e5fbc58636ea1c2f92"},{"name":"outputs.tf","path":"examples/redis_copy_snapshot/outputs.tf","sha":"92cacac6cb2652ac0b6b7d2ae572a1a460e41719"},{"name":"vars.tf","path":"examples/redis_copy_snapshot/vars.tf","sha":"a8b755e0fdb353054e1af2b6b15d557b03a37ff1"}]},{"name":"redis_single_instance","children":[{"name":"README.md","path":"examples/redis_single_instance/README.md","sha":"4fa42b734382a224e1b296e0dc1c7120a193211d"},{"name":"main.tf","path":"examples/redis_single_instance/main.tf","sha":"9623e58defa91203405eda521b940f184dc8ec9a"},{"name":"outputs.tf","path":"examples/redis_single_instance/outputs.tf","sha":"061e0694468400960c507c63c96562d4bc7c2137"},{"name":"vars.tf","path":"examples/redis_single_instance/vars.tf","sha":"7e05023e51ac194e4ab5ae523925b1b24b080ddf"}]},{"name":"redis_with_auth_token","children":[{"name":"README.md","path":"examples/redis_with_auth_token/README.md","sha":"d33e94e9a9cada95aaf64a4f001732a60ed273a6"},{"name":"main.tf","path":"examples/redis_with_auth_token/main.tf","sha":"493e62bce940089b92ed8b41ee009d4b4a28565e"},{"name":"outputs.tf","path":"examples/redis_with_auth_token/outputs.tf","sha":"c52d0992fa05f0687d5583cb27e0b34f04c19f71"},{"name":"vars.tf","path":"examples/redis_with_auth_token/vars.tf","sha":"cf892d3f32b73a6b2411087aa5441e56422c94d0"}]},{"name":"redis_with_auto_scaling","children":[{"name":"README.md","path":"examples/redis_with_auto_scaling/README.md","sha":"f9bcdbde9516b877426e7f6c2c1bcde177483bab"},{"name":"main.tf","path":"examples/redis_with_auto_scaling/main.tf","sha":"240956fc62422756a0399bee4564d6170d6701a2"},{"name":"outputs.tf","path":"examples/redis_with_auto_scaling/outputs.tf","sha":"571b69d7463ab7f9032ca2b5d70dbc33eb0b646e"},{"name":"vars.tf","path":"examples/redis_with_auto_scaling/vars.tf","sha":"ad07361697e2ebac23995ba1cb26689a44a00de7"}]},{"name":"redis_with_sharding","children":[{"name":"README.md","path":"examples/redis_with_sharding/README.md","sha":"15db6dcbe096133c0be14055a6ac7aa91d3092fa"},{"name":"main.tf","path":"examples/redis_with_sharding/main.tf","sha":"f852c4f006c0f50e965c883fec4a069efbd2e46d"},{"name":"outputs.tf","path":"examples/redis_with_sharding/outputs.tf","sha":"571b69d7463ab7f9032ca2b5d70dbc33eb0b646e"},{"name":"vars.tf","path":"examples/redis_with_sharding/vars.tf","sha":"38e5a2fdfe9234cb70c0d22e0f3781d4c3b6199d"}]},{"name":"redis_with_user_group_id","children":[{"name":"README.md","path":"examples/redis_with_user_group_id/README.md","sha":"43d59aaa30561d2e108a79632340da19c96e1989"},{"name":"main.tf","path":"examples/redis_with_user_group_id/main.tf","sha":"ba1edbb6633c9daacbe8c25d1da6134cff44926f"},{"name":"outputs.tf","path":"examples/redis_with_user_group_id/outputs.tf","sha":"c52d0992fa05f0687d5583cb27e0b34f04c19f71"},{"name":"vars.tf","path":"examples/redis_with_user_group_id/vars.tf","sha":"df5def8b859db1ceb1e9e3fea2319e57b65a652b"}]}]},{"name":"modules","children":[{"name":"elastic-cache","children":[{"name":"README.md","path":"modules/elastic-cache/README.md","sha":"ddfa792dec8880597838c035637508b2107ca8ac"},{"name":"main.tf","path":"modules/elastic-cache/main.tf","sha":"0d55a8ae46259ec3c7375b8f049112aa7a0b1d30"},{"name":"outputs.tf","path":"modules/elastic-cache/outputs.tf","sha":"d06f7754cd290a0564acf247c75616b7d9fb376d"},{"name":"vars.tf","path":"modules/elastic-cache/vars.tf","sha":"c521fe91fc7b26cf7f929242b5d5102241fe6cf3"}]},{"name":"memcached","children":[{"name":"README.md","path":"modules/memcached/README.md","sha":"c5d3f4dc902f551347f460c0442ae8a0991ede04"},{"name":"main.tf","path":"modules/memcached/main.tf","sha":"f5d9c682bc1f9b7cdeec7a9568f38d4b24a76e9a"},{"name":"outputs.tf","path":"modules/memcached/outputs.tf","sha":"bcfc047b98700eab8e90005207c56c76443ac889"},{"name":"vars.tf","path":"modules/memcached/vars.tf","sha":"da98e60b8678e612cc842b5d373070ae1d7ee225"}]},{"name":"redis","children":[{"name":"README.md","path":"modules/redis/README.md","sha":"589c3555d479b4d108b83b296db37035efc49056"},{"name":"main.tf","path":"modules/redis/main.tf","sha":"8c59094530a638aff4081d7967cbb1bbb1c49c95"},{"name":"outputs.tf","path":"modules/redis/outputs.tf","sha":"991f74facba639eb60059df50581162311359472"},{"name":"vars.tf","path":"modules/redis/vars.tf","sha":"6e48be7a4ac50872cbe891f9fe300164d1c639f6"}]},{"name":"redis_copy_snapshot","children":[{"name":"README.md","path":"modules/redis_copy_snapshot/README.md","sha":"1f5cbae6c9cd26fd5621cf42c6a4fbe6789bda0c"},{"name":"main.tf","path":"modules/redis_copy_snapshot/main.tf","sha":"c2896827bb4f41dea2accf429bebb9a7119a2838"},{"name":"outputs.tf","path":"modules/redis_copy_snapshot/outputs.tf","sha":"32f0c0ccd6524757bf1b4c02cb48d33090d6ddd6"},{"name":"redis-copy-snapshot","children":[{"name":"index.py","path":"modules/redis_copy_snapshot/redis-copy-snapshot/index.py","sha":"f6a211b527de2c0a1ad56681fb78216e531b1eb2"}]},{"name":"vars.tf","path":"modules/redis_copy_snapshot/vars.tf","sha":"bc38a3fd66ca21e6bbc1a1e7d638eff5efcaf7b6"}]}]},{"name":"terraform-cloud-enterprise-private-module-registry-placeholder.tf","path":"terraform-cloud-enterprise-private-module-registry-placeholder.tf","sha":"ae586c0fe830819580e1009d41a9074f16e65bed"},{"name":"test","children":[{"name":"README.md","path":"test/README.md","sha":"09098790510ea89ab30850b01fa25e69f2730457"},{"name":"example_memcached_connection.go","path":"test/example_memcached_connection.go","sha":"7e1e51e64346c2646ef01aafc376ea69239dd781"},{"name":"example_memcached_test.go","path":"test/example_memcached_test.go","sha":"1ba2b92d1d37aeb9b55e5c28d02ac359caed5e9e"},{"name":"example_redis_connection.go","path":"test/example_redis_connection.go","sha":"28442755bdcfe0eea2919554eb4c2b8b789a87a0"},{"name":"example_redis_test.go","path":"test/example_redis_test.go","sha":"016afbc469e3001109c5cc9a7d0ca7dc4f37dfa1"},{"name":"example_util_functions.go","path":"test/example_util_functions.go","sha":"9deb8ef8a4a9621618fdf8e9512727e69b4f62e9"},{"name":"go.mod","path":"test/go.mod","sha":"96c01069450a12ffd236e8338dd61e7c7303ad50"},{"name":"go.sum","path":"test/go.sum","sha":"1eed465f1b93f5f6bc210bfe28fe799ca82fde89"},{"name":"upgrades","children":[{"name":"upgrade_test.go","path":"test/upgrades/upgrade_test.go","sha":"bb37da0ebf87700f0ea5c7385cd1ba7e45b69ede"}]},{"name":"validation","children":[{"name":"validate_all_modules_and_examples_test.go","path":"test/validation/validate_all_modules_and_examples_test.go","sha":"33d73c385b64c4fc870033e99427e683c31dc45a"}]}]}]},"detailsContent":"<h1 class=\"preview__body--title\" id=\"cache-modules\">Cache Modules</h1><div class=\"preview__body--border\"></div><p>This repo contains modules for running <a href=\"http://redis.io/\" class=\"preview__body--description--blue\" target=\"_blank\">Redis</a> and <a href=\"https://memcached.org/\" class=\"preview__body--description--blue\" target=\"_blank\">Memcached</a> distributed\ncache clusters using <a href=\"https://aws.amazon.com/elasticache/\" class=\"preview__body--description--blue\" target=\"_blank\">Amazon’s ElastiCache Service</a>:</p>\n<ul>\n<li><a href=\"/repos/v0.22.1/module-cache/modules/redis\" class=\"preview__body--description--blue\">redis</a>: Deploy an Elasticache redis cluster.</li>\n<li><a href=\"/repos/v0.22.1/module-cache/modules/memcached\" class=\"preview__body--description--blue\">memcached</a>: Deploy an ElastiCache memcached cluster.</li>\n</ul>\n<h2 class=\"preview__body--subtitle\" id=\"what-is-elasti-cache\">What is ElastiCache?</h2>\n<p>Elasticache is Amazon's implementation of a best-practices setup for two popular caching engines, memcached and redis.\nIt allows for easy establishment of a redundant caching cluster, backup and restore (redis only), and other popular\nfeatures. You pay a moderate premium over running the services yourself and everything is pre-configured for you.</p>\n<h2 class=\"preview__body--subtitle\" id=\"how-to-choose-redis-vs-memcached\">How to Choose Redis vs. Memcached?</h2>\n<p>Amazon ElastiCache supports the Memcached and Redis cache engines. Each engine provides some advantages. Use the\ninformation from the following references to help you choose the engine and version that best meets your requirements:</p>\n<ul>\n<li><a href=\"https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/SelectEngine.html\" class=\"preview__body--description--blue\" target=\"_blank\">Comparing Memcached and Redis</a></li>\n<li><a href=\"https://aws.amazon.com/elasticache/redis-vs-memcached/\" class=\"preview__body--description--blue\" target=\"_blank\">Comparing Redis and Memcached</a></li>\n</ul>\n<h2 class=\"preview__body--subtitle\" id=\"what-is-a-gruntwork-module\">What is a Gruntwork Module?</h2>\n<p>At <a href=\"http://www.gruntwork.io\" class=\"preview__body--description--blue\" target=\"_blank\">Gruntwork</a>, we've taken the thousands of hours we spent building infrastructure on AWS and\ncondensed all that experience and code into pre-built <strong>packages</strong> or <strong>modules</strong>. Each module is a battle-tested,\nbest-practices definition of a piece of infrastructure, such as a VPC, ECS cluster, or an Auto Scaling Group. Modules\nare versioned using <a href=\"http://semver.org/\" class=\"preview__body--description--blue\" target=\"_blank\">Semantic Versioning</a> to allow Gruntwork clients to keep up to date with the\nlatest infrastructure best practices in a systematic way.</p>\n<h2 class=\"preview__body--subtitle\" id=\"how-do-you-use-a-gruntwork-module\">How do you use a Gruntwork Module?</h2>\n<p>Most of our modules contain either:</p>\n<ol>\n<li><a href=\"https://www.terraform.io/\" class=\"preview__body--description--blue\" target=\"_blank\">Terraform</a> code</li>\n<li>Scripts & binaries</li>\n</ol>\n<h4 id=\"using-a-terraform-module\">Using a Terraform module</h4>\n<p>To use a module in your Terraform templates, create a <code>module</code> resource and set its <code>source</code> field to the Git URL of\nthis repo. You should also set the <code>ref</code> parameter so you're fixed to a specific version of this repo, as the <code>main</code>\nbranch may have backward incompatible changes (see <a href=\"https://www.terraform.io/docs/modules/sources.html\" class=\"preview__body--description--blue\" target=\"_blank\">module\nsources</a>).</p>\n<p>For example, to use <code>v1.0.8</code> of one of the data-cache modules, you would add the following:</p>\n<pre><span class=\"hljs-keyword\">module</span> <span class=\"hljs-string\">\"redis_prod\"</span> {\n source = <span class=\"hljs-string\">\"git::git@github.com:gruntwork-io/terraform-aws-cache.git//modules/redis?ref=v1.0.8\"</span>\n\n <span class=\"hljs-comment\">// set the parameters for the redis module</span>\n}\n</pre>\n<p><em>Note: the double slash (<code>//</code>) is intentional and required. It's part of Terraform's Git syntax (see <a href=\"https://www.terraform.io/docs/modules/sources.html\" class=\"preview__body--description--blue\" target=\"_blank\">module\nsources</a>).</em></p>\n<p>See the module's documentation and <code>vars.tf</code> file for all the parameters you can set. Run <code>terraform get -update</code> to\npull the latest version of this module from this repo before running the standard <code>terraform plan</code> and\n<code>terraform apply</code> commands.</p>\n<p><em>NOTE: To automatically enforce terraform best practices, we recommend\nusing <a href=\"/repos/terragrunt\" class=\"preview__body--description--blue\">terragrunt</a>.</em></p>\n<h4 id=\"using-scripts-binaries\">Using scripts & binaries</h4>\n<p>You can install the scripts and binaries in the <code>modules</code> folder of any repo using the <a href=\"/repos/gruntwork-installer\" class=\"preview__body--description--blue\">Gruntwork\nInstaller</a>. For example, if the scripts you want to install are\nin the <code>modules/ecs-scripts</code> folder of the https://github.com/gruntwork-io/terraform-aws-ecs repo, you could install\nthem\nas follows:</p>\n<pre><span class=\"hljs-string\">gruntwork-install </span><span class=\"hljs-built_in\">--module-name</span> <span class=\"hljs-string\">\"ecs-scripts\"</span> <span class=\"hljs-built_in\">--repo</span> <span class=\"hljs-string\">\"https://github.com/gruntwork-io/terraform-aws-ecs\"</span> <span class=\"hljs-built_in\">--tag</span> <span class=\"hljs-string\">\"0.0.1\"</span>\n</pre>\n<p>See the docs for each script & binary for detailed instructions on how to use them.</p>\n<h2 class=\"preview__body--subtitle\" id=\"developing-a-module\">Developing a module</h2>\n<h4 id=\"versioning\">Versioning</h4>\n<p>We are following the principles of <a href=\"http://semver.org/\" class=\"preview__body--description--blue\" target=\"_blank\">Semantic Versioning</a>. During initial development, the major\nversion is to 0 (e.g., <code>0.x.y</code>), which indicates the code does not yet have a stable API. Once we hit <code>1.0.0</code>, we will\nfollow these rules:</p>\n<ol>\n<li>Increment the patch version for backwards-compatible bug fixes (e.g., <code>v1.0.8 -> v1.0.9</code>).</li>\n<li>Increment the minor version for new features that are backwards-compatible (e.g., <code>v1.0.8 -> 1.1.0</code>).</li>\n<li>Increment the major version for any backwards-incompatible changes (e.g. <code>1.0.8 -> 2.0.0</code>).</li>\n</ol>\n<p>The version is defined using Git tags. Use GitHub to create a release, which will have the effect of adding a git tag.</p>\n<h4 id=\"tests\">Tests</h4>\n<p>See the <a href=\"/repos/v0.22.1/module-cache/test\" class=\"preview__body--description--blue\">test</a> folder for details.</p>\n<h2 class=\"preview__body--subtitle\" id=\"license\">License</h2>\n<p>Please see <a href=\"/repos/v0.22.1/module-cache/LICENSE.txt\" class=\"preview__body--description--blue\">LICENSE.txt</a> for details on how the code in this repo is licensed.</p>\n","repoName":"module-cache","repoRef":"v0.22.1","serviceDescriptor":{"serviceName":"Redis","serviceRepoName":"module-cache","serviceRepoOrg":"gruntwork-io","serviceMainReadmePath":"/modules/redis","cloudProviders":["aws"],"description":"Run a Redis cluster using Amazon’s ElastiCache Service. Supports replication, multi-zone automatic failover, and automatic backup.","imageUrl":"redis.png","licenseType":"subscriber","technologies":["Terraform","Bash"],"compliance":[],"tags":[""]},"serviceCategoryName":"NoSQL","fileName":"README.md","filePath":"","title":"Repo Browser: Redis","description":"Browse the repos in the Gruntwork Infrastructure as Code Library."}