MON-459 update main readme to integrate terraform 0.12

This commit is contained in:
Quentin Manfroi 2019-07-04 11:53:10 +02:00
parent f1dfb37854
commit 0435f0168d

106
README.md
View File

@ -2,8 +2,7 @@
This repository is used to store all our monitors templates ready to use for generic purpose.
### How to contribute ? ###
## How to contribute ? ##
First, you may refresh your knowledge and look at the [terminology](https://confluence.fr.clara.net/display/DAT/Getting+started).
@ -13,7 +12,7 @@ If you would like to resolve an issue or implement new monitors you must follow
After any change you should run `./scripts/auto_update.sh ./` command to make sure all is up to date else the CI pipeline will fail on the branch.
### Important notes ###
## Important notes ##
* This repository represents a terraform feature and each first level directory could be imported as a terraform module, you must choose the one(s) you need.
* Each of these modules contains the most commons monitors, but they probably do not fulfill all your customer needs
@ -21,54 +20,107 @@ After any change you should run `./scripts/auto_update.sh ./` command to make su
* You will find a complete `README.md` on each module, explaining how to use it.
* The `alerting-message` module could be used to easily generate a templating message to use by default but it could be used also multiple times to generate messages for specific monitors.
### The DataDog provider ###
## Getting started ##
Before importing some modules, you must define the DataDog provider in your `main.tf`
### Terraform ###
Version >= 0.12 is required to use these modules of monitors.
```
terraform {
required_version = "~> 0.12"
}
```
### DataDog provider ###
Here is the last tester terraform provider version for datadog but next versions should work too.
```
provider "datadog" {
version = "2.0.2"
version = "2.0.2" # last tested working version
api_key = "${var.datadog_api_key}"
app_key = "${var.datadog_app_key}"
api_key = var.datadog_api_key
app_key = var.datadog_app_key
}
```
Both of the `datadog_api_key` and `datadog_app_key` are unique to the client.
### Module declaration example ###
A quick example of using a set of monitors for a given terraform module:
Both of the `datadog_api_key` and `datadog_app_key` are unique to the each datadog account. You can define them in `terraform.tfvars` file:
```
variable "oncall_24x7" {
default = "@pagerduty-Public_Cloud_FR_-_Yoda_-_Unibail_HNO"
datadog_api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
datadog_app_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```
### Variables ###
Some variables need to be declared.
```
variable "environment" {
type = string
default = "dev"
}
variable "oncall_office_hours" {
default = "@pagerduty-Public_Cloud_FR_-_Yoda_-_Unibail_HO"
variable "datadog_api_key" {
type = string
}
variable "oncall_nodata" {
default = "@pagerduty-Public_Cloud_FR_-_Yoda_-_Unibail_HNO"
variable "datadog_app_key" {
type = string
}
```
## Modules declaration example ##
A quick example of alerting message module declaration:
```
locals {
oncall_24x7 = "@pagerduty-MyPagerService_NBH"
oncall_office_hours = "@pagerduty-MyPagerService_BH"
}
module "datadog-message-alerting" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//common/alerting-message"
source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//common/alerting-message?ref={RELEASE}"
message_alert = "${var.oncall_24x7}"
message_warning = "${var.oncall_office_hours}"
message_nodata = "${var.oncall_nodata}"
message_alert = local.oncall_24x7
message_warning = local.oncall_office_hours
message_nodata = local.oncall_24x7
}
module "datadog-monitors-my-monitors-set" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//my/monitors/set?ref={revision}"
module "datadog-message-alerting-bh-only" {
source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//common/alerting-message?ref={RELEASE}"
environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}"
message_alert = local.oncall_office_hours
message_warning = local.oncall_office_hours
message_nodata = local.oncall_office_hours
}
module "datadog-monitors-system-generic" {
source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//system/generic?ref={RELEASE}"
environment = var.environment
message = module.datadog-message-alerting.alerting-message
memory_message = module.datadog-message-alerting-bh-only.alerting-message
# Use variables to customize monitors configuration
}
# Other monitors modules to declare ...
#module "datadog-monitors-my-monitors-set" {
# source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//my/monitors/set?ref={RELEASE}"
#
# environment = var.environment
# message = module.datadog-message-alerting.alerting-message
#}
```
Replace `{revision}` to the last git tag available on this repository.
The `//` is very important, it's a terraform specific syntax used to separate git url and folder path.
`my/monitors/set` represents the path to a monitors set sub directory listed below.