cloudflare/terraform-provider-cloudflare

GitHub: cloudflare/terraform-provider-cloudflare

Cloudflare官方维护的Terraform Provider,将Cloudflare REST API封装为声明式基础设施即代码资源,实现对CDN、DNS、安全策略等的自动化配置管理。

Stars: 1261 | Forks: 821

# Cloudflare Terraform Provider [Cloudflare Terraform provider](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs) 提供了从 Terraform 方便地访问 [Cloudflare REST API](https://developers.cloudflare.com/api) 的能力。 ## 要求 此 provider 需要 Terraform CLI 1.0 或更高版本。您可以在 Hashicorp 的网站上为您的系统[下载安装](https://developer.hashicorp.com/terraform/install)。 ## 使用说明 将以下内容添加到您的 `main.tf` 文件中: ``` # 声明 Provider 和版本 terraform { required_providers { cloudflare = { source = "cloudflare/cloudflare" version = "~> 5.19.1" } } } # 初始化 Provider provider "cloudflare" { # The preferred authorization scheme for interacting with the Cloudflare API. [Create a token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/). api_token = "Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY" # or set CLOUDFLARE_API_TOKEN env variable # The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys. api_key = "144c9defac04969c7bfad8efaa8ea194" # or set CLOUDFLARE_API_KEY env variable # The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key. api_email = "user@example.com" # or set CLOUDFLARE_EMAIL env variable # Used when interacting with the Origin CA certificates API. [View/change your key](https://developers.cloudflare.com/fundamentals/api/get-started/ca-keys/#viewchange-your-origin-ca-keys). user_service_key = "v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719" # or set CLOUDFLARE_API_USER_SERVICE_KEY env variable # Sets an account ID to be used with all account-scoped requests. account_id = "f037e56e89293a057740de681ac9accp" # or set CLOUDFLARE_ACCOUNT_ID env variable # Sets a zone ID to be used with all zone-scoped requests. zone_id = "f037e56e89293a057740de681ac9accp" # or set CLOUDFLARE_ZONE_ID env variable } # 配置 Resource resource "cloudflare_zone" "example_zone" { account = { id = "023e105f4ecef8ad9ca31a8372d0c353" } name = "example.com" type = "full" } ``` 在目录中运行 `terraform init` 来初始化您的项目。 更多的示例可以在本仓库的 [./examples](./examples) 文件夹中找到,您也可以参考 [Terraform Registry](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs) 上的完整文档。 ### Provider 选项 初始化 provider 时,支持以下选项。建议将访问令牌等敏感值使用环境变量来设置。 如果提供了环境变量,则不需要在 terraform 源码中再次设置该选项。 | Property | Environment variable | Required | Default value | | ---------------- | --------------------------------- | -------- | ------------- | | zone_id | `CLOUDFLARE_ZONE_ID` | false | — | | user_service_key | `CLOUDFLARE_API_USER_SERVICE_KEY` | false | — | | api_token | `CLOUDFLARE_API_TOKEN` | false | — | | api_key | `CLOUDFLARE_API_KEY` | false | — | | api_email | `CLOUDFLARE_EMAIL` | false | — | | account_id | `CLOUDFLARE_ACCOUNT_ID` | false | — | ## 语义化版本控制 此包通常遵循 [SemVer](https://semver.org/spec/v2.0.0.html) 约定,尽管某些向后不兼容的更改可能会作为次要版本发布: 1. 对库内部结构的技术性公开、但不打算或未文档化供外部使用的更改。_(如果您依赖于这些内部结构,请开启一个 GitHub issue 告知我们。)_ 2. 我们预计在实践中不会影响绝大多数用户的更改。 我们非常重视向后兼容性,并努力确保您能获得顺畅的升级体验。 我们期待您的反馈;如有问题、Bug 或建议,请开启一个 [issue](https://www.github.com/cloudflare/terraform-provider-cloudflare/issues)。 ## 维护 此 SDK 得到积极维护,但是,许多问题是在 Cloudflare 内部系统而非 GitHub 上跟踪的。欢迎社区成员参加我们每周的缺陷分类会议并讨论您的问题。如遇紧急问题,请联系 [Cloudflare 支持](https://developers.cloudflare.com/support/contacting-cloudflare-support/)。 * [社区缺陷分类会议](https://calendar.google.com/calendar/embed?src=c_dbf6ce250643f2e60f806d28f3fc09a9de24cbe0ab3ffb699838303d2adfc9e4%40group.calendar.google.com&ctz=America%2FLos_Angeles) ## 贡献 请参阅[贡献指南](./CONTRIBUTING.md)。
标签:API Token, API管理, AppImage, CDN, CISA项目, Cloudflare, DNS, DNS管理, EC2, ECS, EVTX分析, HashiCorp, IaC, IT运维, MITRE ATT&CK, REST API, Socks5代理, SSL证书, Terraform, WAF, Web应用防火墙, 云服务, 威胁情报, 开发者工具, 开源框架, 持续交付, 持续集成, 日志审计, 特权提升, 网络配置, 自动化部署