Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
terraform-aws-elasticache-redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Terraform Modules
terraform-aws-elasticache-redis
Commits
ec14fecb
Unverified
Commit
ec14fecb
authored
Aug 25, 2020
by
Varun Palekar
Committed by
GitHub
Aug 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix cloudwatch alarm failure to create (#56) (#77)
parent
f727ef5d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
main.tf
main.tf
+15
-6
No files found.
main.tf
View file @
ec14fecb
...
@@ -54,6 +54,15 @@ resource "aws_security_group_rule" "ingress_cidr_blocks" {
...
@@ -54,6 +54,15 @@ resource "aws_security_group_rule" "ingress_cidr_blocks" {
locals
{
locals
{
elasticache_subnet_group_name
=
var
.
elasticache_subnet_group_name
!
=
""
?
var
.
elasticache_subnet_group_name
:
join
(
""
,
aws_elasticache_subnet_group
.
default
.*.
name
)
elasticache_subnet_group_name
=
var
.
elasticache_subnet_group_name
!
=
""
?
var
.
elasticache_subnet_group_name
:
join
(
""
,
aws_elasticache_subnet_group
.
default
.*.
name
)
# if !cluster, then node_count = replica cluster_size, if cluster then node_count = shard*(replica + 1)
# Why doing this 'The "count" value depends on resource attributes that cannot be determined until apply'. So pre-calculating
member_clusters_count
=
(
var
.
cluster_mode_enabled
?
(
var
.
cluster_mode_num_node_groups
*
(
var
.
cluster_mode_replicas_per_node_group
+
1
))
:
var
.
cluster_size
)
elasticache_member_clusters
=
var
.
enabled
?
tolist
(
aws_elasticache_replication_group
.
default
.
0
.
member_clusters
)
:
[]
}
}
resource
"aws_elasticache_subnet_group"
"default"
{
resource
"aws_elasticache_subnet_group"
"default"
{
...
@@ -118,8 +127,8 @@ resource "aws_elasticache_replication_group" "default" {
...
@@ -118,8 +127,8 @@ resource "aws_elasticache_replication_group" "default" {
# CloudWatch Resources
# CloudWatch Resources
#
#
resource
"aws_cloudwatch_metric_alarm"
"cache_cpu"
{
resource
"aws_cloudwatch_metric_alarm"
"cache_cpu"
{
count
=
var
.
enabled
?
1
:
0
count
=
var
.
enabled
?
local
.
member_clusters_count
:
0
alarm_name
=
"
${
module
.
label
.
id
}
-cpu-utilization"
alarm_name
=
"
${
element
(
local
.
elasticache_member_clusters
,
count
.
index
)
}
-cpu-utilization"
alarm_description
=
"Redis cluster CPU utilization"
alarm_description
=
"Redis cluster CPU utilization"
comparison_operator
=
"GreaterThanThreshold"
comparison_operator
=
"GreaterThanThreshold"
evaluation_periods
=
"1"
evaluation_periods
=
"1"
...
@@ -131,7 +140,7 @@ resource "aws_cloudwatch_metric_alarm" "cache_cpu" {
...
@@ -131,7 +140,7 @@ resource "aws_cloudwatch_metric_alarm" "cache_cpu" {
threshold
=
var
.
alarm_cpu_threshold_percent
threshold
=
var
.
alarm_cpu_threshold_percent
dimensions
=
{
dimensions
=
{
CacheClusterId
=
module
.
label
.
id
CacheClusterId
=
element
(
local
.
elasticache_member_clusters
,
count
.
index
)
}
}
alarm_actions
=
var
.
alarm_actions
alarm_actions
=
var
.
alarm_actions
...
@@ -140,8 +149,8 @@ resource "aws_cloudwatch_metric_alarm" "cache_cpu" {
...
@@ -140,8 +149,8 @@ resource "aws_cloudwatch_metric_alarm" "cache_cpu" {
}
}
resource
"aws_cloudwatch_metric_alarm"
"cache_memory"
{
resource
"aws_cloudwatch_metric_alarm"
"cache_memory"
{
count
=
var
.
enabled
?
1
:
0
count
=
var
.
enabled
?
local
.
member_clusters_count
:
0
alarm_name
=
"
${
module
.
label
.
id
}
-freeable-memory"
alarm_name
=
"
${
element
(
local
.
elasticache_member_clusters
,
count
.
index
)
}
-freeable-memory"
alarm_description
=
"Redis cluster freeable memory"
alarm_description
=
"Redis cluster freeable memory"
comparison_operator
=
"LessThanThreshold"
comparison_operator
=
"LessThanThreshold"
evaluation_periods
=
"1"
evaluation_periods
=
"1"
...
@@ -153,7 +162,7 @@ resource "aws_cloudwatch_metric_alarm" "cache_memory" {
...
@@ -153,7 +162,7 @@ resource "aws_cloudwatch_metric_alarm" "cache_memory" {
threshold
=
var
.
alarm_memory_threshold_bytes
threshold
=
var
.
alarm_memory_threshold_bytes
dimensions
=
{
dimensions
=
{
CacheClusterId
=
module
.
label
.
id
CacheClusterId
=
element
(
local
.
elasticache_member_clusters
,
count
.
index
)
}
}
alarm_actions
=
var
.
alarm_actions
alarm_actions
=
var
.
alarm_actions
...
...
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