diff --git a/README.md b/README.md index a26b92f..811c5c1 100644 --- a/README.md +++ b/README.md @@ -231,13 +231,13 @@ Note: the default behavior of the module is to create an autoscaling group and l | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.32 | +| [aws](#requirement\_aws) | >= 5.46 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.32 | +| [aws](#provider\_aws) | >= 5.46 | ## Modules diff --git a/examples/complete/README.md b/examples/complete/README.md index 8349137..787ec1a 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -30,13 +30,13 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.32 | +| [aws](#requirement\_aws) | >= 5.46 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.32 | +| [aws](#provider\_aws) | >= 5.46 | ## Modules @@ -44,6 +44,7 @@ Note that this example may create resources which cost money. Run `terraform des |------|--------|---------| | [alb](#module\_alb) | terraform-aws-modules/alb/aws | ~> 9.0 | | [asg\_sg](#module\_asg\_sg) | terraform-aws-modules/security-group/aws | ~> 5.0 | +| [auto\_rollback](#module\_auto\_rollback) | terraform-aws-modules/cloudwatch/aws//modules/metric-alarm | ~> 4.3 | | [complete](#module\_complete) | ../../ | n/a | | [default](#module\_default) | ../../ | n/a | | [disabled](#module\_disabled) | ../../ | n/a | diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 32e9e55..39fd13f 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -87,6 +87,9 @@ module "complete" { scale_in_protected_instances = "Refresh" standby_instances = "Terminate" skip_matching = false + alarm_specification = { + alarms = [module.auto_rollback.cloudwatch_metric_alarm_id] + } } triggers = ["tag"] } @@ -980,3 +983,24 @@ module "step_scaling_alarm" { alarm_actions = [module.complete.autoscaling_policy_arns["scale-out"]] } + +module "auto_rollback" { + source = "terraform-aws-modules/cloudwatch/aws//modules/metric-alarm" + version = "~> 4.3" + + alarm_name = "${local.name}-auto-rollback" + alarm_description = "Auto Rollback Alarm Example" + comparison_operator = "GreaterThanThreshold" + evaluation_periods = 1 + threshold = 0 + period = 60 + treat_missing_data = "notBreaching" + + namespace = "AWS/ApplicationELB" + metric_name = "HTTPCode_ELB_5XX_Count" + statistic = "Sum" + + dimensions = { + LoadBalancer = module.alb.arn_suffix + } +} diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 1384338..e1ed610 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.32" + version = ">= 5.46" } } } diff --git a/main.tf b/main.tf index f203f20..d94ba04 100644 --- a/main.tf +++ b/main.tf @@ -420,6 +420,14 @@ resource "aws_autoscaling_group" "this" { dynamic "preferences" { for_each = try([instance_refresh.value.preferences], []) content { + + dynamic "alarm_specification" { + for_each = try([preferences.value.alarm_specification], []) + content { + alarms = alarm_specification.value.alarms + } + } + checkpoint_delay = try(preferences.value.checkpoint_delay, null) checkpoint_percentages = try(preferences.value.checkpoint_percentages, null) instance_warmup = try(preferences.value.instance_warmup, null) @@ -701,6 +709,14 @@ resource "aws_autoscaling_group" "idc" { dynamic "preferences" { for_each = try([instance_refresh.value.preferences], []) content { + + dynamic "alarm_specification" { + for_each = try([preferences.value.alarm_specification], []) + content { + alarms = alarm_specification.value.alarms + } + } + checkpoint_delay = try(preferences.value.checkpoint_delay, null) checkpoint_percentages = try(preferences.value.checkpoint_percentages, null) instance_warmup = try(preferences.value.instance_warmup, null) diff --git a/versions.tf b/versions.tf index 1384338..e1ed610 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.32" + version = ">= 5.46" } } }