Skip to content

Commit 9feccef

Browse files
Merge pull request #1 from RohitSquareops/main
updated module structure, review and tested
2 parents 94b2578 + 4341a91 commit 9feccef

File tree

7 files changed

+93
-103
lines changed

7 files changed

+93
-103
lines changed

IAM.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ The Policy required is:
7070
}
7171

7272
```
73-
<!-- END OF PRE-COMMIT-PIKE DOCS HOOK -->
73+
<!-- END OF PRE-COMMIT-PIKE DOCS HOOK -->

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2023 SquareOps Technologies Pvt. Ltd.
189+
Copyright 2023 SquareOps Technologies Pvt. Ltd.
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

README.md

Lines changed: 44 additions & 61 deletions
Large diffs are not rendered by default.

examples/complete/README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## Redis Example
2+
![squareops_avatar]
3+
4+
[squareops_avatar]: https://squareops.com/wp-content/uploads/2022/12/squareops-logo.png
5+
6+
### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
7+
<br>
8+
9+
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.
110
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
211
## Requirements
312

@@ -14,7 +23,7 @@ No providers.
1423

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

1928
## Resources
2029

@@ -28,7 +37,9 @@ No inputs.
2837

2938
| Name | Description |
3039
|------|-------------|
31-
| <a name="output_elastic-cache-redis-endpoint"></a> [elastic-cache-redis-endpoint](#output\_elastic-cache-redis-endpoint) | Elasticache-redis cluster primary endpoint address |
40+
| <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) |
41+
| <a name="output_elastic_cache_redis_endpoint"></a> [elastic\_cache\_redis\_endpoint](#output\_elastic\_cache\_redis\_endpoint) | Elasticache-redis cluster primary endpoint address |
42+
| <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 |
3243
| <a name="output_id_of_redis_cluster"></a> [id\_of\_redis\_cluster](#output\_id\_of\_redis\_cluster) | ID of the elasticache-redis cluster |
3344
| <a name="output_port_no"></a> [port\_no](#output\_port\_no) | Port number of Redis |
3445
| <a name="output_primary_endpoint_address"></a> [primary\_endpoint\_address](#output\_primary\_endpoint\_address) | Primary endpoint address of redis |

examples/complete/main.tf

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
locals {
2-
name = "skaf"
3-
region = "us-east-2"
4-
environment = "production"
5-
redis_engine_version = "6.x"
2+
name = "skaf"
3+
region = "us-east-1"
4+
family = "redis6.x"
5+
node_type = "cache.t3.small"
6+
vpc_id = "vpc-06f1a2f3a7"
7+
subnet_ids = ["subnet-0bb128ab", "subnet-0b54928666a"]
8+
kms_key_arn = "arn:aws:kms:us-east-1:2222222222:key/bcfdc1c5-1bbbdb467d90"
9+
environment = "prod"
10+
redis_engine_version = "6.0"
11+
allowed_security_groups = ["sg-0e8dab08e40"]
612
}
713

8-
data "aws_availability_zones" "available" {}
9-
1014
module "redis" {
11-
source = "../../"
12-
environment = local.environment
13-
name = local.name
14-
engine_version = local.redis_engine_version
15-
port = 6379
16-
node_type = "cache.t3.small"
17-
num_cache_nodes = 2
18-
family = "redis6.x"
19-
availability_zones = [for n in range(0, 2) : data.aws_availability_zones.available.names[n]]
20-
automatic_failover_enabled = true
21-
snapshot_retention_limit = 7
22-
multi_az_enabled = false
23-
at_rest_encryption_enabled = true
24-
transit_encryption_enabled = false
25-
notification_topic_arn = null
26-
vpc_id = "vpc-06e37f0786b7efaab"
27-
subnets = ["subnet-021320ad57f4ef6bb","subnet-04ec8cb5f9abd4941"]
28-
allowed_cidr_blocks = []
29-
allowed_security_groups = ["sg-028cc84f7ff452dfd"]
30-
maintenance_window = "sun:09:00-sun:10:00"
31-
snapshot_window = "07:00-08:00"
32-
kms_key_arn = "arn:aws:kms:us-east-2:271251951598:key/7fa600be-9c08-4502-a67a-ed7e8bc332cb"
15+
source = "git@github.com:sq-ia/terraform-aws-elasticache-redis.git"
16+
name = local.name
17+
family = local.family
18+
node_type = local.node_type
19+
environment = local.environment
20+
engine_version = local.redis_engine_version
21+
num_cache_nodes = 2
22+
vpc_id = local.vpc_id
23+
subnets = local.subnet_ids
24+
kms_key_arn = local.kms_key_arn
25+
multi_az_enabled = false
26+
availability_zones = 2
27+
snapshot_window = "07:00-08:00"
28+
maintenance_window = "sun:09:00-sun:10:00"
29+
allowed_security_groups = local.allowed_security_groups
3330
}
34-

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
locals {
42
tags = {
53
Environment = var.environment
@@ -8,6 +6,8 @@ locals {
86
engine_log = var.engine_log_destination == null ? [] : [1]
97
}
108

9+
data "aws_availability_zones" "available" {}
10+
1111
resource "random_password" "password" {
1212
length = 16
1313
special = false
@@ -40,7 +40,7 @@ resource "aws_elasticache_replication_group" "redis" {
4040
parameter_group_name = join("", aws_elasticache_parameter_group.default.*.name) #var.parameter_group_name
4141
security_group_ids = [module.security_group_redis.security_group_id]
4242
subnet_group_name = aws_elasticache_subnet_group.elasticache.id
43-
availability_zones = var.availability_zones
43+
availability_zones = [for n in range(0, var.availability_zones) : data.aws_availability_zones.available.names[n]]
4444
automatic_failover_enabled = var.automatic_failover_enabled
4545
snapshot_window = var.snapshot_window
4646
snapshot_retention_limit = var.snapshot_retention_limit

variables.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ variable "port" {
5757

5858
variable "automatic_failover_enabled" {
5959
description = "Enable automatic failover "
60-
default = false
60+
default = true
6161
type = bool
6262
}
6363

@@ -69,9 +69,9 @@ variable "multi_az_enabled" {
6969

7070

7171
variable "availability_zones" {
72-
description = "The list of AZs"
73-
default = []
74-
type = list(string)
72+
description = "The no. of AZs"
73+
default = 2
74+
type = string
7575
}
7676

7777
variable "snapshot_window" {
@@ -82,7 +82,7 @@ variable "snapshot_window" {
8282

8383
variable "snapshot_retention_limit" {
8484
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"
85-
default = 0
85+
default = 7
8686
type = number
8787
}
8888

0 commit comments

Comments
 (0)