|
| 1 | +# |
| 2 | +# Security group resources |
| 3 | +# |
| 4 | + |
| 5 | +resource "aws_security_group" "redis" { |
| 6 | + vpc_id = "${var.vpc_id}" |
| 7 | + |
| 8 | + tags { |
| 9 | + name = "${var.tag_name}" |
| 10 | + description = "${var.tag_description}" |
| 11 | + environment = "${var.tag_environment}" |
| 12 | + creator = "${var.tag_creator}" |
| 13 | + customer = "${var.tag_customer}" |
| 14 | + owner = "${var.tag_owner}" |
| 15 | + product = "${var.tag_product}" |
| 16 | + costcenter = "${var.tag_costcenter}" |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +# |
| 21 | +# ElastiCache resources |
| 22 | +# |
| 23 | + |
| 24 | +resource "aws_elasticache_subnet_group" "default" { |
| 25 | + name = "subnet-group-${var.tag_customer}-${var.tag_product}-${var.tag_environment}" |
| 26 | + description = "Private subnets for the ElastiCache instances: ${var.tag_customer} ${var.tag_product} ${var.tag_environment}" |
| 27 | + subnet_ids = ["${split(",", var.private_subnet_ids)}"] |
| 28 | +} |
| 29 | + |
| 30 | +resource "aws_elasticache_cluster" "redis" { |
| 31 | + cluster_id = "${var.tag_customer}-${var.tag_product}-${var.tag_environment}" |
| 32 | + engine = "redis" |
| 33 | + engine_version = "${var.engine_version}" |
| 34 | + maintenance_window = "${var.maintenance_window}" |
| 35 | + node_type = "${var.instance_type}" |
| 36 | + num_cache_nodes = "1" |
| 37 | + parameter_group_name = "default.redis2.8" |
| 38 | + port = "6379" |
| 39 | + subnet_group_name = "${aws_elasticache_subnet_group.default.name}" |
| 40 | + security_group_ids = ["${aws_security_group.redis.id}"] |
| 41 | + |
| 42 | + tags { |
| 43 | + name = "${var.tag_name}" |
| 44 | + description = "${var.tag_description}" |
| 45 | + environment = "${var.tag_environment}" |
| 46 | + creator = "${var.tag_creator}" |
| 47 | + customer = "${var.tag_customer}" |
| 48 | + owner = "${var.tag_owner}" |
| 49 | + product = "${var.tag_product}" |
| 50 | + costcenter = "${var.tag_costcenter}" |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +# |
| 55 | +# todo: add CloudWatch resources |
| 56 | +# |
0 commit comments