Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to be terraform .12 compatible & other changes #21

Closed
wants to merge 34 commits into from

Conversation

caleb15
Copy link

@caleb15 caleb15 commented Jul 2, 2020

  • Upgrades code to be terraform .12 compatible fixes update to be hcl2 compliant #16
  • Makes alarm names unique fixes alarm names should be unique #5
  • Breaking change: requires sns topic param instead of creating one for the user. The user may already have a prexisting SNS topic that they might want to use. The repo should just concern itself with alarms and not with SNS.
  • Breaking change: db_instance_id changed to db_instance_ids to support multiple db's
  • add alarm_period and alarm_evaluation_periods params

We are running this change in production for 15Five.

@jamengual
Copy link

jamengual commented Jul 2, 2020

It shouldn't be assumed that it's okay to create a new topic - the user might want to reuse an existing sns topic for the RDS alarms. DEV-812

That is going to break other modules, could it be possible for you to use

count = length(var.aws_sns_topic_arn) != 0 ? 1 : 0

to the topics so that if there is no var.aws_sns_topic_arn supplied it created one for you?

thanks

@caleb15
Copy link
Author

caleb15 commented Jul 7, 2020

@jamengual Yeah, that should be possible. But either way the PR will still have a breaking change with the db instance id param.

I'm going to wait for a maintainer to respond to see what changes would be necessary to merge this in.

@jamengual
Copy link

for the breaking changes I think is possible to maybe leave them empty or use a dynamic.

@nitrocode
Copy link
Member

To make this easier to review, could you put these changes in separate PRs?

We should at the very least have a separate PR for terraform11 to terraform12 changes to make this easier to review.

@osterman osterman requested a review from 3h4x July 7, 2020 17:24
Copy link

@3h4x 3h4x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @caleb15 ! Thank you very much for PR.
These are great changes. I'm in favour of removing SNS topic creation without any backward compatibility. It should be fairly easy to migrate to new version thanks to variable aws_sns_topic_arn. In @cloudposse/contributors we are working on SNS module (initial PR already pushed) that should be used in conjunction with any CloudWatch alarm module.
Additionally it's a good change to monitor multiple RDS instances with this single module. We can avoid backward incompatibilty by reducing readablity of code and by having tech debt. Let's avoid that.
I left couple of questions and few improvements.

PS: I'm going to push pre-commit to this repo for tf fmt and other lints. Please merge it to your PR when it's done.


source_type = "db-instance"
source_ids = ["${var.db_instance_id}"]
source_ids = var.db_instance_ids

event_categories = [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason behind removing other categories?
I think it would be best to preserve previous list as a default. To customize you can create event_categories variable of list(string) type.

default = 64
}

variable "freeable_memory_threshold" {
description = "The minimum amount of available random access memory in Byte."
type = "string"
type = string
default = 64000000

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line

resource "aws_sns_topic" "default" {
name_prefix = "rds-threshold-alerts"
}

resource "aws_db_event_subscription" "default" {
name_prefix = "rds-event-sub"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely we need a name prefix so all resources with names created by this module are aligned. Additionally I think rds-sns-alarms is more telling.

Suggested change
name_prefix = "rds-event-sub"
name_prefix = "${var.name_prefix}rds-sns-alarms"

}

variable "aws_sns_topic_arn" {
description = "The bla of the SNS topic you want to use for alerting"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The bla"? I guess you mean ARN

metric_name = "BurstBalance"
namespace = "AWS/RDS"
period = "600"
period = var.period
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit = "Percent"

metric_name = "DiskQueueDepth"
namespace = "AWS/RDS"
period = "600"
period = var.period
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit = "Count"

metric_name = "FreeableMemory"
namespace = "AWS/RDS"
period = "600"
period = var.period
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit = "Bytes"

metric_name = "FreeStorageSpace"
namespace = "AWS/RDS"
period = "600"
period = var.period
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit = "Bytes"

metric_name = "SwapUsage"
namespace = "AWS/RDS"
period = "600"
period = var.period
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit = "Bytes"

alarms.tf Outdated
alarm_actions = ["${aws_sns_topic.default.arn}"]
ok_actions = ["${aws_sns_topic.default.arn}"]
threshold = local.thresholds["BurstBalanceThreshold"]
alarm_description = "Average database storage burst balance over last ${var.period/60} minutes too low, expect a significant performance drop soon"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add db_instance_id to every alarm_description.

@3h4x 3h4x self-assigned this Jul 9, 2020
@caleb15
Copy link
Author

caleb15 commented Sep 15, 2020

Sorry for the delay on responding to the PR review, I've created a ticket so I remember to get to it eventually. It might be a while. Thanks for the review!

@macnibblet
Copy link

@caleb15 Any chance we might see an update :)?

@caleb15
Copy link
Author

caleb15 commented Oct 27, 2020

@macnibblet yes, but it may take a while 🙈 I have the email starred in my inbox along with 30 others.

adamantike added a commit to adamantike/terraform-aws-rds-cloudwatch-sns-alarms that referenced this pull request Nov 20, 2020
caleb15 and others added 4 commits January 3, 2021 12:13
this module is just for alarms
we know it applies to alarms already so no need to state it
* Added rapid increase space alert

* add rds free storage space alert

* fix alarm variable value

* add anomoly detection metric query

Co-authored-by: jamesjsanders <[email protected]>
}
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why all this have to be deleted?

@Gowiem Gowiem requested a review from maximmi February 27, 2021 18:09
@tovbinm
Copy link

tovbinm commented Apr 15, 2021

@caleb15 how far are you from finishing this one up?

@adamantike
Copy link

Also waiting for this PR to be merged, to stop using a fork of this repo!

@Gowiem
Copy link
Member

Gowiem commented Apr 15, 2021

@maximmi are you still the owning migration to 0.12 PRs? Any chance you could check this one out?

@maximmi maximmi self-assigned this Apr 20, 2021
Copy link

@maximmi maximmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caleb15 thank you for contribution
we have our standards for Terraform 0.12+ code, so that tests and github workflows should be in place. It might be hard to implement such things by you, so I will try to update your PR to respect all requirements.
For the reference you could pick any our repo with terraform 0.12+ support, for example: https://github.com/cloudposse/terraform-aws-s3-bucket

@mergify
Copy link

mergify bot commented Jun 17, 2021

This pull request is now in conflict. Could you fix it @caleb15? 🙏

@hans-d hans-d closed this Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update to be hcl2 compliant alarm names should be unique