Skip to content

Commit

Permalink
Merge pull request #1 from Mehdikarimian/develop
Browse files Browse the repository at this point in the history
initiate version
  • Loading branch information
Mehdikarimian committed Apr 23, 2022
2 parents d21245c + 93475aa commit 887ac5b
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 0 deletions.
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
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.
26 changes: 26 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
resource "aws_elasticache_subnet_group" "default" {
name = "${var.namespace}-redis-subnet"
subnet_ids = var.subnet_ids

tags = var.tags

}

resource "aws_elasticache_replication_group" "default" {
replication_group_id = var.cluster_id
replication_group_description = var.cluster_description
security_group_ids = [aws_security_group.redis-security-group.id]
node_type = var.node_type
port = var.port
parameter_group_name = var.parameter_group_name

subnet_group_name = aws_elasticache_subnet_group.default.name
automatic_failover_enabled = var.automatic_failover_enabled

cluster_mode {
replicas_per_node_group = var.replicas_per_node_group
num_node_groups = var.node_groups
}

tags = var.tags
}
15 changes: 15 additions & 0 deletions output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "primary_endpoint_address" {
value = "${aws_elasticache_replication_group.default.primary_endpoint_address}"
}

output "arn" {
value = aws_elasticache_subnet_group.default.arn
}

output "configuration_endpoint_address" {
value = aws_elasticache_replication_group.default.configuration_endpoint_address
}

output "security_group_arn" {
value = aws_security_group.redis-security-group.arn
}
21 changes: 21 additions & 0 deletions security-groups.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# this security group for ecs - Traffic to the ECS cluster should only come from the ALB
resource "aws_security_group" "redis-security-group" {
name = var.security_group_name
vpc_id = var.vpc_id

ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}

tags = var.tags
}
56 changes: 56 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
variable "namespace" {
}

variable "node_groups" {
description = "Number of nodes groups to create in the"
default = 1
}

variable "cluster_id" {
description = "cluster name"
default = "redis-cluster"
}

variable "cluster_description" {
description = "cluster description"
default = ""
}

variable "port" {
description = "running port"
default = 6379
}

variable "automatic_failover_enabled" {
description = ""
default = true
}

variable "security_group_name" {
description = "redis security group name"
}

variable "replicas_per_node_group" {
description = "number of replicas run per node group"
}

variable "parameter_group_name" {
description = "parameter group name"
}

variable "node_type" {
description = "node type"
}

variable "subnet_ids" {
description = "subnets"
}

variable "vpc_id" {
description = "vpc id"
}

variable "tags" {
description = "tags"
type = map(string)
}
10 changes: 10 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 0.14.9"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
}

0 comments on commit 887ac5b

Please sign in to comment.