├── .gitignore ├── azurerm_client_config.tf ├── terraform.tfvars.example ├── azurerm_resource_group.tf ├── provider.tf ├── output.tf ├── azurerm_redis_enterprise_database.tf ├── azurerm_redis_enterprise_cluster.tf ├── random_string.tf ├── variables.tf ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .envrc 3 | .terraform* 4 | terraform.tfstate* 5 | -------------------------------------------------------------------------------- /azurerm_client_config.tf: -------------------------------------------------------------------------------- 1 | data "azurerm_client_config" "current" { 2 | } -------------------------------------------------------------------------------- /terraform.tfvars.example: -------------------------------------------------------------------------------- 1 | subscription_id = "" 2 | tenant_id = "" 3 | client_id = "" 4 | client_secret = "" 5 | -------------------------------------------------------------------------------- /azurerm_resource_group.tf: -------------------------------------------------------------------------------- 1 | resource "azurerm_resource_group" "redisgeek" { 2 | name = format("redisgeek-%s", random_string.resource_group_name.result) 3 | location = var.location 4 | tags = merge(var.tags, { owner = data.azurerm_client_config.current.client_id }) 5 | } 6 | -------------------------------------------------------------------------------- /provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | azurerm = { 4 | source = "hashicorp/azurerm" 5 | } 6 | random = { 7 | source = "hashicorp/random" 8 | } 9 | } 10 | } 11 | 12 | provider "azurerm" { 13 | environment = var.cloud_name 14 | features { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /output.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | redisgeek_config = { 3 | hostname = azurerm_redis_enterprise_cluster.redisgeek.hostname 4 | access_key = azurerm_redis_enterprise_database.redisgeek.primary_access_key 5 | port = "10000" 6 | } 7 | } 8 | 9 | output "redisgeek_config" { 10 | value = local.redisgeek_config 11 | sensitive = true 12 | } -------------------------------------------------------------------------------- /azurerm_redis_enterprise_database.tf: -------------------------------------------------------------------------------- 1 | resource "azurerm_redis_enterprise_database" "redisgeek" { 2 | name = "default" 3 | resource_group_name = azurerm_resource_group.redisgeek.name 4 | cluster_id = azurerm_redis_enterprise_cluster.redisgeek.id 5 | clustering_policy = var.azure_redis_enterprise_database_clustering_policy 6 | } 7 | -------------------------------------------------------------------------------- /azurerm_redis_enterprise_cluster.tf: -------------------------------------------------------------------------------- 1 | resource "azurerm_redis_enterprise_cluster" "redisgeek" { 2 | name = format("redisgeek-%s", random_string.redis_enterprise_name.result) 3 | resource_group_name = azurerm_resource_group.redisgeek.name 4 | location = var.location 5 | zones = [1, 2, 3] 6 | sku_name = var.acre_sku 7 | tags = merge(var.tags, { owner = data.azurerm_client_config.current.client_id }) 8 | } 9 | -------------------------------------------------------------------------------- /random_string.tf: -------------------------------------------------------------------------------- 1 | resource "random_string" "redis_enterprise_name" { 2 | length = 4 3 | special = false 4 | upper = false 5 | } 6 | 7 | resource "random_string" "resource_group_name" { 8 | length = 4 9 | special = false 10 | upper = false 11 | } 12 | 13 | resource "random_string" "acre_name" { 14 | length = 4 15 | special = false 16 | upper = false 17 | } 18 | 19 | resource "random_string" "key_vault_name" { 20 | length = 8 21 | number = false 22 | special = false 23 | upper = false 24 | } 25 | 26 | resource "random_string" "secret_name" { 27 | length = 8 28 | number = false 29 | special = false 30 | upper = false 31 | } 32 | -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | variable "acre_sku" { 2 | type = string 3 | default = "Enterprise_E10-2" 4 | } 5 | 6 | variable "azure_redis_enterprise_database_clustering_policy" { 7 | type = string 8 | default = "EnterpriseCluster" 9 | } 10 | 11 | variable "location" { 12 | type = string 13 | default = "East US" 14 | } 15 | 16 | variable "cloud_name" { 17 | description = "The Azure cloud environment to use. Available values at https://www.terraform.io/docs/providers/azurerm/#environment" 18 | default = "public" 19 | type = string 20 | } 21 | 22 | variable "tags" { 23 | description = "Key/value tags to assign to all resources." 24 | default = {} 25 | type = map(string) 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 redisgeek 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Contributors][contributors-shield]][contributors-url] 2 | [![Forks][forks-shield]][forks-url] 3 | [![Stargazers][stars-shield]][stars-url] 4 | [![Issues][issues-shield]][issues-url] 5 | [![MIT License][license-shield]][license-url] 6 | 7 | # ACRE-TERRAFORM-SIMPLE 8 | 9 | This is a template to get started with the 'azurerm_redis_enterprise_cluster' resource available in the 'azurerm' provider with Terraform. 10 | 11 | - _Tenant_ 12 | - _Subscription_ 13 | - **Resource Group** 14 | - **Redis Enterprise Cluster** 15 | 16 | There are zero Redis Modules configured, and the endpoint is publicly accessible. 17 | 18 | ## [Getting Started](#getting-started) | [About](#about-the-project) | [License](#license) 19 | 20 | ## Getting Started 21 | 22 | ### Prerequisites 23 | 24 | 1. [Terraform](https://terraform.io]) [CLI](https://terraform.io/downloads.html) 25 | 2. [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) 26 | 27 | ### Step 1. Getting Started 28 | 29 | Login to Azure using the Azure CLI 30 | 31 | ```bash 32 | az login 33 | ``` 34 | >Login with a Service Principal will also work 35 | 36 | 37 | ### Step 2: Clone the repository 38 | 39 | ```bash 40 | git clone https://github.com/redis-developer/acre-terraform-simple 41 | ``` 42 | 43 | 44 | ### Step 3: Initialize the repository 45 | 46 | ```bash 47 | cd acre-terraform-simple 48 | terraform init 49 | ``` 50 | >The output should include: ```Terraform has been successfully initialized``` 51 | 52 | 53 | ### Step 4: Optionally, modify the variables 54 | 55 | This default variables are setup to deploy the smallest 'E10' instance into the 'East US' region. 56 | Changes can be made by updating the ```variables.tf``` file. 57 | 58 | 59 | ### Step 5: Verify the plan 60 | 61 | The 'plan' output will show you everything being created by the template. 62 | 63 | ```bash 64 | terraform plan 65 | ``` 66 | >The plan step does not make any changes in Azure 67 | 68 | ### Step 6: Apply the plan 69 | 70 | When the plan looks good, 'apply' the template. 71 | 72 | ```bash 73 | terraform apply 74 | ``` 75 | 76 | ### Step 7: Connect using generated output 77 | 78 | The access key is sensitive, so viewing the outputs must be requested specifically. 79 | The output is also in JSON format. 80 | 81 | ```bash 82 | terraform output redisgeek_config 83 | ``` 84 | > Example output: 85 | ``` 86 | { 87 | "hostname" = "redisgeek-8jy4.eastus.redisenterprise.cache.azure.net" 88 | "access_key" = "DQYABC3uRMyDguE1236Xkvv3TprUcqBWTRkfgOPjs82Y=" 89 | "port" = "10000" 90 | } 91 | ``` 92 | 93 | ## About The Project 94 | 95 | The cluster, deployed across 3-AZs, will have a 99.99 SLA that is financially backed by Azure. 96 | There are no "preview" features or modules included in this template. 97 | 98 | ### Built With 99 | 100 | * [Terraform](https://terraform.io) 101 | 102 | ### Contributing 103 | 104 | Pull-requests are welcomed! 105 | 106 | ## License 107 | 108 | Distributed under the MIT License. See `LICENSE` for more information. 109 | 110 | 111 | 112 | [contributors-shield]: https://img.shields.io/github/contributors/redisgeek/acre-terraform-simple.svg?style=for-the-badge 113 | [contributors-url]: https://github.com/redisgeek/acre-terraform-simple/graphs/contributors 114 | [forks-shield]: https://img.shields.io/github/forks/redisgeek/acre-terraform-simple.svg?style=for-the-badge 115 | [forks-url]: https://github.com/redisgeek/acre-terraform-simple/network/members 116 | [stars-shield]: https://img.shields.io/github/stars/redisgeek/acre-terraform-simple.svg?style=for-the-badge 117 | [stars-url]: https://github.com/redisgeek/acre-terraform-simple/stargazers 118 | [issues-shield]: https://img.shields.io/github/issues/redisgeek/acre-terraform-simple.svg?style=for-the-badge 119 | [issues-url]: https://github.com/redisgeek/acre-terraform-simple/issues 120 | [license-shield]: https://img.shields.io/github/license/redisgeek/acre-terraform-simple.svg?style=for-the-badge 121 | [license-url]: https://github.com/redisgeek/acre-terraform-simple/blob/main/LICENSE --------------------------------------------------------------------------------