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

Add name attribute to outputs.tf to allow easy composite alarm creation #75

Open
swirle13 opened this issue Mar 6, 2025 · 0 comments
Open

Comments

@swirle13
Copy link

swirle13 commented Mar 6, 2025

Is your request related to a new offering from AWS?

Is this functionality available in the AWS provider for Terraform? See CHANGELOG.md, too.

  • Yes ✅: please list the AWS provider version which introduced this functionality

v3.24.0

Is your request related to a problem? Please describe.

I'm attempting to create a composite alarm from multiple cloudwatch metric alarms. Terraform documentation shows the way to insert these values like so:

resource "aws_cloudwatch_composite_alarm" "example" {
  alarm_description = "This is a composite alarm!"
  alarm_name        = "example-composite-alarm"

  ...

  alarm_rule = <<EOF
ALARM(${aws_cloudwatch_metric_alarm.alpha.alarm_name}) OR
ALARM(${aws_cloudwatch_metric_alarm.bravo.alarm_name})
EOF

...
}

where each alarm is referenced by its name. I am unable to reference the name of each alarm that I've created via /modules/metric-alarm as it only has outputs cloudwatch_metric_alarm_arn and cloudwatch_metric_alarm_id

Describe the solution you'd like.

When creating multiple cloudwatch metric alarms, I would like to be able to reference them in creation of the composite alarm.

module "metric_alarm1" {
  source  = "myrepo/modules/metric-alarm"
  version = "0.0.2"

  alarm_name        = "alarm1"
  ...
}

module "metric_alarm2" {
  source  = "myrepo/modules/metric-alarm"
  version = "0.0.2"

  alarm_name        = "alarm2"
  ...
}

module "composite_alarm" {
  source  = "myrepo/modules/composite-alarm"
  version = "0.0.2"
  ...
  alarm_rule = <<EOF
ALARM(${module.metric_alarm1.alarm_name}) OR
ALARM(${module.metric_alarm2.alarm_name})
EOF

}

Describe alternatives you've considered.

Currently, I have to not use the metrics-alarm submodule and use TF resource aws_cloudwatch_metric_alarm directly in order to reference cloudwatch metric alarm name.

Additional context

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

No branches or pull requests

1 participant