Skip to content

Commit

Permalink
feat: Add support for custom metric queries in customized_metric_spec (
Browse files Browse the repository at this point in the history
…#196)

* feat: add support for custom metric queries in customized metric spec

* fix: Update and run pre-commit checks to format

---------

Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
  • Loading branch information
mattaltberg and bryantbiggs committed May 31, 2024
1 parent f0a628d commit edf0446
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.86.0
rev: v1.90.0
hooks:
- id: terraform_fmt
- id: terraform_wrapper_module_for_each
Expand All @@ -24,7 +24,7 @@ repos:
- '--args=--only=terraform_workspace_remote'
- id: terraform_validate
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
Expand Down
37 changes: 34 additions & 3 deletions modules/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,37 @@ resource "aws_appautoscaling_policy" "this" {
for_each = try([target_tracking_scaling_policy_configuration.value.customized_metric_specification], [])

content {
dynamic "metrics" {
for_each = try(customized_metric_specification.value.metrics, [])
content {
id = metrics.value.id
label = try(metrics.value.label, null)
return_data = try(metrics.value.return_data, true)
expression = try(metrics.value.expression, null)


dynamic "metric_stat" {
for_each = try([metrics.value.metric_stat], [])
content {
stat = metric_stat.value.stat
dynamic "metric" {
for_each = try([metric_stat.value.metric], [])
content {
namespace = metric.value.namespace
metric_name = metric.value.metric_name
dynamic "dimensions" {
for_each = try(metric.value.dimensions, [])
content {
name = dimensions.value.name
value = dimensions.value.value
}
}
}
}
}
}
}
}
dynamic "dimensions" {
for_each = try(customized_metric_specification.value.dimensions, [])

Expand All @@ -1252,9 +1283,9 @@ resource "aws_appautoscaling_policy" "this" {
}
}

metric_name = customized_metric_specification.value.metric_name
namespace = customized_metric_specification.value.namespace
statistic = customized_metric_specification.value.statistic
metric_name = try(customized_metric_specification.value.metric_name, null)
namespace = try(customized_metric_specification.value.namespace, null)
statistic = try(customized_metric_specification.value.statistic, null)
unit = try(customized_metric_specification.value.unit, null)
}
}
Expand Down
9 changes: 8 additions & 1 deletion wrappers/cluster/versions.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.3"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.34"
}
}
}
9 changes: 8 additions & 1 deletion wrappers/container-definition/versions.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.3"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.34"
}
}
}
9 changes: 8 additions & 1 deletion wrappers/service/versions.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.3"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.34"
}
}
}
9 changes: 8 additions & 1 deletion wrappers/versions.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.3"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.34"
}
}
}

0 comments on commit edf0446

Please sign in to comment.