Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/miquido/terraform-ecs-prometheus


https://github.com/miquido/terraform-ecs-prometheus

Last synced: 5 days ago
JSON representation

Awesome Lists containing this project

README

        

[![Miquido][logo]](https://www.miquido.com/)

# 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:
```hcl
PROMETHEUS_EXPORTER_PORT 8080
PROMETHEUS_EXPORTER_PATH /actuator/prometheus
```
---
**Terraform Module**

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

## Usage

```hcl
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](#requirement\_terraform) | >= 0.13 |
| [aws](#requirement\_aws) | ~> 4.7 |

## Providers

| Name | Version |
|------|---------|
| [aws](#provider\_aws) | ~> 4.7 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| [alb-ingress-prometheus](#module\_alb-ingress-prometheus) | git::ssh://[email protected]/miquido/terraform/terraform-alb-ingress.git | 3.1.18 |
| [ecs-alb-task-prometheus](#module\_ecs-alb-task-prometheus) | git::ssh://[email protected]/miquido/terraform/terraform-ecs-alb-task.git | 5.6.26 |
| [prometheus-service-discovery](#module\_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](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
| [aws_route53_record.prometheus](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
| [aws_route53_record.prometheus-ipv6](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
| [aws_iam_policy_document.service-discovery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [alb](#input\_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](#input\_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](#input\_app\_mesh\_id) | n/a | `string` | `null` | no |
| [app\_mesh\_route53\_zone](#input\_app\_mesh\_route53\_zone) | app\_mesh route zone to create service entry |
object({
id = string
name = string
})
| `null` | no |
| [aws\_region](#input\_aws\_region) | Default AWS Region | `string` | n/a | yes |
| [aws\_service\_discovery\_private\_dns\_namespace](#input\_aws\_service\_discovery\_private\_dns\_namespace) | n/a |
object({
name = string
id = string
hosted_zone = string
})
| `null` | no |
| [domain](#input\_domain) | domain under which prometheus will be available. Required when alb is used | `string` | `null` | no |
| [ecs\_cluster](#input\_ecs\_cluster) | resource aws\_ecs\_cluster where to deploy service |
object({
arn = string
name = string
})
| n/a | yes |
| [enable\_app\_mesh](#input\_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](#input\_environment) | Environment name | `any` | n/a | yes |
| [ingress\_priority](#input\_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](#input\_project) | Account/Project Name | `string` | n/a | yes |
| [route53\_zone\_id](#input\_route53\_zone\_id) | route id to create prometheus entry | `string` | `null` | no |
| [service\_name](#input\_service\_name) | Name under which service will be deployed | `string` | `"prometheus"` | no |
| [tags](#input\_tags) | Default tags to apply on all created resources | `map(string)` | `{}` | no |
| [task\_cpu](#input\_task\_cpu) | ECS task cpu for prometheus | `number` | `256` | no |
| [task\_memory](#input\_task\_memory) | ECS task memory for prometheus | `number` | `512` | no |
| [vpc](#input\_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
```text
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
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](https://miquido.com)

[logo]: https://www.miquido.com/img/logos/logo__miquido.svg
[website]: https://www.miquido.com/
[gitlab]: https://gitlab.com/miquido
[github]: https://github.com/miquido
[bitbucket]: https://bitbucket.org/miquido