Skip to content

Commit

Permalink
Explicit providers
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Ainsworth committed Oct 18, 2023
1 parent e1b24c7 commit ecc4e31
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions terraform/environment/region/modules/ecs_autoscaling/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ resource "aws_appautoscaling_target" "ecs_service" {
role_arn = var.ecs_autoscaling_service_role_arn
max_capacity = var.ecs_task_autoscaling_maximum
min_capacity = var.ecs_task_autoscaling_minimum

provider = aws.region
}

# Automatically scale capacity up by one
Expand All @@ -26,6 +28,8 @@ resource "aws_appautoscaling_policy" "up" {
}

depends_on = [aws_appautoscaling_target.ecs_service]

provider = aws.region
}

# Automatically scale capacity down by one
Expand All @@ -47,6 +51,8 @@ resource "aws_appautoscaling_policy" "down" {
}

depends_on = [aws_appautoscaling_target.ecs_service]

provider = aws.region
}

resource "aws_cloudwatch_metric_alarm" "scale_up" {
Expand Down Expand Up @@ -113,6 +119,8 @@ resource "aws_cloudwatch_metric_alarm" "scale_up" {
}
}
alarm_actions = [aws_appautoscaling_policy.up.arn]

provider = aws.region
}

resource "aws_cloudwatch_metric_alarm" "scale_down" {
Expand Down Expand Up @@ -179,6 +187,8 @@ resource "aws_cloudwatch_metric_alarm" "scale_down" {
}
}
alarm_actions = [aws_appautoscaling_policy.down.arn]

provider = aws.region
}


Expand All @@ -198,4 +208,6 @@ resource "aws_cloudwatch_metric_alarm" "max_scaling_reached" {
ServiceName = var.aws_ecs_service_name
ClusterName = var.aws_ecs_cluster_name
}

provider = aws.region
}
4 changes: 4 additions & 0 deletions terraform/environment/region/pagerduty.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ resource "pagerduty_service_integration" "cloudwatch_integration" {
resource "aws_sns_topic" "cloudwatch_to_pagerduty" {
name = "CloudWatch-to-PagerDuty-${var.environment_name}"
kms_master_key_id = data.aws_kms_alias.pagerduty_sns.target_key_arn

provider = aws.region
}

resource "aws_sns_topic_subscription" "cloudwatch_sns_subscription" {
topic_arn = aws_sns_topic.cloudwatch_to_pagerduty.arn
protocol = "https"
endpoint_auto_confirms = true
endpoint = "https://events.pagerduty.com/integration/${pagerduty_service_integration.cloudwatch_integration.integration_key}/enqueue"

provider = aws.region
}
4 changes: 4 additions & 0 deletions terraform/environment/region/ship_to_metrics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ resource "aws_cloudwatch_log_subscription_filter" "events" {
filter_pattern = "{ $.context.event_code = * }"
destination_arn = data.aws_lambda_function.clsf_to_sqs[0].arn
depends_on = [aws_lambda_permission.allow_cloudwatch]

provider = aws.region
}

resource "aws_lambda_permission" "allow_cloudwatch" {
Expand All @@ -29,4 +31,6 @@ resource "aws_lambda_permission" "allow_cloudwatch" {
function_name = data.aws_lambda_function.clsf_to_sqs[0].function_name
principal = "logs.${data.aws_region.current.name}.amazonaws.com"
source_arn = "${aws_cloudwatch_log_group.application_logs.arn}:*"

provider = aws.region
}

0 comments on commit ecc4e31

Please sign in to comment.