File tree 6 files changed +99
-4
lines changed
6 files changed +99
-4
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,13 @@ and the inline policy for the aim user terraform-bot-account
88
88
89
89
## deploy the infrastructure
90
90
91
+ Ensure the environment variables are loaded in your terminal sessions and that you are in the terraform directory.
92
+ Then simply type:
93
+ ```
94
+ make apply
95
+ ```
96
+
97
+ Warning: creating the redis cluster can take a significant amount of time (> 5 minutes). Just be patient and let it finish.
91
98
92
99
## useful commands for testing the infrastructure
93
100
Original file line number Diff line number Diff line change @@ -33,14 +33,16 @@ show:
33
33
terraform show
34
34
35
35
output :
36
- @echo " *** DOCKERNODES ***"
36
+ @echo " \n *** DOCKERNODES ***"
37
37
@terraform output --module=dockernodes
38
- @echo " *** LOADBALANCERS ***"
38
+ @echo " \n *** LOADBALANCERS ***"
39
39
@terraform output --module=loadbalancers
40
- @echo " *** MONGONODES *** "
40
+ @echo " \n *** MONGONODES *** "
41
41
@terraform output --module=mongodbnodes
42
- @echo " *** VPC ***"
42
+ @echo " \n *** VPC ***"
43
43
@terraform output --module=vpc
44
+ @echo " \n*** Redis ***"
45
+ @terraform output --module=rediscluster
44
46
45
47
ping :
46
48
ansible -i bin/terraform.py/terraform.py -m ping all
Original file line number Diff line number Diff line change @@ -54,3 +54,19 @@ module "mongodbnodes" {
54
54
default_sg_id = " ${ module . vpc . default_sg_id } "
55
55
subnet_id_zones = " ${ module . vpc . subnet_id_zones } "
56
56
}
57
+
58
+ module "rediscluster" {
59
+ source = " ./redis"
60
+
61
+ env = " ${ var . env } "
62
+ region = " ${ var . region } "
63
+ vpc_id = " ${ module . vpc . vpc_id } "
64
+ vpc_private_cidr = " ${ module . vpc . vpc_private_cidr } "
65
+ subnet_id_zones = " ${ module . vpc . subnet_id_zones } "
66
+
67
+ cache_name = " redis-cache"
68
+ engine_version = " 2.8.22"
69
+ instance_type = " cache.t2.micro"
70
+ maintenance_window = " sun:05:00-sun:06:00"
71
+
72
+ }
Original file line number Diff line number Diff line change
1
+ output "cache_security_group_id" {
2
+ value = " ${ aws_security_group . redis . id } "
3
+ }
4
+
5
+ output "hostname" {
6
+ value = " ${ aws_elasticache_cluster . redis . cache_nodes . 0 . address } "
7
+ }
8
+
9
+ output "port" {
10
+ value = " ${ aws_elasticache_cluster . redis . cache_nodes . 0 . port } "
11
+ }
12
+
13
+ output "endpoint" {
14
+ value = " ${ format (" %s:%s" , aws_elasticache_cluster. redis . cache_nodes . 0 . address , aws_elasticache_cluster. redis . cache_nodes . 0 . port )} "
15
+ }
Original file line number Diff line number Diff line change
1
+ resource "aws_security_group" "redis" {
2
+ name = " redis_security_group"
3
+ description = " Allowing access to redis cluster"
4
+ vpc_id = " ${ var . vpc_id } "
5
+
6
+ }
7
+
8
+ resource "aws_elasticache_cluster" "redis" {
9
+ cluster_id = " ${ var . cache_name } "
10
+ engine = " redis"
11
+ engine_version = " ${ var . engine_version } "
12
+ maintenance_window = " ${ var . maintenance_window } "
13
+ node_type = " ${ var . instance_type } "
14
+ num_cache_nodes = " 1"
15
+ parameter_group_name = " default.redis2.8"
16
+ port = " 6379"
17
+ subnet_group_name = " ${ aws_elasticache_subnet_group . default . name } "
18
+ security_group_ids = [" ${ aws_security_group . redis . id } " ]
19
+
20
+ tags {
21
+ Name = " CacheCluster"
22
+ env = " ${ var . env } "
23
+ role = " redisnode"
24
+ Name = " ${ format (" redis-%02d" , count. index + 1 )} "
25
+ }
26
+ }
27
+
28
+ resource "aws_elasticache_subnet_group" "default" {
29
+ name = " ${ var . cache_name } -subnet-group"
30
+ description = " Private subnets for the ElastiCache instances"
31
+ subnet_ids = [" ${ var . subnet_id_zones } " ]
32
+ }
33
+
34
+
Original file line number Diff line number Diff line change
1
+ variable "env" {}
2
+ variable "region" {}
3
+
4
+ variable "vpc_id" {}
5
+ variable "vpc_private_cidr" {}
6
+ variable "subnet_id_zones" {
7
+ type = " list"
8
+ }
9
+ variable "cache_name" {}
10
+
11
+ variable "engine_version" {
12
+ default = " 2.8.22"
13
+ }
14
+
15
+ variable "instance_type" {
16
+ default = " cache.t2.micro"
17
+ }
18
+
19
+ variable "maintenance_window" {
20
+ default = " sun:05:00-sun:06:00"
21
+ }
You can’t perform that action at this time.
0 commit comments