Initial commit: Terraform configurations for multiple cloud providers

This commit is contained in:
Ben User
2026-02-01 06:36:02 +00:00
commit 70f160b396
58 changed files with 1813 additions and 0 deletions

8
datadog/.env Normal file
View File

@@ -0,0 +1,8 @@
# Datadog Application Key (以 "ee9a" 结尾)
8ad8eed0af8b041adc43653c176e06f34508ee9a
# Datadog API Key (以 "3c7d" 结尾)
6f3900667c1b401225a8360382c33c7d
# Datadog Site URL
https://us5.datadoghq.com/

48
datadog/README.md Normal file
View File

@@ -0,0 +1,48 @@
# Datadog Terraform Integration
## 配置说明
此目录包含用于与 Datadog 服务集成的 Terraform 配置。
## 必需的凭证
要使用此配置,您需要在 `terraform.tfvars` 文件中提供以下信息:
- `datadog_api_key`: Datadog API 密钥(以 "3c7d" 结尾6f3900667c1b401225a8360382c33c7d
- `datadog_app_key`: Datadog APP 密钥(以 "ee9a" 结尾8ad8eed0af8b041adc43653c176e06f34508ee9a
- `datadog_site`: Datadog 站点 URL已提供https://us5.datadoghq.com/
## 如何获取凭证
1. 您的 Datadog 凭证已经完整:
- **API Key**: `6f3900667c1b401225a8360382c33c7d`(以 "3c7d" 结尾)
- **Application Key**: `8ad8eed0af8b041adc43653c176e06f34508ee9a`(以 "ee9a" 结尾,存储在 .env 文件第一行)
- **站点 URL**: `https://us5.datadoghq.com/`(存储在 .env 文件第二行)
2. 这些值已经正确配置在 `terraform.tfvars` 文件中
3. 连接已验证成功
## 验证连接
运行以下命令来验证连接:
```bash
cd datadog
terraform init
terraform plan
```
## 支持的资源
此配置演示了如何创建 Datadog Monitor但 Datadog Terraform provider 支持广泛的资源类型,包括:
- Monitors监控器
- Dashboards仪表板
- Metrics指标
- Logs日志
- APM 配置
- Security 规则等
## 注意事项
- 请确保您的 API 和 APP 密钥具有适当的权限来创建和管理所需的资源
- 密钥应该安全存储,不要提交到版本控制系统
- 403 错误表示认证失败,请检查您的密钥是否正确且未过期

51
datadog/test-datadog.tf Normal file
View File

@@ -0,0 +1,51 @@
terraform {
required_providers {
datadog = {
source = "DataDog/datadog"
version = "~> 3.0"
}
}
}
# Provider configuration
provider "datadog" {
api_key = var.datadog_api_key
app_key = var.datadog_app_key
api_url = var.datadog_site
}
# Variables
variable "datadog_api_key" {
description = "Datadog API key"
type = string
sensitive = true
}
variable "datadog_app_key" {
description = "Datadog APP key"
type = string
sensitive = true
}
variable "datadog_site" {
description = "Datadog site URL"
type = string
default = "https://api.datadoghq.com"
}
# Example resource - Datadog Monitor
resource "datadog_monitor" "test_monitor" {
name = "Test Monitor"
type = "metric alert"
query = "avg(last_1h):avg:system.cpu.user{*} > 80"
message = "CPU usage is too high"
escalation_message = "Escalation message"
monitor_thresholds {
critical = "80"
}
lifecycle {
ignore_changes = [query] # For testing purposes
}
}