Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tf_mod_aws_elasticache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
steamhaus
tf_mod_aws_elasticache
Commits
8e140c99
Commit
8e140c99
authored
Oct 20, 2016
by
A-Gordon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
147 additions
and
0 deletions
+147
-0
.gitlab-ci.yml
.gitlab-ci.yml
+12
-0
main.tf
main.tf
+135
-0
No files found.
.gitlab-ci.yml
0 → 100644
View file @
8e140c99
image
:
alpine:latest
variables
:
TERRAFORM_URL
:
"
https://releases.hashicorp.com/terraform/0.7.1/terraform_0.7.1_linux_amd64.zip"
before_script
:
-
apk update && apk add ca-certificates && update-ca-certificates && apk add openssl
-
wget -O /tmp/terraform.zip $TERRAFORM_URL
-
unzip /tmp/terraform.zip -d /usr/local/bin
test
:
script
:
terraform validate
main.tf
0 → 100644
View file @
8e140c99
#############################################################################################################
# Variables
#############################################################################################################
variable
"vpc_id"
{}
variable
"security_groups"
{
type
=
"list"
}
variable
"subnet_ids"
{
type
=
"list"
}
variable
"cache_name"
{}
variable
"cache_nodes"
{
default
=
"2"
}
variable
"az_mode"
{
default
=
"cross-az"
}
variable
"engine_version"
{
default
=
"1.4.24"
}
variable
"instance_type"
{
default
=
"cache.t2.micro"
}
variable
"port"
{
default
=
"11211"
}
variable
"maintenance_window"
{
default
=
"sun:01:00-sun:02:00"
}
variable
"dns_zone"
{}
# variable "alarm_actions" {}
############################################################################################################
# Security Group
#############################################################################################################
resource
"aws_security_group"
"memcached"
{
vpc_id
=
"
${
var
.
vpc_id
}
"
description
=
"ElastiCache SG"
ingress
{
from_port
=
11211
to_port
=
11211
protocol
=
"tcp"
security_groups
=
[
"
${
var
.
security_groups
}
"
]
}
tags
=
{
Name
=
"
${
var
.
cache_name
}
"
}
}
############################################################################################################
# Subnet Group
#############################################################################################################
resource
"aws_elasticache_subnet_group"
"default"
{
name
=
"
${
var
.
cache_name
}
-subnet-group"
description
=
"Private subnets for the ElastiCache instances"
subnet_ids
=
[
"
${
var
.
subnet_ids
}
"
]
}
############################################################################################################
# Elasticache Cluster
#############################################################################################################
resource
"aws_elasticache_cluster"
"memcached"
{
cluster_id
=
"
${
var
.
cache_name
}
"
engine
=
"memcached"
engine_version
=
"
${
var
.
engine_version
}
"
maintenance_window
=
"
${
var
.
maintenance_window
}
"
node_type
=
"
${
var
.
instance_type
}
"
num_cache_nodes
=
"
${
var
.
cache_nodes
}
"
az_mode
=
"
${
var
.
az_mode
}
"
parameter_group_name
=
"default.memcached1.4"
port
=
"
${
var
.
port
}
"
subnet_group_name
=
"
${
aws_elasticache_subnet_group
.
default
.
name
}
"
security_group_ids
=
[
"
${
aws_security_group
.
memcached
.
id
}
"
]
tags
{
Name
=
"CacheCluster"
}
}
############################################################################################################
# Route53 record
#############################################################################################################
resource
"aws_route53_record"
"memcached"
{
zone_id
=
"
${
var
.
dns_zone
}
"
name
=
"cache.cfg.
${
var
.
cache_name
}
.aws"
type
=
"CNAME"
ttl
=
"60"
records
=
[
"
${
aws_elasticache_cluster
.
memcached
.
cluster_address
}
"
]
}
############################################################################################################
# Cloudwatch resources
#############################################################################################################
resource
"aws_cloudwatch_metric_alarm"
"cpu"
{
alarm_name
=
"alarmCacheClusterCPUUtilization"
alarm_description
=
"Cache cluster CPU utilization"
comparison_operator
=
"GreaterThanThreshold"
evaluation_periods
=
"1"
metric_name
=
"CPUUtilization"
namespace
=
"AWS/ElastiCache"
period
=
"300"
statistic
=
"Average"
threshold
=
"75"
dimensions
{
CacheClusterId
=
"
${
aws_elasticache_cluster
.
memcached
.
id
}
"
}
# alarm_actions = ["${split(",", var.alarm_actions)}"]
}
resource
"aws_cloudwatch_metric_alarm"
"memory_free"
{
alarm_name
=
"alarmCacheClusterFreeableMemory"
alarm_description
=
"Cache cluster freeable memory"
comparison_operator
=
"LessThanThreshold"
evaluation_periods
=
"1"
metric_name
=
"FreeableMemory"
namespace
=
"AWS/ElastiCache"
period
=
"60"
statistic
=
"Average"
# 10MB in bytes
threshold
=
"10000000"
dimensions
{
CacheClusterId
=
"
${
aws_elasticache_cluster
.
memcached
.
id
}
"
}
# alarm_actions = ["${split(",", var.alarm_actions)}"]
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment