Created
March 2, 2024 06:03
-
-
Save roopeshvs/e2a6d8ca10cf7fe5087f3878e6e08882 to your computer and use it in GitHub Desktop.
aws-lambda-module-aws_appautoscaling_policy-snippet.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_appautoscaling_policy" "appautoscaling_policy" { | |
count = var.enable_autoscaling_provisoned_concurrency ? 1 : 0 | |
name = "ProvisionedConcurrency:${module.lambda.lambda_function_name}:${module.lambda_alias_latest.lambda_alias_name}" | |
policy_type = "TargetTrackingScaling" | |
resource_id = aws_appautoscaling_target.appautoscaling_target[0].resource_id | |
scalable_dimension = aws_appautoscaling_target.appautoscaling_target[0].scalable_dimension | |
service_namespace = aws_appautoscaling_target.appautoscaling_target[0].service_namespace | |
target_tracking_scaling_policy_configuration { | |
customized_metric_specification { | |
metrics { | |
label = "ProvisionedConcurrencyUtilization" | |
id = "m1" | |
metric_stat { | |
metric { | |
metric_name = "ProvisionedConcurrencyUtilization" | |
namespace = "AWS/Lambda" | |
dimensions { | |
name = "FunctionName" | |
value = module.lambda.lambda_function_name | |
} | |
dimensions { | |
name = "Resource" | |
value = "${module.lambda.lambda_function_name}:${module.lambda_alias_latest.lambda_alias_name}" | |
} | |
} | |
stat = "Maximum" | |
} | |
return_data = false | |
} | |
metrics { | |
label = "ProvisionedConcurrencyUtilization where Missing Data = 0" | |
id = "m2" | |
expression = "FILL(m1, 0)" | |
return_data = true | |
} | |
} | |
target_value = var.target_provisioned_concurrency_utilization | |
scale_in_cooldown = var.scale_in_cooldown | |
scale_out_cooldown = var.scale_out_cooldown | |
disable_scale_in = false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment