Skip to content

Commit

Permalink
Merge pull request squareops#1 from RohitSquareops/main
Browse files Browse the repository at this point in the history
updated module structure, review and tested
  • Loading branch information
sunil-kumar-squareops authored May 18, 2023
2 parents 94b2578 + 4341a91 commit 9feccef
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 103 deletions.
2 changes: 1 addition & 1 deletion IAM.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ The Policy required is:
}

```
<!-- END OF PRE-COMMIT-PIKE DOCS HOOK -->
<!-- END OF PRE-COMMIT-PIKE DOCS HOOK -->
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2023 SquareOps Technologies Pvt. Ltd.
Copyright 2023 SquareOps Technologies Pvt. Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -198,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
105 changes: 44 additions & 61 deletions README.md

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## Redis Example
![squareops_avatar]

[squareops_avatar]: https://squareops.com/wp-content/uploads/2022/12/squareops-logo.png

### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
<br>

This example will be very useful for users who are new to a module and want to quickly learn how to use it. By reviewing the examples, users can gain a better understanding of how the module works, what features it supports, and how to customize it to their specific needs.
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

Expand All @@ -14,7 +23,7 @@ No providers.

| Name | Source | Version |
|------|--------|---------|
| <a name="module_redis"></a> [redis](#module\_redis) | ../../ | n/a |
| <a name="module_redis"></a> [redis](#module\_redis) | git@github.com:sq-ia/terraform-aws-elasticache-redis.git | n/a |

## Resources

Expand All @@ -28,7 +37,9 @@ No inputs.

| Name | Description |
|------|-------------|
| <a name="output_elastic-cache-redis-endpoint"></a> [elastic-cache-redis-endpoint](#output\_elastic-cache-redis-endpoint) | Elasticache-redis cluster primary endpoint address |
| <a name="output_auth_token_password"></a> [auth\_token\_password](#output\_auth\_token\_password) | Elasticache-redis auth token password(this password may be old, because Terraform doesn't track it after initial creation) |
| <a name="output_elastic_cache_redis_endpoint"></a> [elastic\_cache\_redis\_endpoint](#output\_elastic\_cache\_redis\_endpoint) | Elasticache-redis cluster primary endpoint address |
| <a name="output_elastic_cache_redis_security_group"></a> [elastic\_cache\_redis\_security\_group](#output\_elastic\_cache\_redis\_security\_group) | The security group ID of the cluster |
| <a name="output_id_of_redis_cluster"></a> [id\_of\_redis\_cluster](#output\_id\_of\_redis\_cluster) | ID of the elasticache-redis cluster |
| <a name="output_port_no"></a> [port\_no](#output\_port\_no) | Port number of Redis |
| <a name="output_primary_endpoint_address"></a> [primary\_endpoint\_address](#output\_primary\_endpoint\_address) | Primary endpoint address of redis |
Expand Down
54 changes: 25 additions & 29 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
locals {
name = "skaf"
region = "us-east-2"
environment = "production"
redis_engine_version = "6.x"
name = "skaf"
region = "us-east-1"
family = "redis6.x"
node_type = "cache.t3.small"
vpc_id = "vpc-06f1a2f3a7"
subnet_ids = ["subnet-0bb128ab", "subnet-0b54928666a"]
kms_key_arn = "arn:aws:kms:us-east-1:2222222222:key/bcfdc1c5-1bbbdb467d90"
environment = "prod"
redis_engine_version = "6.0"
allowed_security_groups = ["sg-0e8dab08e40"]
}

data "aws_availability_zones" "available" {}

module "redis" {
source = "../../"
environment = local.environment
name = local.name
engine_version = local.redis_engine_version
port = 6379
node_type = "cache.t3.small"
num_cache_nodes = 2
family = "redis6.x"
availability_zones = [for n in range(0, 2) : data.aws_availability_zones.available.names[n]]
automatic_failover_enabled = true
snapshot_retention_limit = 7
multi_az_enabled = false
at_rest_encryption_enabled = true
transit_encryption_enabled = false
notification_topic_arn = null
vpc_id = "vpc-06e37f0786b7efaab"
subnets = ["subnet-021320ad57f4ef6bb","subnet-04ec8cb5f9abd4941"]
allowed_cidr_blocks = []
allowed_security_groups = ["sg-028cc84f7ff452dfd"]
maintenance_window = "sun:09:00-sun:10:00"
snapshot_window = "07:00-08:00"
kms_key_arn = "arn:aws:kms:us-east-2:271251951598:key/7fa600be-9c08-4502-a67a-ed7e8bc332cb"
source = "git@github.com:sq-ia/terraform-aws-elasticache-redis.git"
name = local.name
family = local.family
node_type = local.node_type
environment = local.environment
engine_version = local.redis_engine_version
num_cache_nodes = 2
vpc_id = local.vpc_id
subnets = local.subnet_ids
kms_key_arn = local.kms_key_arn
multi_az_enabled = false
availability_zones = 2
snapshot_window = "07:00-08:00"
maintenance_window = "sun:09:00-sun:10:00"
allowed_security_groups = local.allowed_security_groups
}

6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


locals {
tags = {
Environment = var.environment
Expand All @@ -8,6 +6,8 @@ locals {
engine_log = var.engine_log_destination == null ? [] : [1]
}

data "aws_availability_zones" "available" {}

resource "random_password" "password" {
length = 16
special = false
Expand Down Expand Up @@ -40,7 +40,7 @@ resource "aws_elasticache_replication_group" "redis" {
parameter_group_name = join("", aws_elasticache_parameter_group.default.*.name) #var.parameter_group_name
security_group_ids = [module.security_group_redis.security_group_id]
subnet_group_name = aws_elasticache_subnet_group.elasticache.id
availability_zones = var.availability_zones
availability_zones = [for n in range(0, var.availability_zones) : data.aws_availability_zones.available.names[n]]
automatic_failover_enabled = var.automatic_failover_enabled
snapshot_window = var.snapshot_window
snapshot_retention_limit = var.snapshot_retention_limit
Expand Down
10 changes: 5 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ variable "port" {

variable "automatic_failover_enabled" {
description = "Enable automatic failover "
default = false
default = true
type = bool
}

Expand All @@ -69,9 +69,9 @@ variable "multi_az_enabled" {


variable "availability_zones" {
description = "The list of AZs"
default = []
type = list(string)
description = "The no. of AZs"
default = 2
type = string
}

variable "snapshot_window" {
Expand All @@ -82,7 +82,7 @@ variable "snapshot_window" {

variable "snapshot_retention_limit" {
description = "The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them. For example, if you set SnapshotRetentionLimit to 5, then a snapshot that was taken today will be retained for 5 days before being deleted. If the value of SnapshotRetentionLimit is set to zero (0), backups are turned off. Please note that setting a snapshot_retention_limit is not supported on cache.t1.micro or cache.t2.* cache nodes"
default = 0
default = 7
type = number
}

Expand Down

0 comments on commit 9feccef

Please sign in to comment.