1+ # ###----------------------------------------------------------------------------------
2+ # # Provider block added, Use the Amazon Web Services (AWS) provider to interact with the many resources supported by AWS.
3+ # ###----------------------------------------------------------------------------------
14provider "aws" {
25 region = " eu-west-1"
36}
47
8+ # ###----------------------------------------------------------------------------------
9+ # # A VPC is a virtual network that closely resembles a traditional network that you'd operate in your own data center.
10+ # ###----------------------------------------------------------------------------------
511module "vpc" {
612 source = " clouddrove/vpc/aws"
7- version = " 1.3.0 "
13+ version = " 1.3.1 "
814
915 name = " vpc"
1016 environment = " test"
11- label_order = [" name " , " environment " ]
17+ label_order = [" environment " , " name " ]
1218
13- cidr_block = " 172.16 .0.0/16"
19+ cidr_block = " 10.0 .0.0/16"
1420}
1521
22+ # ###----------------------------------------------------------------------------------
23+ # # A subnet is a range of IP addresses in your VPC.
24+ # ###----------------------------------------------------------------------------------
1625module "subnets" {
1726 source = " clouddrove/subnet/aws"
1827 version = " 1.3.0"
1928
2029 name = " subnets"
2130 environment = " test"
22- label_order = [" name " , " environment " ]
31+ label_order = [" environment " , " name " ]
2332 availability_zones = [" eu-west-1a" , " eu-west-1b" , " eu-west-1c" ]
2433 vpc_id = module. vpc . vpc_id
2534 type = " public"
@@ -28,76 +37,49 @@ module "subnets" {
2837 ipv6_cidr_block = module. vpc . ipv6_cidr_block
2938}
3039
31- module "redis-sg" {
32- source = " clouddrove/security-group/aws"
33- version = " 1.3.0"
40+ # ###----------------------------------------------------------------------------------
41+ # # Amazon ElastiCache [REDIS-CLUSTER] is a fully managed in-memory data store and cache service by Amazon Web Services.
42+ # # The service improves the performance of web applications by retrieving information from managed in-memory caches,
43+ # # instead of relying entirely on slower disk-based databases.
44+ # ###----------------------------------------------------------------------------------
45+ module "redis-cluster" {
46+ source = " ./../../"
3447
35- name = " redis-sg "
48+ name = " redis-cluster "
3649 environment = " test"
37- label_order = [" name " , " environment " ]
50+ label_order = [" environment " , " name " ]
3851
52+ # ###----------------------------------------------------------------------------------
53+ # # Below A security group controls the traffic that is allowed to reach and leave the resources that it is associated with.
54+ # ###----------------------------------------------------------------------------------
3955 vpc_id = module. vpc . vpc_id
4056 allowed_ip = [module . vpc . vpc_cidr_block ]
4157 allowed_ports = [6379 ]
42- }
43-
44- module "kms_key" {
45- source = " clouddrove/kms/aws"
46- version = " 1.3.0"
47-
48- name = " kms"
49- environment = " test"
50- label_order = [" name" , " environment" ]
51-
52- enabled = true
53-
54- description = " KMS key for aurora"
55- alias = " alias/redis-cluster"
56- key_usage = " ENCRYPT_DECRYPT"
57- customer_master_key_spec = " SYMMETRIC_DEFAULT"
58- deletion_window_in_days = 7
59- is_enabled = true
60- policy = data. aws_iam_policy_document . default . json
61- }
62-
63- data "aws_iam_policy_document" "default" {
64- version = " 2012-10-17"
65-
66- statement {
67- sid = " Enable IAM User Permissions"
68- effect = " Allow"
69- principals {
70- type = " AWS"
71- identifiers = [" *" ]
72- }
73- actions = [" kms:*" ]
74- resources = [" *" ]
75- }
76- }
77-
78- module "redis-cluster" {
79- source = " ./../../"
80-
81- name = " cluster"
82- environment = " test"
83- label_order = [" name" , " environment" ]
8458
59+ # ###----------------------------------------------------------------------------------
60+ # # will create ROUTE-53 for redis which will add the dns of the cluster.
61+ # ###----------------------------------------------------------------------------------
8562 cluster_replication_enabled = true
8663 engine = " redis"
8764 engine_version = " 7.0"
8865 parameter_group_name = " default.redis7.cluster.on"
8966 port = 6379
9067 node_type = " cache.t2.micro"
91- kms_key_id = module. kms_key . key_arn
9268 subnet_ids = module. subnets . public_subnet_id
93- security_group_ids = [module . redis-sg . security_group_ids ]
9469 availability_zones = [" eu-west-1a" , " eu-west-1b" ]
95- auto_minor_version_upgrade = true
9670 replicas_per_node_group = 2
97- num_node_groups = 1
71+ num_cache_nodes = 1
9872 snapshot_retention_limit = 7
9973 automatic_failover_enabled = true
10074 extra_tags = {
10175 Application = " CloudDrove"
10276 }
77+
78+ # ###----------------------------------------------------------------------------------
79+ # # will create ROUTE-53 for redis which will add the dns of the cluster.
80+ # ###----------------------------------------------------------------------------------
81+ dns_record_name = " prod"
82+ route53_ttl = " 300"
83+ route53_type = " CNAME"
84+ route53_zone_id = " Z0xxxx16XCxxxxxxx4"
10385}
0 commit comments