Skip to content

miquido/Terraform-ECS-Prometheus

Repository files navigation

Miquido

miquido-terraform-ecs-prometheus

This module will deploy prometheus server with ecs service discovery into your ECS cluster. You can setup optionally to expose it via Application Load Balancer. You can also enable App mesh for this service.

To enable service discovery please add Docker labels in the task definitions that you want to discover. for example:

  PROMETHEUS_EXPORTER_PORT  8080
  PROMETHEUS_EXPORTER_PATH  /actuator/prometheus

Terraform Module

GitLab Repository: https://gitlab.com/miquido/terraform/terraform-ecs-prometheus

Usage

module "prometheus" {
source     = "../../"
aws_region = "eu-west-1" // var.aws_region
ecs_cluster = {          // aws_ecs_cluster.main
  arn  = "arn::test::test"
  name = "main"
}
project = "example" // var.project
vpc = {             // module.vpc
  vpc_main_security_group_id = "test_id"
  vpc_id                     = "test_id"
  private_subnet_ids         = ["test_id"]
  vpc_main_security_group_id = "test_id"
}
environment = "stage" //var.environment

/*********** Optional app mesh ************/
aws_service_discovery_private_dns_namespace = { // aws_service_discovery_private_dns_namespace.map
  name        = "test"
  id          = "test"
  hosted_zone = "test"
}
aws_appmesh_mesh_id  = "test" // aws_appmesh_mesh.service.id
mesh_route53_zone_id = "test" // aws_route53_zone.mesh_private_zone.zone_id

/*********** Optional alb ************/
route53_zone_id = "test" //aws_route53_zone.default.zone_id
alb = {                  // module.alb
  http_listener_arn  = "test"
  https_listener_arn = "test"
  alb_arn_suffix     = "test"
  alb_dns_name       = "test"
  alb_zone_id        = "test"
}
domain = "test" // local.prometheus_service_domain
}

Requirements

Name Version
terraform >= 0.13
aws ~> 4.7

Providers

Name Version
aws ~> 4.7

Modules

Name Source Version
alb-ingress-prometheus git::ssh://[email protected]/miquido/terraform/terraform-alb-ingress.git 3.1.18
ecs-alb-task-prometheus git::ssh://[email protected]/miquido/terraform/terraform-ecs-alb-task.git 5.6.26
prometheus-service-discovery git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git 0.58.1

Resources

Name Type
aws_iam_role_policy.service-discovery resource
aws_route53_record.prometheus resource
aws_route53_record.prometheus-ipv6 resource
aws_iam_policy_document.service-discovery data source

Inputs

Name Description Type Default Required
alb Alb module from ssh://[email protected]/miquido/terraform/terraform-alb.git
object({
http_listener_arn = string
https_listener_arn = string
alb_arn_suffix = string
alb_dns_name = string
alb_zone_id = string
})
null no
app_mesh_aws_service_discovery_private_dns_namespace app mesh private DNS namespace
object({
name = string
id = string
hosted_zone = string
})
null no
app_mesh_id n/a string null no
app_mesh_route53_zone app_mesh route zone to create service entry
object({
id = string
name = string
})
null no
aws_region Default AWS Region string n/a yes
aws_service_discovery_private_dns_namespace n/a
object({
name = string
id = string
hosted_zone = string
})
null no
domain domain under which prometheus will be available. Required when alb is used string null no
ecs_cluster resource aws_ecs_cluster where to deploy service
object({
arn = string
name = string
})
n/a yes
enable_app_mesh Should appmesh resources be created. Required vars: aws_service_discovery_private_dns_namespace, aws_appmesh_mesh_id, mesh_route53_zone_id bool true no
environment Environment name any n/a yes
ingress_priority The priority for the rules without authentication, between 1 and 50000 (1 being highest priority). Must be different from authenticated_priority since a listener can't have multiple rules with the same priority number 89 no
project Account/Project Name string n/a yes
route53_zone_id route id to create prometheus entry string null no
service_name Name under which service will be deployed string "prometheus" no
tags Default tags to apply on all created resources map(string) {} no
task_cpu ECS task cpu for prometheus number 256 no
task_memory ECS task memory for prometheus number 512 no
vpc VPC module ssh://[email protected]/miquido/terraform/terraform-vpc.git
object({
vpc_main_security_group_id = string
vpc_id = string
private_subnet_ids = list(string)
})
n/a yes

Outputs

No outputs.

Makefile Targets

Available targets:

  help                                Help screen
  help/all                            Display help for all targets
  help/short                          This help short screen
  lint                                Lint Terraform code

Developing

  1. Make changes in terraform files

  2. Regenerate documentation

    bash <(git archive [email protected]:miquido/terraform/terraform-readme-update.git master update.sh | tar -xO)
  3. Run lint

    make lint
    

Copyright

Copyright © 2017-2022 Miquido

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published