├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── bug_report.yml │ ├── config.yml │ ├── feature_request.md │ ├── feature_request.yml │ └── question.md ├── PULL_REQUEST_TEMPLATE.md ├── banner.png ├── mergify.yml ├── renovate.json ├── settings.yml └── workflows │ ├── branch.yml │ ├── chatops.yml │ ├── release.yml │ └── scheduled.yml ├── .gitignore ├── LICENSE ├── README.md ├── README.yaml ├── atmos.yaml ├── context.tf ├── examples └── complete │ ├── context.tf │ ├── fixtures.us-east-2.tfvars │ ├── main.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── main.tf ├── outputs.tf ├── security-group-inputs.tf ├── test ├── .gitignore ├── Makefile ├── Makefile.alpine └── src │ ├── .gitignore │ ├── Makefile │ ├── examples_complete_test.go │ ├── go.mod │ └── go.sum ├── variables-deprecated.tf ├── variables.tf └── versions.tf /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Use this file to define individuals or teams that are responsible for code in a repository. 2 | # Read more: 3 | # 4 | # Order is important: the last matching pattern has the highest precedence 5 | 6 | # These owners will be the default owners for everything 7 | * @cloudposse/engineering @cloudposse/contributors 8 | 9 | # Cloud Posse must review any changes to Makefiles 10 | **/Makefile @cloudposse/engineering 11 | **/Makefile.* @cloudposse/engineering 12 | 13 | # Cloud Posse must review any changes to GitHub actions 14 | .github/* @cloudposse/engineering 15 | 16 | # Cloud Posse must review any changes to standard context definition, 17 | # but some changes can be rubber-stamped. 18 | **/*.tf @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers 19 | README.yaml @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers 20 | README.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers 21 | docs/*.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers 22 | 23 | # Cloud Posse Admins must review all changes to CODEOWNERS or the mergify configuration 24 | .github/mergify.yml @cloudposse/admins 25 | .github/CODEOWNERS @cloudposse/admins 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: 'bug' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Found a bug? Maybe our [Slack Community](https://slack.cloudposse.com) can help. 11 | 12 | [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) 13 | 14 | ## Describe the Bug 15 | A clear and concise description of what the bug is. 16 | 17 | ## Expected Behavior 18 | A clear and concise description of what you expected to happen. 19 | 20 | ## Steps to Reproduce 21 | Steps to reproduce the behavior: 22 | 1. Go to '...' 23 | 2. Run '....' 24 | 3. Enter '....' 25 | 4. See error 26 | 27 | ## Screenshots 28 | If applicable, add screenshots or logs to help explain your problem. 29 | 30 | ## Environment (please complete the following information): 31 | 32 | Anything that will help us triage the bug will help. Here are some ideas: 33 | - OS: [e.g. Linux, OSX, WSL, etc] 34 | - Version [e.g. 10.15] 35 | 36 | ## Additional Context 37 | Add any other context about the problem here. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | description: Create a report to help us improve 4 | labels: ["bug"] 5 | assignees: [""] 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | Found a bug? 11 | 12 | Please checkout our [Slack Community](https://slack.cloudposse.com) 13 | or visit our [Slack Archive](https://archive.sweetops.com/). 14 | 15 | [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) 16 | 17 | - type: textarea 18 | id: concise-description 19 | attributes: 20 | label: Describe the Bug 21 | description: A clear and concise description of what the bug is. 22 | placeholder: What is the bug about? 23 | validations: 24 | required: true 25 | 26 | - type: textarea 27 | id: expected 28 | attributes: 29 | label: Expected Behavior 30 | description: A clear and concise description of what you expected. 31 | placeholder: What happened? 32 | validations: 33 | required: true 34 | 35 | - type: textarea 36 | id: reproduction-steps 37 | attributes: 38 | label: Steps to Reproduce 39 | description: Steps to reproduce the behavior. 40 | placeholder: How do we reproduce it? 41 | validations: 42 | required: true 43 | 44 | - type: textarea 45 | id: screenshots 46 | attributes: 47 | label: Screenshots 48 | description: If applicable, add screenshots or logs to help explain. 49 | validations: 50 | required: false 51 | 52 | - type: textarea 53 | id: environment 54 | attributes: 55 | label: Environment 56 | description: Anything that will help us triage the bug. 57 | placeholder: | 58 | - OS: [e.g. Linux, OSX, WSL, etc] 59 | - Version [e.g. 10.15] 60 | - Module version 61 | - Terraform version 62 | validations: 63 | required: false 64 | 65 | - type: textarea 66 | id: additional 67 | attributes: 68 | label: Additional Context 69 | description: | 70 | Add any other context about the problem here. 71 | validations: 72 | required: false 73 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | 3 | contact_links: 4 | 5 | - name: Community Slack Team 6 | url: https://cloudposse.com/slack/ 7 | about: |- 8 | Please ask and answer questions here. 9 | 10 | - name: Office Hours 11 | url: https://cloudposse.com/office-hours/ 12 | about: |- 13 | Join us every Wednesday for FREE Office Hours (lunch & learn). 14 | 15 | - name: DevOps Accelerator Program 16 | url: https://cloudposse.com/accelerate/ 17 | about: |- 18 | Own your infrastructure in record time. We build it. You drive it. 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: 'feature request' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Have a question? Please checkout our [Slack Community](https://slack.cloudposse.com) or visit our [Slack Archive](https://archive.sweetops.com/). 11 | 12 | [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) 13 | 14 | ## Describe the Feature 15 | 16 | A clear and concise description of what the bug is. 17 | 18 | ## Expected Behavior 19 | 20 | A clear and concise description of what you expected to happen. 21 | 22 | ## Use Case 23 | 24 | Is your feature request related to a problem/challenge you are trying to solve? Please provide some additional context of why this feature or capability will be valuable. 25 | 26 | ## Describe Ideal Solution 27 | 28 | A clear and concise description of what you want to happen. If you don't know, that's okay. 29 | 30 | ## Alternatives Considered 31 | 32 | Explain what alternative solutions or features you've considered. 33 | 34 | ## Additional Context 35 | 36 | Add any other context or screenshots about the feature request here. 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | description: Suggest an idea for this project 4 | labels: ["feature request"] 5 | assignees: [""] 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | Have a question? 11 | 12 | Please checkout our [Slack Community](https://slack.cloudposse.com) 13 | or visit our [Slack Archive](https://archive.sweetops.com/). 14 | 15 | [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) 16 | 17 | - type: textarea 18 | id: concise-description 19 | attributes: 20 | label: Describe the Feature 21 | description: A clear and concise description of what the feature is. 22 | placeholder: What is the feature about? 23 | validations: 24 | required: true 25 | 26 | - type: textarea 27 | id: expected 28 | attributes: 29 | label: Expected Behavior 30 | description: A clear and concise description of what you expected. 31 | placeholder: What happened? 32 | validations: 33 | required: true 34 | 35 | - type: textarea 36 | id: use-case 37 | attributes: 38 | label: Use Case 39 | description: | 40 | Is your feature request related to a problem/challenge you are trying 41 | to solve? 42 | 43 | Please provide some additional context of why this feature or 44 | capability will be valuable. 45 | validations: 46 | required: true 47 | 48 | - type: textarea 49 | id: ideal-solution 50 | attributes: 51 | label: Describe Ideal Solution 52 | description: A clear and concise description of what you want to happen. 53 | validations: 54 | required: true 55 | 56 | - type: textarea 57 | id: alternatives-considered 58 | attributes: 59 | label: Alternatives Considered 60 | description: Explain alternative solutions or features considered. 61 | validations: 62 | required: false 63 | 64 | - type: textarea 65 | id: additional 66 | attributes: 67 | label: Additional Context 68 | description: | 69 | Add any other context about the problem here. 70 | validations: 71 | required: false 72 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudposse/terraform-aws-elasticache-memcached/f4c62bef09e6da5b7a6695727096f1d18fdd4792/.github/ISSUE_TEMPLATE/question.md -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## what 2 | 3 | 7 | 8 | ## why 9 | 10 | 15 | 16 | ## references 17 | 18 | 22 | -------------------------------------------------------------------------------- /.github/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudposse/terraform-aws-elasticache-memcached/f4c62bef09e6da5b7a6695727096f1d18fdd4792/.github/banner.png -------------------------------------------------------------------------------- /.github/mergify.yml: -------------------------------------------------------------------------------- 1 | extends: .github 2 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", 4 | ":preserveSemverRanges", 5 | ":rebaseStalePrs" 6 | ], 7 | "baseBranches": ["main"], 8 | "labels": ["auto-update"], 9 | "dependencyDashboardAutoclose": true, 10 | "enabledManagers": ["terraform"], 11 | "terraform": { 12 | "ignorePaths": ["**/context.tf"] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.github/settings.yml: -------------------------------------------------------------------------------- 1 | # Upstream changes from _extends are only recognized when modifications are made to this file in the default branch. 2 | _extends: .github 3 | repository: 4 | name: terraform-aws-elasticache-memcached 5 | description: Terraform Module for ElastiCache Memcached Cluster 6 | homepage: https://cloudposse.com/accelerate 7 | topics: terraform, terraform-modules, memcached, elasticache, aws, hcl2 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.github/workflows/branch.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Branch 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | - release/** 8 | types: [opened, synchronize, reopened, labeled, unlabeled] 9 | push: 10 | branches: 11 | - main 12 | - release/v* 13 | paths-ignore: 14 | - '.github/**' 15 | - 'docs/**' 16 | - 'examples/**' 17 | - 'test/**' 18 | - 'README.md' 19 | 20 | permissions: {} 21 | 22 | jobs: 23 | terraform-module: 24 | uses: cloudposse/.github/.github/workflows/shared-terraform-module.yml@main 25 | secrets: inherit 26 | -------------------------------------------------------------------------------- /.github/workflows/chatops.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: chatops 3 | on: 4 | issue_comment: 5 | types: [created] 6 | 7 | permissions: 8 | pull-requests: write 9 | id-token: write 10 | contents: write 11 | statuses: write 12 | 13 | jobs: 14 | test: 15 | uses: cloudposse/.github/.github/workflows/shared-terraform-chatops.yml@main 16 | if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/terratest') }} 17 | secrets: inherit 18 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: release 3 | on: 4 | release: 5 | types: 6 | - published 7 | 8 | permissions: 9 | id-token: write 10 | contents: write 11 | pull-requests: write 12 | 13 | jobs: 14 | terraform-module: 15 | uses: cloudposse/.github/.github/workflows/shared-release-branches.yml@main 16 | secrets: inherit 17 | -------------------------------------------------------------------------------- /.github/workflows/scheduled.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: scheduled 3 | on: 4 | workflow_dispatch: { } # Allows manually trigger this workflow 5 | schedule: 6 | - cron: "0 3 * * *" 7 | 8 | permissions: 9 | pull-requests: write 10 | id-token: write 11 | contents: write 12 | 13 | jobs: 14 | scheduled: 15 | uses: cloudposse/.github/.github/workflows/shared-terraform-scheduled.yml@main 16 | secrets: inherit 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled files 2 | *.tfstate 3 | *.tfstate.backup 4 | 5 | # Module directory 6 | .terraform 7 | .idea 8 | *.iml 9 | 10 | .build-harness 11 | build-harness -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2017-2019 Cloud Posse, LLC 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Project Banner
5 |

