Skip to content

Commit 0f3864d

Browse files
committed
initial commit
1 parent 9930131 commit 0f3864d

File tree

11 files changed

+287
-0
lines changed

11 files changed

+287
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ override.tf.json
2727

2828
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
2929
# example: *tfplan*
30+
31+
.idea/
32+
.terraform.lock.hcl

elasticache.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# NOTE: For working with Redis (Cluster Mode Enabled) replication groups, see the aws_elasticache_replication_group resource.
2+
3+
resource "aws_elasticache_cluster" "elasticache" {
4+
cluster_id = var.cluster_id == "" ? "${var.teamid}-${var.prjid}" : var.snapshot_name
5+
engine = var.engine
6+
node_type = var.node_type
7+
num_cache_nodes = var.cache_nodes
8+
parameter_group_name = var.parameter_group_name
9+
engine_version = var.engine_version
10+
port = var.port
11+
subnet_group_name = var.subnet_group_name
12+
security_group_ids = var.security_group_ids
13+
snapshot_arns = var.snapshot_arns == "" ? "[]" : var.snapshot_arns
14+
snapshot_name = var.snapshot_name == "" ? "${var.teamid}-${var.prjid}" : var.snapshot_name
15+
snapshot_window = var.snapshot_window == "" ? "null" : var.snapshot_window
16+
snapshot_retention_limit = var.snapshot_retention_limit == "" ? "null" : var.snapshot_retention_limit
17+
az_mode = var.az_mode == "" ? "null" : var.az_mode
18+
availability_zone = var.availability_zone
19+
tags = merge(local.shared_tags)
20+
notification_topic_arn = var.notification_topic_arn == "" ? "null" : var.notification_topic_arn
21+
apply_immediately = var.apply_immediately == "" ? "true" : var.apply_immediately
22+
}

example/base/elasticache.tf

Whitespace-only changes.

example/base/main.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module "efs" {
2+
source = "../../.."
3+
4+
teamid = var.teamid
5+
prjid = var.prjid
6+
email = var.email
7+
profile_to_use = var.profile_to_use
8+
cluster_identifier = var.cluster_identifier
9+
engine = var.engine
10+
node_type = var.node_type
11+
num_cache_nodes = var.cache_nodes
12+
parameter_group_name = var.parameter_group_name
13+
engine_version = var.engine_version
14+
port = var.port
15+
subnet_group_name = var.subnet_group_name
16+
security_group_ids = var.security_group_ids
17+
snapshot_window = var.snapshot_window
18+
snapshot_retention_limit = var.snapshot_retention_limit
19+
availability_zone = var.availability_zone
20+
}

example/base/remote_backend.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file is generated by the tf wrapper script to configure the remote backend.
2+
# This is used by Terraform v0.9.0+ and is NOT compatible with older versions.
3+
# Do not edit or delete!
4+
5+
terraform { backend "s3" {} }

example/base/variables.tf

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Additional documentation: https://www.terraform.io/docs/configuration/variables.html
2+
variable "email" {
3+
description = "email address to be used for tagging (suggestion: use group email address)"
4+
}
5+
6+
variable "teamid" {
7+
description = "(Required) Name of the team/group e.g. devops, dataengineering. Should not be changed after running 'tf apply'"
8+
}
9+
10+
variable "prjid" {
11+
description = "(Required) Name of the project/stack e.g: mystack, nifieks, demoaci. Should not be changed after running 'tf apply'"
12+
}
13+
14+
variable "cluster_identifier" {
15+
type = "string"
16+
description = "Identifier of new cluster"
17+
}
18+
19+
variable "node_type" {
20+
type = "string"
21+
description = "Type of node."
22+
}
23+
24+
variable "cache_nodes" {
25+
description = "Number of cache nodes"
26+
default = 1
27+
}
28+
29+
variable "parameter_group_name" {
30+
type = "string"
31+
description = "Name of parameter group."
32+
}
33+
34+
variable "engine_version" {
35+
type = "string"
36+
description = "Version of engine"
37+
}
38+
39+
variable "port" {
40+
description = "Port for cluster."
41+
default = 6379
42+
}
43+
44+
variable "subnet_group_name" {
45+
type = "string"
46+
description = "Name of subnet group."
47+
}
48+
49+
variable "security_group_ids" {
50+
type = "list"
51+
description = "List of security groups."
52+
}
53+
54+
variable "snapshot_window" {
55+
type = "string"
56+
description = "Time of day when snapshot will be taken."
57+
}
58+
59+
variable "snapshot_retention_limit" {
60+
description = "Number of days snapshot image will be retaind"
61+
default = 5
62+
}
63+
64+
variable "availability_zone" {
65+
type = "string"
66+
description = "Availability zone"
67+
}
68+
69+
variable "engine" {
70+
default = "redis"
71+
}
72+
73+
variable "profile_to_use" {
74+
description = "Getting values from ~/.aws/credentials"
75+
}
76+
77+
variable "aws_region" {
78+
default = "us-west-2"
79+
}

example/custom/sample.tfvars

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cluster_identifier = "terraformtestcluster"
2+
node_type = "cache.m4.large"
3+
cache_nodes = 1
4+
parameter_group_name = "default.redis3.2"
5+
engine_version = "3.2.10"
6+
port = 6379
7+
subnet_group_name = "test"
8+
security_group_ids = ["sg-xxxxxxxxxx"]
9+
snapshot_window = "05:00-09:00"
10+
snapshot_retention_limit = 5
11+
availability_zone = "us-west-2b"
12+
# ------------------------------------------------------------------
13+
# Note: Do not change teamid and prjid once set.
14+
teamid = "rumse"
15+
prjid = "demo-redis"

main.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
locals {
2+
shared_tags = map(
3+
"Name", "${var.teamid}-${var.prjid}",
4+
"Owner", var.email,
5+
"Team", var.teamid,
6+
"Project", var.prjid
7+
)
8+
}
9+
10+
module "global" {
11+
source = "./../../../../_base_module/aws"
12+
}
13+
14+
provider "aws" {
15+
region = var.aws_region
16+
profile = var.profile_to_use
17+
version = "~> 2.61"
18+
}
19+
20+
terraform {
21+
required_version = ">= 0.12"
22+
}

output.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
output "elasticache_id" {
2+
value = aws_elasticache_cluster.elasticache.id
3+
}
4+
5+
output "elasticache_snapshot_name" {
6+
value = aws_elasticache_cluster.elasticache.snapshot_name
7+
}
8+
9+
output "elasticache_cluster_address" {
10+
value = aws_elasticache_cluster.elasticache.cluster_address
11+
}

remote_backend.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file is generated by the tf wrapper script to configure the remote backend.
2+
# This is used by Terraform v0.9.0+ and is NOT compatible with older versions.
3+
# Do not edit or delete!
4+
5+
terraform { backend "s3" {} }

0 commit comments

Comments
 (0)