Skip to content

dasmeta/terraform-aws-service

Repository files navigation

service

What

This module

  • deploys services by using helm_release tf resource:
    • it is conditional: set deploy_service to false if you don't want to deploy a service,
  • creates these basic alarms in CloudWatch for the service:
    • service pod's received traffic is out of anomaly band,
    • service pod's transmitted traffic is out of anomaly band,
    • service pod has 2 or more restarts in 5 minues,
    • service has 0 available replicas,
    • service HPA has been on its maximum for 5 minutes: there are maximum pods of the service.

How

Alarms are configured by default but can be customized via alarms.custom_values parameter. By default all 5 alarms are enabled but each of them can be disabled:

module "this" {
  ....

  alarms = {
    sns_topic = "default"
    restarts = {
      enabled = false
    }
    network_out = {
      enabled = false
    }
  }

  ....
}

In this case restarts, network_out alarms will not be created. Only maximum_replicas_usage, replicas, network_in alarms will be created.

Use Cases

Please check examples folder for more detailed examples.

Requirements

No requirements.

Providers

Name Version
helm n/a

Modules

Name Source Version
cw_alerts dasmeta/monitoring/aws//modules/alerts 1.3.5

Resources

Name Type
helm_release.service resource

Inputs

Name Description Type Default Required
alarms Alarms are enabled by default. You need to set SNS topic name to send alarms. Use custom_values to customize alarms.
object({
enabled = optional(bool, true)
sns_topic = string
custom_values = optional(any, {})
restarts = optional(object({
enabled = bool
}), {
enabled = true
})
replicas = optional(object({
enabled = bool
}), {
enabled = true
})
network_in = optional(object({
enabled = bool
}), {
enabled = true
})
network_out = optional(object({
enabled = bool
}), {
enabled = true
})
maximum_replicas_usage = optional(object({
enabled = optional(bool, true)
maximum_replicas = optional(number)
}), {
enabled = true
maximum_replicas = 3 //The count of HPA maximum for a service. It will be used as a threshold for HPA maximum alarm.
})

})
n/a yes
chart n/a string "base" no
chart_version n/a string null no
cluster_name Cluster name string n/a yes
create_namespace Create namespace bool false no
deploy_service Wether to deploy the service via helm or not. bool true no
helm_values Values which overwrite chart defaults any null no
name Service name. It's used as a helm release name and specified PodName in AWS CloudWatch metrics for which alarms will be created. string n/a yes
namespace Namespace string null no
repository n/a string "https://dasmeta.github.io/helm/" no

Outputs

No outputs.