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

aws_cloudwatch_metric_alarm "arn:aws:automate:${var.region}:ec2:recover does not match regexp #6386

Closed
ghost opened this issue Nov 7, 2018 · 8 comments · Fixed by #6405
Closed
Labels
bug Addresses a defect in current functionality. service/cloudwatch Issues and PRs that pertain to the cloudwatch service.
Milestone

Comments

@ghost
Copy link

ghost commented Nov 7, 2018

This issue was originally opened by @klassm as hashicorp/terraform#19307. It was migrated here as a result of the provider split. The original body of the issue is below.


Hi there,
updating to the latest version of terraform 0.11.10 produced a new issue with our configuration. We are using an aws_cloudwatch_metric_alarm to trigger alarm actions for recover and reboot.

resource "aws_cloudwatch_metric_alarm" "auto_recovery_alarm" {
  count = "${length(var.availability_zones)}"

  alarm_name = "${var.env}-auto-recovery-${count.index}"
  comparison_operator = "LessThanThreshold"
  evaluation_periods = "1"
  metric_name = "ProxyHealth"
  namespace = "MyService"
  period = "60"
  statistic = "Minimum"
  threshold = "1"

  dimensions = {
    InstanceId = "${aws_instance.proxy.*.id[count.index]}"
    ProxyIp = "${aws_instance.proxy.*.private_ip[count.index]}"
  }

  alarm_actions = [
    "arn:aws:automate:${var.region}:ec2:recover",
    "arn:aws:automate:${var.region}:ec2:reboot"
  ]
}

This worked out just fine - however, in the latest version of terraform planning an execution plan breaks with

Error: module.service.module.proxy.aws_cloudwatch_metric_alarm.auto_recovery_alarm[0]: "alarm_actions.1" does not match EC2 automation ARN ("^arn:[\\w-]+:automate:[\\w-]+:ec2:(recover|stop|terminate)$"): "arn:aws:automate:eu-central-1:ec2:reboot"

Looking at the AWS API documentation, "arn:aws:automate:eu-central-1:ec2:reboot" still seems to be a valid value: https://docs.aws.amazon.com/de_de/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html

Is there any reason why this does not work any more?

Thanks,
Matthias

@zleavell
Copy link

zleavell commented Nov 8, 2018

Im definitely having the same error with terraform. I was actually able to use this about 2 days ago, but today I cannot use it:

 resource "aws_cloudwatch_metric_alarm" "ec2-autorecover-application-amer" {
     alarm_name          = "${var.application-group}-${var.application}-amer-autorecover-ec2-application"
     namespace           = "AWS/EC2"
     evaluation_periods  = "2"
     period              = "300"
     alarm_description   = "This metric auto recovers the EC2 instance after failed status checks"
     alarm_actions       = ["arn:aws:automate:${var.region}:ec2:recover"]
     statistic           = "Minimum"
     comparison_operator = "GreaterThanThreshold"
     threshold           = "1"
     metric_name         = "StatusCheckFailed_System"
     insufficient_data_actions = []
 
     dimensions {
     InstanceId = "${data.aws_instances.zoom-instance-amer.ids[count.index]}"

Reboot action seems to be gone now?

Error:

module.app.aws_cloudwatch_metric_alarm.autoreboot-application-high-cpu-amer: "alarm_actions.0" does not match EC2 automation ARN ("^arn:[\\w-]+:automate:[\\w-]+:ec2:(recover|stop|terminate)$"): "arn:aws:automate:us-west-2:ec2:reboot"

@bflad bflad added bug Addresses a defect in current functionality. service/cloudwatch Issues and PRs that pertain to the cloudwatch service. labels Nov 8, 2018
@bflad
Copy link
Contributor

bflad commented Nov 8, 2018

Hi folks 👋 Sorry for the trouble here. This has been an unfolding issue for the last few releases. 😅

  • In version 1.41.0 of the AWS provider (specifically resource/aws_cloudwatch_metric_alarm: Validate alarm actions #6151), we started validating during plan-time that alarm_actions were in fact "normal" ARNs (e.g. arn:PARTITION:SERVICE:REGION:ACCOUNT:RESOURCE) which was a validation that did not exist previously. Since these EC2 automation ARNs differ by including ec2 in the account ID field (normally a 12 digit number) this caused the initial regression.
  • In version 1.42.0 of the AWS provider (specifically resource/aws_cloudwatch_metric_alarm: Allow EC2 Automate ARNs with alarm_actions #6206) we started allowing EC2 automation ARNs including recover, stop, and terminate.
  • This issue here now surfaces that while reboot is documented under OKActions, it was not documented under AlarmActions, which was a mistake on my part for not including it in the original fix.

I have submitted #6405 to allow reboot as well. I'll make sure this gets included in version 1.43.1, which will likely get released later tonight.

@bflad bflad added this to the v1.43.1 milestone Nov 8, 2018
@klassm
Copy link

klassm commented Nov 9, 2018 via email

@zleavell
Copy link

zleavell commented Nov 9, 2018

Hi folks 👋 Sorry for the trouble here. This has been an unfolding issue for the last few releases. 😅

  • In version 1.41.0 of the AWS provider (specifically resource/aws_cloudwatch_metric_alarm: Validate alarm actions #6151), we started validating during plan-time that alarm_actions were in fact "normal" ARNs (e.g. arn:PARTITION:SERVICE:REGION:ACCOUNT:RESOURCE) which was a validation that did not exist previously. Since these EC2 automation ARNs differ by including ec2 in the account ID field (normally a 12 digit number) this caused the initial regression.
  • In version 1.42.0 of the AWS provider (specifically resource/aws_cloudwatch_metric_alarm: Allow EC2 Automate ARNs with alarm_actions #6206) we started allowing EC2 automation ARNs including recover, stop, and terminate.
  • This issue here now surfaces that while reboot is documented under OKActions, it was not documented under AlarmActions, which was a mistake on my part for not including it in the original fix.

I have submitted #6405 to allow reboot as well. I'll make sure this gets included in version 1.43.1, which will likely get released later tonight.

Hey there Blfad - will you let us know when this gets deployed?

@bflad
Copy link
Contributor

bflad commented Nov 9, 2018

The fix for this has been merged and will be released in version 1.43.1 of the provider shortly (next hour or so, sorry for the slight delay). 👍

@bflad
Copy link
Contributor

bflad commented Nov 9, 2018

This has been released in version 1.43.1 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@zleavell
Copy link

zleavell commented Nov 9, 2018

Fixed, thanks!

@ghost
Copy link
Author

ghost commented Apr 2, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/cloudwatch Issues and PRs that pertain to the cloudwatch service.
Projects
None yet
3 participants