6 | Latest ReleaseLast UpdatedSlack Community

7 | 8 | 9 | 29 | 30 | Terraform module to provision an [`ElastiCache`](https://aws.amazon.com/elasticache/) Memcached Cluster 31 | 32 | 33 | > [!TIP] 34 | > #### 👽 Use Atmos with Terraform 35 | > Cloud Posse uses [`atmos`](https://atmos.tools) to easily orchestrate multiple environments using Terraform.
36 | > Works with [Github Actions](https://atmos.tools/integrations/github-actions/), [Atlantis](https://atmos.tools/integrations/atlantis), or [Spacelift](https://atmos.tools/integrations/spacelift). 37 | > 38 | >
39 | > Watch demo of using Atmos with Terraform 40 | >
41 | > Example of running atmos to manage infrastructure from our Quick Start tutorial. 42 | > 43 | 44 | 45 | 46 | 47 | 48 | ## Usage 49 | 50 | For a complete example, see [examples/complete](examples/complete). 51 | 52 | For automated tests of the complete example using [bats](https://github.com/bats-core/bats-core) and [Terratest](https://github.com/gruntwork-io/terratest) (which tests and deploys the example on AWS), see [test](test). 53 | 54 | ```hcl 55 | provider "aws" { 56 | region = var.region 57 | } 58 | 59 | module "this" { 60 | source = "cloudposse/label/null" 61 | # Cloud Posse recommends pinning every module to a specific version 62 | # version = "x.x.x" 63 | namespace = var.namespace 64 | stage = var.stage 65 | name = var.name 66 | } 67 | 68 | module "vpc" { 69 | source = "cloudposse/vpc/aws" 70 | # Cloud Posse recommends pinning every module to a specific version 71 | # version = "x.x.x" 72 | 73 | cidr_block = "172.16.0.0/16" 74 | 75 | context = module.this.context 76 | } 77 | 78 | module "subnets" { 79 | source = "cloudposse/dynamic-subnets/aws" 80 | # Cloud Posse recommends pinning every module to a specific version 81 | # version = "x.x.x" 82 | 83 | availability_zones = var.availability_zones 84 | vpc_id = module.vpc.vpc_id 85 | igw_id = module.vpc.igw_id 86 | cidr_block = module.vpc.vpc_cidr_block 87 | nat_gateway_enabled = true 88 | nat_instance_enabled = false 89 | 90 | context = module.this.context 91 | } 92 | 93 | module "memcached" { 94 | source = "cloudposse/elasticache-memcached/aws" 95 | # Cloud Posse recommends pinning every module to a specific version 96 | # version = "x.x.x" 97 | 98 | availability_zones = var.availability_zones 99 | vpc_id = module.vpc.vpc_id 100 | allowed_security_groups = [module.vpc.vpc_default_security_group_id] 101 | subnets = module.subnets.private_subnet_ids 102 | cluster_size = var.cluster_size 103 | instance_type = var.instance_type 104 | engine_version = var.engine_version 105 | apply_immediately = true 106 | zone_id = var.zone_id 107 | 108 | elasticache_parameter_group_family = var.elasticache_parameter_group_family 109 | 110 | context = module.this.context 111 | } 112 | ``` 113 | 114 | > [!IMPORTANT] 115 | > In Cloud Posse's examples, we avoid pinning modules to specific versions to prevent discrepancies between the documentation 116 | > and the latest released versions. However, for your own projects, we strongly advise pinning each module to the exact version 117 | > you're using. This practice ensures the stability of your infrastructure. Additionally, we recommend implementing a systematic 118 | > approach for updating versions to avoid unexpected changes. 119 | 120 | 121 | 122 | 123 | 124 | ## Examples 125 | 126 | Review the [complete example](examples/complete) to see how to use this module. 127 | 128 | 129 | 130 | 131 | 132 | ## Requirements 133 | 134 | | Name | Version | 135 | |------|---------| 136 | | [terraform](#requirement\_terraform) | >= 1.0.0 | 137 | | [aws](#requirement\_aws) | >= 5.16 | 138 | | [null](#requirement\_null) | >= 3.0 | 139 | 140 | ## Providers 141 | 142 | | Name | Version | 143 | |------|---------| 144 | | [aws](#provider\_aws) | >= 5.16 | 145 | | [null](#provider\_null) | >= 3.0 | 146 | 147 | ## Modules 148 | 149 | | Name | Source | Version | 150 | |------|--------|---------| 151 | | [aws\_security\_group](#module\_aws\_security\_group) | cloudposse/security-group/aws | 2.2.0 | 152 | | [dns](#module\_dns) | cloudposse/route53-cluster-hostname/aws | 0.13.0 | 153 | | [this](#module\_this) | cloudposse/label/null | 0.25.0 | 154 | 155 | ## Resources 156 | 157 | | Name | Type | 158 | |------|------| 159 | | [aws_cloudwatch_metric_alarm.cache_cpu](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource | 160 | | [aws_cloudwatch_metric_alarm.cache_memory](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource | 161 | | [aws_elasticache_cluster.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource | 162 | | [aws_elasticache_parameter_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_parameter_group) | resource | 163 | | [aws_elasticache_subnet_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_subnet_group) | resource | 164 | | [null_resource.cluster_urls](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | 165 | 166 | ## Inputs 167 | 168 | | Name | Description | Type | Default | Required | 169 | |------|-------------|------|---------|:--------:| 170 | | [additional\_security\_group\_rules](#input\_additional\_security\_group\_rules) | A list of Security Group rule objects to add to the created security group, in addition to the ones
this module normally creates. (To suppress the module's rules, set `create_security_group` to false
and supply your own security group via `associated_security_group_ids`.)
The keys and values of the objects are fully compatible with the `aws_security_group_rule` resource, except
for `security_group_id` which will be ignored, and the optional "key" which, if provided, must be unique and known at "plan" time.
To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule . | `list(any)` | `[]` | no | 171 | | [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no | 172 | | [alarm\_actions](#input\_alarm\_actions) | Alarm actions | `list(string)` | `[]` | no | 173 | | [alarm\_cpu\_threshold\_percent](#input\_alarm\_cpu\_threshold\_percent) | CPU threshold alarm level | `number` | `75` | no | 174 | | [alarm\_memory\_threshold\_bytes](#input\_alarm\_memory\_threshold\_bytes) | Alarm memory threshold bytes | `number` | `10000000` | no | 175 | | [allow\_all\_egress](#input\_allow\_all\_egress) | If `true`, the created security group will allow egress on all ports and protocols to all IP address.
If this is false and no egress rules are otherwise specified, then no egress will be allowed. | `bool` | `true` | no | 176 | | [allowed\_cidr\_blocks](#input\_allowed\_cidr\_blocks) | A list of IPv4 CIDRs to allow access to the security group created by this module.
The length of this list must be known at "plan" time. | `list(string)` | `[]` | no | 177 | | [allowed\_ipv6\_cidr\_blocks](#input\_allowed\_ipv6\_cidr\_blocks) | A list of IPv6 CIDRs to allow access to the security group created by this module.
The length of this list must be known at "plan" time. | `list(string)` | `[]` | no | 178 | | [allowed\_ipv6\_prefix\_list\_ids](#input\_allowed\_ipv6\_prefix\_list\_ids) | A list of IPv6 Prefix Lists IDs to allow access to the security group created by this module.
The length of this list must be known at "plan" time. | `list(string)` | `[]` | no | 179 | | [allowed\_security\_group\_ids](#input\_allowed\_security\_group\_ids) | A list of IDs of Security Groups to allow access to the security group created by this module.
The length of this list must be known at "plan" time. | `list(string)` | `[]` | no | 180 | | [allowed\_security\_groups](#input\_allowed\_security\_groups) | DEPRECATED: Use `allowed_security_group_ids` instead. | `list(string)` | `[]` | no | 181 | | [apply\_immediately](#input\_apply\_immediately) | Specifies whether any database modifications are applied immediately, or during the next maintenance window | `bool` | `true` | no | 182 | | [associated\_security\_group\_ids](#input\_associated\_security\_group\_ids) | A list of IDs of Security Groups to associate the created resource with, in addition to the created security group.
These security groups will not be modified and, if `create_security_group` is `false`, must have rules providing the desired access. | `list(string)` | `[]` | no | 183 | | [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the `delimiter`
and treated as a single ID element. | `list(string)` | `[]` | no | 184 | | [availability\_zone](#input\_availability\_zone) | The Availability Zone of the cluster. az\_mode must be set to single-az when used. | `string` | `""` | no | 185 | | [availability\_zones](#input\_availability\_zones) | List of Availability Zones for the cluster. az\_mode must be set to cross-az when used. | `list(string)` | `[]` | no | 186 | | [az\_mode](#input\_az\_mode) | Enable or disable multiple AZs, eg: single-az or cross-az | `string` | `"single-az"` | no | 187 | | [cloudwatch\_metric\_alarms\_enabled](#input\_cloudwatch\_metric\_alarms\_enabled) | Boolean flag to enable/disable CloudWatch metrics alarms | `bool` | `false` | no | 188 | | [cluster\_size](#input\_cluster\_size) | Cluster size | `number` | `1` | no | 189 | | [context](#input\_context) | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` |
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
| no | 190 | | [create\_security\_group](#input\_create\_security\_group) | Set `true` to create and configure a new security group. If false, `associated_security_group_ids` must be provided. | `bool` | `true` | no | 191 | | [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | 192 | | [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
`labels` is a list of labels, in order, to pass to `format()` function.
Label values will be normalized before being passed to `format()` so they will be
identical to how they appear in `id`.
Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no | 193 | | [dns\_subdomain](#input\_dns\_subdomain) | The subdomain to use for the CNAME record. If not provided then the CNAME record will use var.name. | `string` | `""` | no | 194 | | [elasticache\_parameter\_group\_family](#input\_elasticache\_parameter\_group\_family) | ElastiCache parameter group family | `string` | `"memcached1.5"` | no | 195 | | [elasticache\_subnet\_group\_name](#input\_elasticache\_subnet\_group\_name) | Subnet group name for the ElastiCache instance | `string` | `""` | no | 196 | | [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | 197 | | [engine\_version](#input\_engine\_version) | Memcached engine version. For more info, see https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/supported-engine-versions.html | `string` | `"1.5.16"` | no | 198 | | [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | 199 | | [existing\_security\_groups](#input\_existing\_security\_groups) | DEPRECATED: Use `associated_security_group_ids` instead.
Historical description: List of existing Security Group IDs to place the cluster into.
Set `use_existing_security_groups` to `true` to enable using `existing_security_groups` as Security Groups for the cluster. | `list(string)` | `[]` | no | 200 | | [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for keep the existing setting, which defaults to `0`.
Does not affect `id_full`. | `number` | `null` | no | 201 | | [instance\_type](#input\_instance\_type) | Elastic cache instance type | `string` | `"cache.t2.micro"` | no | 202 | | [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no | 203 | | [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no | 204 | | [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.
Default value: `lower`. | `string` | `null` | no | 205 | | [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.
Default is to include all labels.
Tags with empty values will not be included in the `tags` output.
Set to `[]` to suppress all generated tags.
**Notes:**
The value of the `name` tag, if included, will be the `id`, not the `name`.
Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be
changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` |
[
"default"
]
| no | 206 | | [maintenance\_window](#input\_maintenance\_window) | Maintenance window | `string` | `"wed:03:00-wed:04:00"` | no | 207 | | [max\_item\_size](#input\_max\_item\_size) | Max item size | `number` | `10485760` | no | 208 | | [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a `tag`.
The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no | 209 | | [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no | 210 | | [network\_type](#input\_network\_type) | The network type of the cluster. Valid values: ipv4, ipv6, dual\_stack. | `string` | `"ipv4"` | no | 211 | | [notification\_topic\_arn](#input\_notification\_topic\_arn) | Notification topic arn | `string` | `""` | no | 212 | | [port](#input\_port) | Memcached port | `number` | `11211` | no | 213 | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | 214 | | [security\_group\_create\_before\_destroy](#input\_security\_group\_create\_before\_destroy) | Set `true` to enable Terraform `create_before_destroy` behavior on the created security group.
We only recommend setting this `false` if you are upgrading this module and need to keep
the existing security group from being replaced.
Note that changing this value will always cause the security group to be replaced. | `bool` | `true` | no | 215 | | [security\_group\_create\_timeout](#input\_security\_group\_create\_timeout) | How long to wait for the security group to be created. | `string` | `"10m"` | no | 216 | | [security\_group\_delete\_timeout](#input\_security\_group\_delete\_timeout) | How long to retry on `DependencyViolation` errors during security group deletion. | `string` | `"15m"` | no | 217 | | [security\_group\_description](#input\_security\_group\_description) | The description to assign to the created Security Group.
Warning: Changing the description causes the security group to be replaced. | `string` | `"Security group for Elasticache Memcached"` | no | 218 | | [security\_group\_name](#input\_security\_group\_name) | The name to assign to the created security group. Must be unique within the VPC.
If not provided, will be derived from the `null-label.context` passed in.
If `create_before_destroy` is true, will be used as a name prefix. | `list(string)` | `[]` | no | 219 | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | 220 | | [subnets](#input\_subnets) | AWS subnet ids | `list(string)` | `[]` | no | 221 | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | 222 | | [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no | 223 | | [transit\_encryption\_enabled](#input\_transit\_encryption\_enabled) | Boolean flag to enable transit encryption (requires Memcached version 1.6.12+) | `bool` | `false` | no | 224 | | [use\_existing\_security\_groups](#input\_use\_existing\_security\_groups) | DEPRECATED: Use `create_security_group` instead.
Historical description: Flag to enable/disable creation of Security Group in the module.
Set to `true` to disable Security Group creation and provide a list of existing security Group IDs in `existing_security_groups` to place the cluster into.
Historical default: `false` | `bool` | `null` | no | 225 | | [vpc\_id](#input\_vpc\_id) | VPC ID | `string` | `""` | no | 226 | | [zone\_id](#input\_zone\_id) | Route53 DNS Zone ID | `string` | `""` | no | 227 | 228 | ## Outputs 229 | 230 | | Name | Description | 231 | |------|-------------| 232 | | [cluster\_address](#output\_cluster\_address) | Cluster address | 233 | | [cluster\_configuration\_endpoint](#output\_cluster\_configuration\_endpoint) | Cluster configuration endpoint | 234 | | [cluster\_id](#output\_cluster\_id) | Cluster ID | 235 | | [cluster\_urls](#output\_cluster\_urls) | Cluster URLs | 236 | | [hostname](#output\_hostname) | Cluster hostname | 237 | | [security\_group\_arn](#output\_security\_group\_arn) | The ARN of the created security group | 238 | | [security\_group\_id](#output\_security\_group\_id) | The ID of the created security group | 239 | | [security\_group\_name](#output\_security\_group\_name) | The name of the created security group | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | ## Related Projects 249 | 250 | Check out these related projects. 251 | 252 | - [terraform-aws-elasticache-redis](https://github.com/cloudposse/terraform-aws-elasticache-redis) - Terraform module to provision an ElastiCache Redis Cluster 253 | - [terraform-aws-elasticache-cloudwatch-sns-alarms](https://github.com/cloudposse/terraform-aws-elasticache-cloudwatch-sns-alarms) - Terraform module that configures CloudWatch SNS alerts for ElastiCache 254 | 255 | 256 | > [!TIP] 257 | > #### Use Terraform Reference Architectures for AWS 258 | > 259 | > Use Cloud Posse's ready-to-go [terraform architecture blueprints](https://cloudposse.com/reference-architecture/) for AWS to get up and running quickly. 260 | > 261 | > ✅ We build it together with your team.
262 | > ✅ Your team owns everything.
263 | > ✅ 100% Open Source and backed by fanatical support.
264 | > 265 | > Request Quote 266 | >
📚 Learn More 267 | > 268 | >
269 | > 270 | > Cloud Posse is the leading [**DevOps Accelerator**](https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-elasticache-memcached&utm_content=commercial_support) for funded startups and enterprises. 271 | > 272 | > *Your team can operate like a pro today.* 273 | > 274 | > Ensure that your team succeeds by using Cloud Posse's proven process and turnkey blueprints. Plus, we stick around until you succeed. 275 | > #### Day-0: Your Foundation for Success 276 | > - **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code. 277 | > - **Deployment Strategy.** Adopt a proven deployment strategy with GitHub Actions, enabling automated, repeatable, and reliable software releases. 278 | > - **Site Reliability Engineering.** Gain total visibility into your applications and services with Datadog, ensuring high availability and performance. 279 | > - **Security Baseline.** Establish a secure environment from the start, with built-in governance, accountability, and comprehensive audit logs, safeguarding your operations. 280 | > - **GitOps.** Empower your team to manage infrastructure changes confidently and efficiently through Pull Requests, leveraging the full power of GitHub Actions. 281 | > 282 | > Request Quote 283 | > 284 | > #### Day-2: Your Operational Mastery 285 | > - **Training.** Equip your team with the knowledge and skills to confidently manage the infrastructure, ensuring long-term success and self-sufficiency. 286 | > - **Support.** Benefit from a seamless communication over Slack with our experts, ensuring you have the support you need, whenever you need it. 287 | > - **Troubleshooting.** Access expert assistance to quickly resolve any operational challenges, minimizing downtime and maintaining business continuity. 288 | > - **Code Reviews.** Enhance your team’s code quality with our expert feedback, fostering continuous improvement and collaboration. 289 | > - **Bug Fixes.** Rely on our team to troubleshoot and resolve any issues, ensuring your systems run smoothly. 290 | > - **Migration Assistance.** Accelerate your migration process with our dedicated support, minimizing disruption and speeding up time-to-value. 291 | > - **Customer Workshops.** Engage with our team in weekly workshops, gaining insights and strategies to continuously improve and innovate. 292 | > 293 | > Request Quote 294 | >
295 | 296 | ## ✨ Contributing 297 | 298 | This project is under active development, and we encourage contributions from our community. 299 | 300 | 301 | 302 | Many thanks to our outstanding contributors: 303 | 304 | 305 | 306 | 307 | 308 | For 🐛 bug reports & feature requests, please use the [issue tracker](https://github.com/cloudposse/terraform-aws-elasticache-memcached/issues). 309 | 310 | In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. 311 | 1. Review our [Code of Conduct](https://github.com/cloudposse/terraform-aws-elasticache-memcached/?tab=coc-ov-file#code-of-conduct) and [Contributor Guidelines](https://github.com/cloudposse/.github/blob/main/CONTRIBUTING.md). 312 | 2. **Fork** the repo on GitHub 313 | 3. **Clone** the project to your own machine 314 | 4. **Commit** changes to your own branch 315 | 5. **Push** your work back up to your fork 316 | 6. Submit a **Pull Request** so that we can review your changes 317 | 318 | **NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request! 319 | 320 | ### 🌎 Slack Community 321 | 322 | Join our [Open Source Community](https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-elasticache-memcached&utm_content=slack) on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure. 323 | 324 | ### 📰 Newsletter 325 | 326 | Sign up for [our newsletter](https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-elasticache-memcached&utm_content=newsletter) and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. 327 | Dropped straight into your Inbox every week — and usually a 5-minute read. 328 | 329 | ### 📆 Office Hours 330 | 331 | [Join us every Wednesday via Zoom](https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-elasticache-memcached&utm_content=office_hours) for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a _live Q&A_ that you can’t find anywhere else. 332 | It's **FREE** for everyone! 333 | ## License 334 | 335 | License 336 | 337 |
338 | Preamble to the Apache License, Version 2.0 339 |
340 |
341 | 342 | Complete license is available in the [`LICENSE`](LICENSE) file. 343 | 344 | ```text 345 | Licensed to the Apache Software Foundation (ASF) under one 346 | or more contributor license agreements. See the NOTICE file 347 | distributed with this work for additional information 348 | regarding copyright ownership. The ASF licenses this file 349 | to you under the Apache License, Version 2.0 (the 350 | "License"); you may not use this file except in compliance 351 | with the License. You may obtain a copy of the License at 352 | 353 | https://www.apache.org/licenses/LICENSE-2.0 354 | 355 | Unless required by applicable law or agreed to in writing, 356 | software distributed under the License is distributed on an 357 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 358 | KIND, either express or implied. See the License for the 359 | specific language governing permissions and limitations 360 | under the License. 361 | ``` 362 |
363 | 364 | ## Trademarks 365 | 366 | All other trademarks referenced herein are the property of their respective owners. 367 | 368 | 369 | --- 370 | Copyright © 2017-2025 [Cloud Posse, LLC](https://cpco.io/copyright) 371 | 372 | 373 | README footer 374 | 375 | Beacon 376 | -------------------------------------------------------------------------------- /README.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # This is the canonical configuration for the `README.md` 3 | # Run `make readme` to rebuild the `README.md` 4 | # 5 | 6 | # Name of this project 7 | name: terraform-aws-elasticache-memcached 8 | # Tags of this project 9 | tags: 10 | - aws 11 | - terraform 12 | - terraform-modules 13 | - databases 14 | - memcached 15 | - elasticache 16 | # Categories of this project 17 | categories: 18 | - terraform-modules/databases 19 | # Logo for this project 20 | #logo: docs/logo.png 21 | 22 | # License of this project 23 | license: "APACHE2" 24 | # Canonical GitHub repo 25 | github_repo: cloudposse/terraform-aws-elasticache-memcached 26 | # Badges to display 27 | badges: 28 | - name: Latest Release 29 | image: https://img.shields.io/github/release/cloudposse/terraform-aws-elasticache-memcached.svg?style=for-the-badge 30 | url: https://github.com/cloudposse/terraform-aws-elasticache-memcached/releases/latest 31 | - name: Last Updated 32 | image: https://img.shields.io/github/last-commit/cloudposse/terraform-aws-elasticache-memcached.svg?style=for-the-badge 33 | url: https://github.com/cloudposse/terraform-aws-elasticache-memcached/commits 34 | - name: Slack Community 35 | image: https://slack.cloudposse.com/for-the-badge.svg 36 | url: https://cloudposse.com/slack 37 | 38 | # List any related terraform modules that this module may be used with or that this module depends on. 39 | related: 40 | - name: "terraform-aws-elasticache-redis" 41 | description: "Terraform module to provision an ElastiCache Redis Cluster" 42 | url: "https://github.com/cloudposse/terraform-aws-elasticache-redis" 43 | - name: "terraform-aws-elasticache-cloudwatch-sns-alarms" 44 | description: "Terraform module that configures CloudWatch SNS alerts for ElastiCache" 45 | url: "https://github.com/cloudposse/terraform-aws-elasticache-cloudwatch-sns-alarms" 46 | # Short description of this project 47 | description: |- 48 | Terraform module to provision an [`ElastiCache`](https://aws.amazon.com/elasticache/) Memcached Cluster 49 | # How to use this project 50 | usage: |2- 51 | 52 | For a complete example, see [examples/complete](examples/complete). 53 | 54 | For automated tests of the complete example using [bats](https://github.com/bats-core/bats-core) and [Terratest](https://github.com/gruntwork-io/terratest) (which tests and deploys the example on AWS), see [test](test). 55 | 56 | ```hcl 57 | provider "aws" { 58 | region = var.region 59 | } 60 | 61 | module "this" { 62 | source = "cloudposse/label/null" 63 | # Cloud Posse recommends pinning every module to a specific version 64 | # version = "x.x.x" 65 | namespace = var.namespace 66 | stage = var.stage 67 | name = var.name 68 | } 69 | 70 | module "vpc" { 71 | source = "cloudposse/vpc/aws" 72 | # Cloud Posse recommends pinning every module to a specific version 73 | # version = "x.x.x" 74 | 75 | cidr_block = "172.16.0.0/16" 76 | 77 | context = module.this.context 78 | } 79 | 80 | module "subnets" { 81 | source = "cloudposse/dynamic-subnets/aws" 82 | # Cloud Posse recommends pinning every module to a specific version 83 | # version = "x.x.x" 84 | 85 | availability_zones = var.availability_zones 86 | vpc_id = module.vpc.vpc_id 87 | igw_id = module.vpc.igw_id 88 | cidr_block = module.vpc.vpc_cidr_block 89 | nat_gateway_enabled = true 90 | nat_instance_enabled = false 91 | 92 | context = module.this.context 93 | } 94 | 95 | module "memcached" { 96 | source = "cloudposse/elasticache-memcached/aws" 97 | # Cloud Posse recommends pinning every module to a specific version 98 | # version = "x.x.x" 99 | 100 | availability_zones = var.availability_zones 101 | vpc_id = module.vpc.vpc_id 102 | allowed_security_groups = [module.vpc.vpc_default_security_group_id] 103 | subnets = module.subnets.private_subnet_ids 104 | cluster_size = var.cluster_size 105 | instance_type = var.instance_type 106 | engine_version = var.engine_version 107 | apply_immediately = true 108 | zone_id = var.zone_id 109 | 110 | elasticache_parameter_group_family = var.elasticache_parameter_group_family 111 | 112 | context = module.this.context 113 | } 114 | ``` 115 | examples: |- 116 | Review the [complete example](examples/complete) to see how to use this module. 117 | include: [] 118 | contributors: [] 119 | -------------------------------------------------------------------------------- /atmos.yaml: -------------------------------------------------------------------------------- 1 | # Atmos Configuration — powered by https://atmos.tools 2 | # 3 | # This configuration enables centralized, DRY, and consistent project scaffolding using Atmos. 4 | # 5 | # Included features: 6 | # - Organizational custom commands: https://atmos.tools/core-concepts/custom-commands 7 | # - Automated README generation: https://atmos.tools/cli/commands/docs/generate 8 | # 9 | 10 | # Import shared configuration used by all modules 11 | import: 12 | - https://raw.githubusercontent.com/cloudposse/.github/refs/heads/main/.github/atmos/terraform-module.yaml 13 | -------------------------------------------------------------------------------- /context.tf: -------------------------------------------------------------------------------- 1 | # 2 | # ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label 3 | # All other instances of this file should be a copy of that one 4 | # 5 | # 6 | # Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf 7 | # and then place it in your Terraform module to automatically get 8 | # Cloud Posse's standard configuration inputs suitable for passing 9 | # to Cloud Posse modules. 10 | # 11 | # curl -sL https://raw.githubusercontent.com/cloudposse/terraform-null-label/master/exports/context.tf -o context.tf 12 | # 13 | # Modules should access the whole context as `module.this.context` 14 | # to get the input variables with nulls for defaults, 15 | # for example `context = module.this.context`, 16 | # and access individual variables as `module.this.`, 17 | # with final values filled in. 18 | # 19 | # For example, when using defaults, `module.this.context.delimiter` 20 | # will be null, and `module.this.delimiter` will be `-` (hyphen). 21 | # 22 | 23 | module "this" { 24 | source = "cloudposse/label/null" 25 | version = "0.25.0" # requires Terraform >= 0.13.0 26 | 27 | enabled = var.enabled 28 | namespace = var.namespace 29 | tenant = var.tenant 30 | environment = var.environment 31 | stage = var.stage 32 | name = var.name 33 | delimiter = var.delimiter 34 | attributes = var.attributes 35 | tags = var.tags 36 | additional_tag_map = var.additional_tag_map 37 | label_order = var.label_order 38 | regex_replace_chars = var.regex_replace_chars 39 | id_length_limit = var.id_length_limit 40 | label_key_case = var.label_key_case 41 | label_value_case = var.label_value_case 42 | descriptor_formats = var.descriptor_formats 43 | labels_as_tags = var.labels_as_tags 44 | 45 | context = var.context 46 | } 47 | 48 | # Copy contents of cloudposse/terraform-null-label/variables.tf here 49 | 50 | variable "context" { 51 | type = any 52 | default = { 53 | enabled = true 54 | namespace = null 55 | tenant = null 56 | environment = null 57 | stage = null 58 | name = null 59 | delimiter = null 60 | attributes = [] 61 | tags = {} 62 | additional_tag_map = {} 63 | regex_replace_chars = null 64 | label_order = [] 65 | id_length_limit = null 66 | label_key_case = null 67 | label_value_case = null 68 | descriptor_formats = {} 69 | # Note: we have to use [] instead of null for unset lists due to 70 | # https://github.com/hashicorp/terraform/issues/28137 71 | # which was not fixed until Terraform 1.0.0, 72 | # but we want the default to be all the labels in `label_order` 73 | # and we want users to be able to prevent all tag generation 74 | # by setting `labels_as_tags` to `[]`, so we need 75 | # a different sentinel to indicate "default" 76 | labels_as_tags = ["unset"] 77 | } 78 | description = <<-EOT 79 | Single object for setting entire context at once. 80 | See description of individual variables for details. 81 | Leave string and numeric variables as `null` to use default value. 82 | Individual variable settings (non-null) override settings in context object, 83 | except for attributes, tags, and additional_tag_map, which are merged. 84 | EOT 85 | 86 | validation { 87 | condition = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"]) 88 | error_message = "Allowed values: `lower`, `title`, `upper`." 89 | } 90 | 91 | validation { 92 | condition = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"]) 93 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`." 94 | } 95 | } 96 | 97 | variable "enabled" { 98 | type = bool 99 | default = null 100 | description = "Set to false to prevent the module from creating any resources" 101 | } 102 | 103 | variable "namespace" { 104 | type = string 105 | default = null 106 | description = "ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique" 107 | } 108 | 109 | variable "tenant" { 110 | type = string 111 | default = null 112 | description = "ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for" 113 | } 114 | 115 | variable "environment" { 116 | type = string 117 | default = null 118 | description = "ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'" 119 | } 120 | 121 | variable "stage" { 122 | type = string 123 | default = null 124 | description = "ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'" 125 | } 126 | 127 | variable "name" { 128 | type = string 129 | default = null 130 | description = <<-EOT 131 | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'. 132 | This is the only ID element not also included as a `tag`. 133 | The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. 134 | EOT 135 | } 136 | 137 | variable "delimiter" { 138 | type = string 139 | default = null 140 | description = <<-EOT 141 | Delimiter to be used between ID elements. 142 | Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. 143 | EOT 144 | } 145 | 146 | variable "attributes" { 147 | type = list(string) 148 | default = [] 149 | description = <<-EOT 150 | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`, 151 | in the order they appear in the list. New attributes are appended to the 152 | end of the list. The elements of the list are joined by the `delimiter` 153 | and treated as a single ID element. 154 | EOT 155 | } 156 | 157 | variable "labels_as_tags" { 158 | type = set(string) 159 | default = ["default"] 160 | description = <<-EOT 161 | Set of labels (ID elements) to include as tags in the `tags` output. 162 | Default is to include all labels. 163 | Tags with empty values will not be included in the `tags` output. 164 | Set to `[]` to suppress all generated tags. 165 | **Notes:** 166 | The value of the `name` tag, if included, will be the `id`, not the `name`. 167 | Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be 168 | changed in later chained modules. Attempts to change it will be silently ignored. 169 | EOT 170 | } 171 | 172 | variable "tags" { 173 | type = map(string) 174 | default = {} 175 | description = <<-EOT 176 | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`). 177 | Neither the tag keys nor the tag values will be modified by this module. 178 | EOT 179 | } 180 | 181 | variable "additional_tag_map" { 182 | type = map(string) 183 | default = {} 184 | description = <<-EOT 185 | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`. 186 | This is for some rare cases where resources want additional configuration of tags 187 | and therefore take a list of maps with tag key, value, and additional configuration. 188 | EOT 189 | } 190 | 191 | variable "label_order" { 192 | type = list(string) 193 | default = null 194 | description = <<-EOT 195 | The order in which the labels (ID elements) appear in the `id`. 196 | Defaults to ["namespace", "environment", "stage", "name", "attributes"]. 197 | You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. 198 | EOT 199 | } 200 | 201 | variable "regex_replace_chars" { 202 | type = string 203 | default = null 204 | description = <<-EOT 205 | Terraform regular expression (regex) string. 206 | Characters matching the regex will be removed from the ID elements. 207 | If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. 208 | EOT 209 | } 210 | 211 | variable "id_length_limit" { 212 | type = number 213 | default = null 214 | description = <<-EOT 215 | Limit `id` to this many characters (minimum 6). 216 | Set to `0` for unlimited length. 217 | Set to `null` for keep the existing setting, which defaults to `0`. 218 | Does not affect `id_full`. 219 | EOT 220 | validation { 221 | condition = var.id_length_limit == null ? true : var.id_length_limit >= 6 || var.id_length_limit == 0 222 | error_message = "The id_length_limit must be >= 6 if supplied (not null), or 0 for unlimited length." 223 | } 224 | } 225 | 226 | variable "label_key_case" { 227 | type = string 228 | default = null 229 | description = <<-EOT 230 | Controls the letter case of the `tags` keys (label names) for tags generated by this module. 231 | Does not affect keys of tags passed in via the `tags` input. 232 | Possible values: `lower`, `title`, `upper`. 233 | Default value: `title`. 234 | EOT 235 | 236 | validation { 237 | condition = var.label_key_case == null ? true : contains(["lower", "title", "upper"], var.label_key_case) 238 | error_message = "Allowed values: `lower`, `title`, `upper`." 239 | } 240 | } 241 | 242 | variable "label_value_case" { 243 | type = string 244 | default = null 245 | description = <<-EOT 246 | Controls the letter case of ID elements (labels) as included in `id`, 247 | set as tag values, and output by this module individually. 248 | Does not affect values of tags passed in via the `tags` input. 249 | Possible values: `lower`, `title`, `upper` and `none` (no transformation). 250 | Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs. 251 | Default value: `lower`. 252 | EOT 253 | 254 | validation { 255 | condition = var.label_value_case == null ? true : contains(["lower", "title", "upper", "none"], var.label_value_case) 256 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`." 257 | } 258 | } 259 | 260 | variable "descriptor_formats" { 261 | type = any 262 | default = {} 263 | description = <<-EOT 264 | Describe additional descriptors to be output in the `descriptors` output map. 265 | Map of maps. Keys are names of descriptors. Values are maps of the form 266 | `{ 267 | format = string 268 | labels = list(string) 269 | }` 270 | (Type is `any` so the map values can later be enhanced to provide additional options.) 271 | `format` is a Terraform format string to be passed to the `format()` function. 272 | `labels` is a list of labels, in order, to pass to `format()` function. 273 | Label values will be normalized before being passed to `format()` so they will be 274 | identical to how they appear in `id`. 275 | Default is `{}` (`descriptors` output will be empty). 276 | EOT 277 | } 278 | 279 | #### End of copy of cloudposse/terraform-null-label/variables.tf 280 | -------------------------------------------------------------------------------- /examples/complete/context.tf: -------------------------------------------------------------------------------- 1 | # 2 | # ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label 3 | # All other instances of this file should be a copy of that one 4 | # 5 | # 6 | # Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf 7 | # and then place it in your Terraform module to automatically get 8 | # Cloud Posse's standard configuration inputs suitable for passing 9 | # to Cloud Posse modules. 10 | # 11 | # curl -sL https://raw.githubusercontent.com/cloudposse/terraform-null-label/master/exports/context.tf -o context.tf 12 | # 13 | # Modules should access the whole context as `module.this.context` 14 | # to get the input variables with nulls for defaults, 15 | # for example `context = module.this.context`, 16 | # and access individual variables as `module.this.`, 17 | # with final values filled in. 18 | # 19 | # For example, when using defaults, `module.this.context.delimiter` 20 | # will be null, and `module.this.delimiter` will be `-` (hyphen). 21 | # 22 | 23 | module "this" { 24 | source = "cloudposse/label/null" 25 | version = "0.25.0" # requires Terraform >= 0.13.0 26 | 27 | enabled = var.enabled 28 | namespace = var.namespace 29 | tenant = var.tenant 30 | environment = var.environment 31 | stage = var.stage 32 | name = var.name 33 | delimiter = var.delimiter 34 | attributes = var.attributes 35 | tags = var.tags 36 | additional_tag_map = var.additional_tag_map 37 | label_order = var.label_order 38 | regex_replace_chars = var.regex_replace_chars 39 | id_length_limit = var.id_length_limit 40 | label_key_case = var.label_key_case 41 | label_value_case = var.label_value_case 42 | descriptor_formats = var.descriptor_formats 43 | labels_as_tags = var.labels_as_tags 44 | 45 | context = var.context 46 | } 47 | 48 | # Copy contents of cloudposse/terraform-null-label/variables.tf here 49 | 50 | variable "context" { 51 | type = any 52 | default = { 53 | enabled = true 54 | namespace = null 55 | tenant = null 56 | environment = null 57 | stage = null 58 | name = null 59 | delimiter = null 60 | attributes = [] 61 | tags = {} 62 | additional_tag_map = {} 63 | regex_replace_chars = null 64 | label_order = [] 65 | id_length_limit = null 66 | label_key_case = null 67 | label_value_case = null 68 | descriptor_formats = {} 69 | # Note: we have to use [] instead of null for unset lists due to 70 | # https://github.com/hashicorp/terraform/issues/28137 71 | # which was not fixed until Terraform 1.0.0, 72 | # but we want the default to be all the labels in `label_order` 73 | # and we want users to be able to prevent all tag generation 74 | # by setting `labels_as_tags` to `[]`, so we need 75 | # a different sentinel to indicate "default" 76 | labels_as_tags = ["unset"] 77 | } 78 | description = <<-EOT 79 | Single object for setting entire context at once. 80 | See description of individual variables for details. 81 | Leave string and numeric variables as `null` to use default value. 82 | Individual variable settings (non-null) override settings in context object, 83 | except for attributes, tags, and additional_tag_map, which are merged. 84 | EOT 85 | 86 | validation { 87 | condition = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"]) 88 | error_message = "Allowed values: `lower`, `title`, `upper`." 89 | } 90 | 91 | validation { 92 | condition = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"]) 93 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`." 94 | } 95 | } 96 | 97 | variable "enabled" { 98 | type = bool 99 | default = null 100 | description = "Set to false to prevent the module from creating any resources" 101 | } 102 | 103 | variable "namespace" { 104 | type = string 105 | default = null 106 | description = "ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique" 107 | } 108 | 109 | variable "tenant" { 110 | type = string 111 | default = null 112 | description = "ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for" 113 | } 114 | 115 | variable "environment" { 116 | type = string 117 | default = null 118 | description = "ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'" 119 | } 120 | 121 | variable "stage" { 122 | type = string 123 | default = null 124 | description = "ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'" 125 | } 126 | 127 | variable "name" { 128 | type = string 129 | default = null 130 | description = <<-EOT 131 | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'. 132 | This is the only ID element not also included as a `tag`. 133 | The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. 134 | EOT 135 | } 136 | 137 | variable "delimiter" { 138 | type = string 139 | default = null 140 | description = <<-EOT 141 | Delimiter to be used between ID elements. 142 | Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. 143 | EOT 144 | } 145 | 146 | variable "attributes" { 147 | type = list(string) 148 | default = [] 149 | description = <<-EOT 150 | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`, 151 | in the order they appear in the list. New attributes are appended to the 152 | end of the list. The elements of the list are joined by the `delimiter` 153 | and treated as a single ID element. 154 | EOT 155 | } 156 | 157 | variable "labels_as_tags" { 158 | type = set(string) 159 | default = ["default"] 160 | description = <<-EOT 161 | Set of labels (ID elements) to include as tags in the `tags` output. 162 | Default is to include all labels. 163 | Tags with empty values will not be included in the `tags` output. 164 | Set to `[]` to suppress all generated tags. 165 | **Notes:** 166 | The value of the `name` tag, if included, will be the `id`, not the `name`. 167 | Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be 168 | changed in later chained modules. Attempts to change it will be silently ignored. 169 | EOT 170 | } 171 | 172 | variable "tags" { 173 | type = map(string) 174 | default = {} 175 | description = <<-EOT 176 | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`). 177 | Neither the tag keys nor the tag values will be modified by this module. 178 | EOT 179 | } 180 | 181 | variable "additional_tag_map" { 182 | type = map(string) 183 | default = {} 184 | description = <<-EOT 185 | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`. 186 | This is for some rare cases where resources want additional configuration of tags 187 | and therefore take a list of maps with tag key, value, and additional configuration. 188 | EOT 189 | } 190 | 191 | variable "label_order" { 192 | type = list(string) 193 | default = null 194 | description = <<-EOT 195 | The order in which the labels (ID elements) appear in the `id`. 196 | Defaults to ["namespace", "environment", "stage", "name", "attributes"]. 197 | You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. 198 | EOT 199 | } 200 | 201 | variable "regex_replace_chars" { 202 | type = string 203 | default = null 204 | description = <<-EOT 205 | Terraform regular expression (regex) string. 206 | Characters matching the regex will be removed from the ID elements. 207 | If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. 208 | EOT 209 | } 210 | 211 | variable "id_length_limit" { 212 | type = number 213 | default = null 214 | description = <<-EOT 215 | Limit `id` to this many characters (minimum 6). 216 | Set to `0` for unlimited length. 217 | Set to `null` for keep the existing setting, which defaults to `0`. 218 | Does not affect `id_full`. 219 | EOT 220 | validation { 221 | condition = var.id_length_limit == null ? true : var.id_length_limit >= 6 || var.id_length_limit == 0 222 | error_message = "The id_length_limit must be >= 6 if supplied (not null), or 0 for unlimited length." 223 | } 224 | } 225 | 226 | variable "label_key_case" { 227 | type = string 228 | default = null 229 | description = <<-EOT 230 | Controls the letter case of the `tags` keys (label names) for tags generated by this module. 231 | Does not affect keys of tags passed in via the `tags` input. 232 | Possible values: `lower`, `title`, `upper`. 233 | Default value: `title`. 234 | EOT 235 | 236 | validation { 237 | condition = var.label_key_case == null ? true : contains(["lower", "title", "upper"], var.label_key_case) 238 | error_message = "Allowed values: `lower`, `title`, `upper`." 239 | } 240 | } 241 | 242 | variable "label_value_case" { 243 | type = string 244 | default = null 245 | description = <<-EOT 246 | Controls the letter case of ID elements (labels) as included in `id`, 247 | set as tag values, and output by this module individually. 248 | Does not affect values of tags passed in via the `tags` input. 249 | Possible values: `lower`, `title`, `upper` and `none` (no transformation). 250 | Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs. 251 | Default value: `lower`. 252 | EOT 253 | 254 | validation { 255 | condition = var.label_value_case == null ? true : contains(["lower", "title", "upper", "none"], var.label_value_case) 256 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`." 257 | } 258 | } 259 | 260 | variable "descriptor_formats" { 261 | type = any 262 | default = {} 263 | description = <<-EOT 264 | Describe additional descriptors to be output in the `descriptors` output map. 265 | Map of maps. Keys are names of descriptors. Values are maps of the form 266 | `{ 267 | format = string 268 | labels = list(string) 269 | }` 270 | (Type is `any` so the map values can later be enhanced to provide additional options.) 271 | `format` is a Terraform format string to be passed to the `format()` function. 272 | `labels` is a list of labels, in order, to pass to `format()` function. 273 | Label values will be normalized before being passed to `format()` so they will be 274 | identical to how they appear in `id`. 275 | Default is `{}` (`descriptors` output will be empty). 276 | EOT 277 | } 278 | 279 | #### End of copy of cloudposse/terraform-null-label/variables.tf 280 | -------------------------------------------------------------------------------- /examples/complete/fixtures.us-east-2.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-2" 2 | 3 | availability_zone = "us-east-2a" 4 | 5 | availability_zones = ["us-east-2a"] 6 | 7 | namespace = "eg" 8 | 9 | stage = "test" 10 | 11 | name = "memcached-test" 12 | 13 | instance_type = "cache.t2.micro" 14 | 15 | cluster_size = 1 16 | 17 | # https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/supported-engine-versions.html 18 | engine_version = "1.5.16" 19 | 20 | elasticache_parameter_group_family = "memcached1.5" 21 | -------------------------------------------------------------------------------- /examples/complete/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | module "vpc" { 6 | source = "cloudposse/vpc/aws" 7 | version = "2.2.0" 8 | 9 | ipv4_primary_cidr_block = "172.16.0.0/16" 10 | 11 | context = module.this.context 12 | } 13 | 14 | module "subnets" { 15 | source = "cloudposse/dynamic-subnets/aws" 16 | version = "2.4.1" 17 | 18 | availability_zones = var.availability_zones 19 | vpc_id = module.vpc.vpc_id 20 | igw_id = [module.vpc.igw_id] 21 | ipv4_cidr_block = [module.vpc.vpc_cidr_block] 22 | nat_gateway_enabled = false 23 | nat_instance_enabled = false 24 | 25 | context = module.this.context 26 | } 27 | 28 | module "memcached" { 29 | source = "../../" 30 | az_mode = var.az_mode 31 | availability_zone = var.availability_zone 32 | vpc_id = module.vpc.vpc_id 33 | allowed_security_groups = [module.vpc.vpc_default_security_group_id] 34 | subnets = module.subnets.private_subnet_ids 35 | cluster_size = var.cluster_size 36 | instance_type = var.instance_type 37 | engine_version = var.engine_version 38 | apply_immediately = true 39 | zone_id = var.zone_id 40 | 41 | elasticache_parameter_group_family = var.elasticache_parameter_group_family 42 | 43 | context = module.this.context 44 | } 45 | -------------------------------------------------------------------------------- /examples/complete/outputs.tf: -------------------------------------------------------------------------------- 1 | output "public_subnet_cidrs" { 2 | value = module.subnets.public_subnet_cidrs 3 | description = "Public subnet CIDRs" 4 | } 5 | 6 | output "private_subnet_cidrs" { 7 | value = module.subnets.private_subnet_cidrs 8 | description = "Private subnet CIDRs" 9 | } 10 | 11 | output "vpc_cidr" { 12 | value = module.vpc.vpc_cidr_block 13 | description = "VPC CIDR" 14 | } 15 | 16 | output "cluster_id" { 17 | value = module.memcached.cluster_id 18 | description = "Cluster ID" 19 | } 20 | 21 | output "security_group_id" { 22 | value = module.memcached.security_group_id 23 | description = "Security Group ID" 24 | } 25 | 26 | output "cluster_address" { 27 | value = module.memcached.cluster_address 28 | description = "Cluster address" 29 | } 30 | 31 | output "cluster_configuration_endpoint" { 32 | value = module.memcached.cluster_configuration_endpoint 33 | description = "Cluster configuration endpoint" 34 | } 35 | 36 | output "hostname" { 37 | value = module.memcached.hostname 38 | description = "Cluster hostname" 39 | } 40 | 41 | output "cluster_urls" { 42 | value = module.memcached.cluster_urls 43 | description = "Cluster URLs" 44 | } 45 | -------------------------------------------------------------------------------- /examples/complete/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | type = string 3 | description = "AWS region" 4 | } 5 | 6 | variable "az_mode" { 7 | type = string 8 | default = "single-az" 9 | description = "Enable or disable multiple AZs, eg: single-az or cross-az" 10 | } 11 | 12 | variable "availability_zone" { 13 | type = string 14 | default = "" 15 | description = "The Availability Zone of the cluster. az_mode must be set to single-az when used." 16 | } 17 | 18 | variable "availability_zones" { 19 | type = list(string) 20 | default = [] 21 | description = "List of Availability Zones for the cluster. az_mode must be set to cross-az when used." 22 | } 23 | 24 | variable "cluster_size" { 25 | type = number 26 | default = 1 27 | description = "Cluster size" 28 | } 29 | 30 | variable "instance_type" { 31 | type = string 32 | default = "cache.t2.micro" 33 | description = "Elastic cache instance type" 34 | } 35 | 36 | variable "engine_version" { 37 | type = string 38 | default = "1.5.16" 39 | description = "Memcached engine version. For more info, see https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/supported-engine-versions.html" 40 | } 41 | 42 | variable "zone_id" { 43 | type = string 44 | default = "" 45 | description = "Route53 DNS Zone ID" 46 | } 47 | 48 | variable "elasticache_parameter_group_family" { 49 | type = string 50 | description = "ElastiCache parameter group family" 51 | default = "memcached1.5" 52 | } 53 | -------------------------------------------------------------------------------- /examples/complete/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0.0" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 4.0" 8 | } 9 | null = { 10 | source = "hashicorp/null" 11 | version = ">= 3.0" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /main.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | elasticache_subnet_group_name = var.elasticache_subnet_group_name != "" ? var.elasticache_subnet_group_name : join("", aws_elasticache_subnet_group.default[*].name) 3 | enabled = module.this.enabled 4 | } 5 | 6 | resource "null_resource" "cluster_urls" { 7 | count = local.enabled ? var.cluster_size : 0 8 | 9 | triggers = { 10 | name = "${replace( 11 | join("", aws_elasticache_cluster.default[*].cluster_address), 12 | ".cfg.", 13 | format(".%04d.", count.index + 1) 14 | )}:${var.port}" 15 | } 16 | 17 | lifecycle { 18 | create_before_destroy = true 19 | } 20 | } 21 | 22 | # 23 | # Security Group Resources 24 | # 25 | locals { 26 | cidr_ingress_rule = ( 27 | length(var.allowed_cidr_blocks) + length(var.allowed_ipv6_cidr_blocks) + length(var.allowed_ipv6_prefix_list_ids)) == 0 ? null : { 28 | key = "cidr-ingress" 29 | type = "ingress" 30 | from_port = var.port 31 | to_port = var.port 32 | protocol = "tcp" 33 | cidr_blocks = var.allowed_cidr_blocks 34 | 35 | allowed_ipv6_cidr_blocks = var.allowed_ipv6_cidr_blocks 36 | allowed_ipv6_prefix_list_ids = var.allowed_ipv6_prefix_list_ids 37 | 38 | description = "Allow inbound traffic from CIDR blocks" 39 | } 40 | 41 | sg_rules = { 42 | legacy = merge(local.cidr_ingress_rule, {}) 43 | extra = var.additional_security_group_rules 44 | } 45 | } 46 | 47 | module "aws_security_group" { 48 | source = "cloudposse/security-group/aws" 49 | version = "2.2.0" 50 | 51 | enabled = local.create_security_group 52 | 53 | allow_all_egress = var.allow_all_egress 54 | security_group_name = var.security_group_name 55 | rules_map = local.sg_rules 56 | rule_matrix = [{ 57 | key = "in" 58 | source_security_group_ids = local.allowed_security_group_ids 59 | rules = [{ 60 | key = "in" 61 | type = "ingress" 62 | from_port = var.port 63 | to_port = var.port 64 | protocol = "tcp" 65 | description = "Selectively allow inbound traffic" 66 | }] 67 | }] 68 | 69 | vpc_id = var.vpc_id 70 | 71 | security_group_description = local.security_group_description 72 | 73 | create_before_destroy = var.security_group_create_before_destroy 74 | 75 | security_group_create_timeout = var.security_group_create_timeout 76 | security_group_delete_timeout = var.security_group_delete_timeout 77 | 78 | context = module.this.context 79 | } 80 | 81 | # 82 | # ElastiCache Resources 83 | # 84 | resource "aws_elasticache_subnet_group" "default" { 85 | count = local.enabled && var.elasticache_subnet_group_name == "" && length(var.subnets) > 0 ? 1 : 0 86 | name = module.this.id 87 | description = "Elasticache subnet group for ${module.this.id}" 88 | subnet_ids = var.subnets 89 | tags = module.this.tags 90 | } 91 | 92 | resource "aws_elasticache_parameter_group" "default" { 93 | count = local.enabled ? 1 : 0 94 | name = module.this.id 95 | family = var.elasticache_parameter_group_family 96 | 97 | parameter { 98 | name = "max_item_size" 99 | value = var.max_item_size 100 | } 101 | 102 | tags = module.this.tags 103 | } 104 | 105 | resource "aws_elasticache_cluster" "default" { 106 | count = local.enabled ? 1 : 0 107 | apply_immediately = var.apply_immediately 108 | cluster_id = module.this.id 109 | engine = "memcached" 110 | engine_version = var.engine_version 111 | node_type = var.instance_type 112 | num_cache_nodes = var.cluster_size 113 | parameter_group_name = join("", aws_elasticache_parameter_group.default[*].name) 114 | transit_encryption_enabled = var.transit_encryption_enabled 115 | subnet_group_name = local.elasticache_subnet_group_name 116 | # It would be nice to remove null or duplicate security group IDs, if there are any, using `compact`, 117 | # but that causes problems, and having duplicates does not seem to cause problems. 118 | # See https://github.com/hashicorp/terraform/issues/29799 119 | security_group_ids = local.create_security_group ? concat(local.associated_security_group_ids, [module.aws_security_group.id]) : local.associated_security_group_ids 120 | maintenance_window = var.maintenance_window 121 | notification_topic_arn = var.notification_topic_arn 122 | port = var.port 123 | az_mode = var.az_mode 124 | availability_zone = var.availability_zone 125 | preferred_availability_zones = var.availability_zones 126 | network_type = var.network_type 127 | tags = module.this.tags 128 | } 129 | 130 | # 131 | # CloudWatch Resources 132 | # 133 | resource "aws_cloudwatch_metric_alarm" "cache_cpu" { 134 | count = local.enabled && var.cloudwatch_metric_alarms_enabled ? 1 : 0 135 | alarm_name = "${module.this.id}-cpu-utilization" 136 | alarm_description = "Memcached cluster CPU utilization" 137 | comparison_operator = "GreaterThanThreshold" 138 | evaluation_periods = 1 139 | metric_name = "CPUUtilization" 140 | namespace = "AWS/ElastiCache" 141 | period = 300 142 | statistic = "Average" 143 | 144 | threshold = var.alarm_cpu_threshold_percent 145 | 146 | dimensions = { 147 | CacheClusterId = module.this.id 148 | } 149 | 150 | alarm_actions = var.alarm_actions 151 | depends_on = [aws_elasticache_cluster.default] 152 | 153 | tags = module.this.tags 154 | } 155 | 156 | resource "aws_cloudwatch_metric_alarm" "cache_memory" { 157 | count = local.enabled && var.cloudwatch_metric_alarms_enabled ? 1 : 0 158 | alarm_name = "${module.this.id}-freeable-memory" 159 | alarm_description = "Memcached cluster freeable memory" 160 | comparison_operator = "LessThanThreshold" 161 | evaluation_periods = 1 162 | metric_name = "FreeableMemory" 163 | namespace = "AWS/ElastiCache" 164 | period = 60 165 | statistic = "Average" 166 | 167 | threshold = var.alarm_memory_threshold_bytes 168 | 169 | dimensions = { 170 | CacheClusterId = module.this.id 171 | } 172 | 173 | alarm_actions = var.alarm_actions 174 | depends_on = [aws_elasticache_cluster.default] 175 | 176 | tags = module.this.tags 177 | } 178 | 179 | module "dns" { 180 | source = "cloudposse/route53-cluster-hostname/aws" 181 | version = "0.13.0" 182 | enabled = module.this.enabled && length(var.zone_id) > 0 ? true : false 183 | dns_name = var.dns_subdomain != "" ? var.dns_subdomain : module.this.id 184 | ttl = 60 185 | zone_id = var.zone_id 186 | records = [join("", aws_elasticache_cluster.default[*].cluster_address)] 187 | 188 | context = module.this.context 189 | } 190 | -------------------------------------------------------------------------------- /outputs.tf: -------------------------------------------------------------------------------- 1 | output "cluster_id" { 2 | value = join("", aws_elasticache_cluster.default[*].id) 3 | description = "Cluster ID" 4 | } 5 | 6 | output "security_group_id" { 7 | value = module.aws_security_group.id 8 | description = "The ID of the created security group" 9 | } 10 | 11 | output "security_group_arn" { 12 | value = module.aws_security_group.arn 13 | description = "The ARN of the created security group" 14 | } 15 | 16 | output "security_group_name" { 17 | value = module.aws_security_group.name 18 | description = "The name of the created security group" 19 | } 20 | 21 | output "cluster_address" { 22 | value = join("", aws_elasticache_cluster.default[*].cluster_address) 23 | description = "Cluster address" 24 | } 25 | 26 | output "cluster_configuration_endpoint" { 27 | value = join("", aws_elasticache_cluster.default[*].configuration_endpoint) 28 | description = "Cluster configuration endpoint" 29 | } 30 | 31 | output "hostname" { 32 | value = module.dns.hostname 33 | description = "Cluster hostname" 34 | } 35 | 36 | output "cluster_urls" { 37 | value = null_resource.cluster_urls[*].triggers.name 38 | description = "Cluster URLs" 39 | } 40 | -------------------------------------------------------------------------------- /security-group-inputs.tf: -------------------------------------------------------------------------------- 1 | # security_group_inputs Version: 2 2 | ## 3 | 4 | 5 | variable "create_security_group" { 6 | type = bool 7 | default = true 8 | description = "Set `true` to create and configure a new security group. If false, `associated_security_group_ids` must be provided." 9 | } 10 | 11 | locals { 12 | create_security_group = local.enabled && (var.use_existing_security_groups == null ? var.create_security_group : !var.use_existing_security_groups) 13 | } 14 | 15 | variable "associated_security_group_ids" { 16 | type = list(string) 17 | default = [] 18 | description = <<-EOT 19 | A list of IDs of Security Groups to associate the created resource with, in addition to the created security group. 20 | These security groups will not be modified and, if `create_security_group` is `false`, must have rules providing the desired access. 21 | EOT 22 | } 23 | 24 | locals { 25 | associated_security_group_ids = concat(var.existing_security_groups, var.associated_security_group_ids) 26 | } 27 | 28 | variable "allowed_security_group_ids" { 29 | type = list(string) 30 | default = [] 31 | description = <<-EOT 32 | A list of IDs of Security Groups to allow access to the security group created by this module. 33 | The length of this list must be known at "plan" time. 34 | EOT 35 | } 36 | 37 | locals { 38 | allowed_security_group_ids = concat(var.allowed_security_groups, var.allowed_security_group_ids) 39 | } 40 | 41 | variable "allowed_cidr_blocks" { 42 | type = list(string) 43 | default = [] 44 | description = <<-EOT 45 | A list of IPv4 CIDRs to allow access to the security group created by this module. 46 | The length of this list must be known at "plan" time. 47 | EOT 48 | } 49 | 50 | variable "allowed_ipv6_cidr_blocks" { 51 | type = list(string) 52 | default = [] 53 | description = <<-EOT 54 | A list of IPv6 CIDRs to allow access to the security group created by this module. 55 | The length of this list must be known at "plan" time. 56 | EOT 57 | } 58 | 59 | variable "allowed_ipv6_prefix_list_ids" { 60 | type = list(string) 61 | default = [] 62 | description = <<-EOT 63 | A list of IPv6 Prefix Lists IDs to allow access to the security group created by this module. 64 | The length of this list must be known at "plan" time. 65 | EOT 66 | } 67 | 68 | variable "security_group_name" { 69 | type = list(string) 70 | default = [] 71 | description = <<-EOT 72 | The name to assign to the created security group. Must be unique within the VPC. 73 | If not provided, will be derived from the `null-label.context` passed in. 74 | If `create_before_destroy` is true, will be used as a name prefix. 75 | EOT 76 | } 77 | 78 | variable "security_group_description" { 79 | type = string 80 | default = "Security group for Elasticache Memcached" 81 | description = <<-EOT 82 | The description to assign to the created Security Group. 83 | Warning: Changing the description causes the security group to be replaced. 84 | EOT 85 | } 86 | 87 | locals { 88 | security_group_description = var.security_group_description == null ? "Managed by Terraform" : var.security_group_description 89 | } 90 | 91 | variable "security_group_create_before_destroy" { 92 | type = bool 93 | default = true 94 | description = <<-EOT 95 | Set `true` to enable Terraform `create_before_destroy` behavior on the created security group. 96 | We only recommend setting this `false` if you are upgrading this module and need to keep 97 | the existing security group from being replaced. 98 | Note that changing this value will always cause the security group to be replaced. 99 | EOT 100 | } 101 | 102 | variable "security_group_create_timeout" { 103 | type = string 104 | default = "10m" 105 | description = "How long to wait for the security group to be created." 106 | } 107 | 108 | variable "security_group_delete_timeout" { 109 | type = string 110 | default = "15m" 111 | description = <<-EOT 112 | How long to retry on `DependencyViolation` errors during security group deletion. 113 | EOT 114 | } 115 | 116 | variable "allow_all_egress" { 117 | type = bool 118 | default = true 119 | description = <<-EOT 120 | If `true`, the created security group will allow egress on all ports and protocols to all IP address. 121 | If this is false and no egress rules are otherwise specified, then no egress will be allowed. 122 | EOT 123 | } 124 | 125 | variable "additional_security_group_rules" { 126 | type = list(any) 127 | default = [] 128 | description = <<-EOT 129 | A list of Security Group rule objects to add to the created security group, in addition to the ones 130 | this module normally creates. (To suppress the module's rules, set `create_security_group` to false 131 | and supply your own security group via `associated_security_group_ids`.) 132 | The keys and values of the objects are fully compatible with the `aws_security_group_rule` resource, except 133 | for `security_group_id` which will be ignored, and the optional "key" which, if provided, must be unique and known at "plan" time. 134 | To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule . 135 | EOT 136 | } 137 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | .test-harness 2 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | TEST_HARNESS ?= https://github.com/cloudposse/test-harness.git 2 | TEST_HARNESS_BRANCH ?= master 3 | TEST_HARNESS_PATH = $(realpath .test-harness) 4 | BATS_ARGS ?= --tap 5 | BATS_LOG ?= test.log 6 | 7 | # Define a macro to run the tests 8 | define RUN_TESTS 9 | @echo "Running tests in $(1)" 10 | @cd $(1) && bats $(BATS_ARGS) $(addsuffix .bats,$(addprefix $(TEST_HARNESS_PATH)/test/terraform/,$(TESTS))) 11 | endef 12 | 13 | default: all 14 | 15 | -include Makefile.* 16 | 17 | ## Provision the test-harnesss 18 | .test-harness: 19 | [ -d $@ ] || git clone --depth=1 -b $(TEST_HARNESS_BRANCH) $(TEST_HARNESS) $@ 20 | 21 | ## Initialize the tests 22 | init: .test-harness 23 | 24 | ## Install all dependencies (OS specific) 25 | deps:: 26 | @exit 0 27 | 28 | ## Clean up the test harness 29 | clean: 30 | [ "$(TEST_HARNESS_PATH)" == "/" ] || rm -rf $(TEST_HARNESS_PATH) 31 | 32 | ## Run all tests 33 | all: module examples/complete 34 | 35 | ## Run basic sanity checks against the module itself 36 | module: export TESTS ?= installed lint module-pinning provider-pinning validate terraform-docs input-descriptions output-descriptions 37 | module: deps 38 | $(call RUN_TESTS, ../) 39 | 40 | ## Run tests against example 41 | examples/complete: export TESTS ?= installed lint validate 42 | examples/complete: deps 43 | $(call RUN_TESTS, ../$@) 44 | -------------------------------------------------------------------------------- /test/Makefile.alpine: -------------------------------------------------------------------------------- 1 | ifneq (,$(wildcard /sbin/apk)) 2 | ## Install all dependencies for alpine 3 | deps:: init 4 | @apk add --update terraform-docs@cloudposse json2hcl@cloudposse 5 | endif 6 | -------------------------------------------------------------------------------- /test/src/.gitignore: -------------------------------------------------------------------------------- 1 | .gopath 2 | vendor/ 3 | -------------------------------------------------------------------------------- /test/src/Makefile: -------------------------------------------------------------------------------- 1 | export TERRAFORM_VERSION ?= $(shell curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version' | cut -d. -f1) 2 | 3 | .DEFAULT_GOAL : all 4 | 5 | .PHONY: all 6 | ## Default target 7 | all: test 8 | 9 | .PHONY : init 10 | ## Initialize tests 11 | init: 12 | @exit 0 13 | 14 | .PHONY : test 15 | ## Run tests 16 | test: init 17 | go mod download 18 | go test -v -timeout 60m -run TestExamplesComplete 19 | 20 | ## Run tests in docker container 21 | docker/test: 22 | docker run --name terratest --rm -it -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e GITHUB_TOKEN \ 23 | -e PATH="/usr/local/terraform/$(TERRAFORM_VERSION)/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ 24 | -v $(CURDIR)/../../:/module/ cloudposse/test-harness:latest -C /module/test/src test 25 | 26 | .PHONY : clean 27 | ## Clean up files 28 | clean: 29 | rm -rf ../../examples/complete/*.tfstate* 30 | -------------------------------------------------------------------------------- /test/src/examples_complete_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | "fmt" 7 | 8 | "github.com/gruntwork-io/terratest/modules/random" 9 | "github.com/gruntwork-io/terratest/modules/terraform" 10 | "github.com/stretchr/testify/assert" 11 | ) 12 | 13 | // Test the Terraform module in examples/complete using Terratest. 14 | func TestExamplesComplete(t *testing.T) { 15 | t.Parallel() 16 | randID := strings.ToLower(random.UniqueId()) 17 | attributes := []string{randID} 18 | 19 | terraformOptions := &terraform.Options{ 20 | // The path to where our Terraform code is located 21 | TerraformDir: "../../examples/complete", 22 | Upgrade: true, 23 | // Variables to pass to our Terraform code using -var-file options 24 | VarFiles: []string{"fixtures.us-east-2.tfvars"}, 25 | Vars: map[string]interface{}{ 26 | "attributes": attributes, 27 | }, 28 | } 29 | 30 | // At the end of the test, run `terraform destroy` to clean up any resources that were created 31 | defer terraform.Destroy(t, terraformOptions) 32 | 33 | // This will run `terraform init` and `terraform apply` and fail the test if there are any errors 34 | terraform.InitAndApply(t, terraformOptions) 35 | 36 | // Run `terraform output` to get the value of an output variable 37 | vpcCidr := terraform.Output(t, terraformOptions, "vpc_cidr") 38 | // Verify we're getting back the outputs we expect 39 | assert.Equal(t, "172.16.0.0/16", vpcCidr) 40 | 41 | // Run `terraform output` to get the value of an output variable 42 | privateSubnetCidrs := terraform.OutputList(t, terraformOptions, "private_subnet_cidrs") 43 | // Verify we're getting back the outputs we expect 44 | assert.Equal(t, []string{"172.16.0.0/19"}, privateSubnetCidrs) 45 | 46 | // Run `terraform output` to get the value of an output variable 47 | publicSubnetCidrs := terraform.OutputList(t, terraformOptions, "public_subnet_cidrs") 48 | // Verify we're getting back the outputs we expect 49 | assert.Equal(t, []string{"172.16.96.0/19"}, publicSubnetCidrs) 50 | 51 | // Run `terraform output` to get the value of an output variable 52 | clusterId := terraform.Output(t, terraformOptions, "cluster_id") 53 | // Verify we're getting back the outputs we expect 54 | assert.Equal(t, fmt.Sprintf("eg-test-memcached-test-%s", randID), clusterId) 55 | } 56 | -------------------------------------------------------------------------------- /test/src/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/cloudposse/terraform-aws-elasticache-memcached 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/gruntwork-io/terratest v0.40.0 7 | github.com/stretchr/testify v1.7.0 8 | ) 9 | -------------------------------------------------------------------------------- /variables-deprecated.tf: -------------------------------------------------------------------------------- 1 | variable "use_existing_security_groups" { 2 | type = bool 3 | description = <<-EOT 4 | DEPRECATED: Use `create_security_group` instead. 5 | Historical description: Flag to enable/disable creation of Security Group in the module. 6 | Set to `true` to disable Security Group creation and provide a list of existing security Group IDs in `existing_security_groups` to place the cluster into. 7 | Historical default: `false` 8 | EOT 9 | default = null 10 | } 11 | 12 | variable "existing_security_groups" { 13 | type = list(string) 14 | default = [] 15 | description = <<-EOT 16 | DEPRECATED: Use `associated_security_group_ids` instead. 17 | Historical description: List of existing Security Group IDs to place the cluster into. 18 | Set `use_existing_security_groups` to `true` to enable using `existing_security_groups` as Security Groups for the cluster. 19 | EOT 20 | } 21 | 22 | variable "allowed_security_groups" { 23 | type = list(string) 24 | default = [] 25 | description = <<-EOT 26 | DEPRECATED: Use `allowed_security_group_ids` instead. 27 | EOT 28 | } 29 | -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | variable "vpc_id" { 2 | type = string 3 | default = "" 4 | description = "VPC ID" 5 | } 6 | 7 | variable "max_item_size" { 8 | type = number 9 | default = 10485760 10 | description = "Max item size" 11 | } 12 | 13 | variable "subnets" { 14 | type = list(string) 15 | default = [] 16 | description = "AWS subnet ids" 17 | } 18 | 19 | variable "network_type" { 20 | type = string 21 | default = "ipv4" 22 | description = "The network type of the cluster. Valid values: ipv4, ipv6, dual_stack." 23 | } 24 | 25 | variable "maintenance_window" { 26 | type = string 27 | default = "wed:03:00-wed:04:00" 28 | description = "Maintenance window" 29 | } 30 | 31 | variable "cluster_size" { 32 | type = number 33 | default = 1 34 | description = "Cluster size" 35 | } 36 | 37 | variable "instance_type" { 38 | type = string 39 | default = "cache.t2.micro" 40 | description = "Elastic cache instance type" 41 | } 42 | 43 | variable "engine_version" { 44 | type = string 45 | default = "1.5.16" 46 | description = "Memcached engine version. For more info, see https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/supported-engine-versions.html" 47 | } 48 | 49 | variable "notification_topic_arn" { 50 | type = string 51 | default = "" 52 | description = "Notification topic arn" 53 | } 54 | 55 | variable "alarm_cpu_threshold_percent" { 56 | type = number 57 | default = 75 58 | description = "CPU threshold alarm level" 59 | } 60 | 61 | variable "alarm_memory_threshold_bytes" { 62 | type = number 63 | default = 10000000 # 10MB 64 | description = "Alarm memory threshold bytes" 65 | } 66 | 67 | variable "alarm_actions" { 68 | type = list(string) 69 | default = [] 70 | description = "Alarm actions" 71 | } 72 | 73 | variable "apply_immediately" { 74 | type = bool 75 | default = true 76 | description = "Specifies whether any database modifications are applied immediately, or during the next maintenance window" 77 | } 78 | 79 | variable "availability_zone" { 80 | type = string 81 | default = "" 82 | description = "The Availability Zone of the cluster. az_mode must be set to single-az when used." 83 | } 84 | 85 | variable "availability_zones" { 86 | type = list(string) 87 | default = [] 88 | description = "List of Availability Zones for the cluster. az_mode must be set to cross-az when used." 89 | } 90 | 91 | variable "az_mode" { 92 | type = string 93 | default = "single-az" 94 | description = "Enable or disable multiple AZs, eg: single-az or cross-az" 95 | } 96 | 97 | variable "zone_id" { 98 | type = string 99 | default = "" 100 | description = "Route53 DNS Zone ID" 101 | } 102 | 103 | variable "dns_subdomain" { 104 | type = string 105 | default = "" 106 | description = "The subdomain to use for the CNAME record. If not provided then the CNAME record will use var.name." 107 | } 108 | 109 | variable "port" { 110 | type = number 111 | default = 11211 112 | description = "Memcached port" 113 | } 114 | 115 | variable "elasticache_subnet_group_name" { 116 | type = string 117 | description = "Subnet group name for the ElastiCache instance" 118 | default = "" 119 | } 120 | 121 | variable "elasticache_parameter_group_family" { 122 | type = string 123 | description = "ElastiCache parameter group family" 124 | default = "memcached1.5" 125 | } 126 | 127 | variable "cloudwatch_metric_alarms_enabled" { 128 | type = bool 129 | description = "Boolean flag to enable/disable CloudWatch metrics alarms" 130 | default = false 131 | } 132 | 133 | variable "transit_encryption_enabled" { 134 | type = bool 135 | description = "Boolean flag to enable transit encryption (requires Memcached version 1.6.12+)" 136 | default = false 137 | } 138 | -------------------------------------------------------------------------------- /versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0.0" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 5.16" 8 | } 9 | null = { 10 | source = "hashicorp/null" 11 | version = ">= 3.0" 12 | } 13 | } 14 | } 15 | --------------------------------------------------------------------------------