Hostinger Terraform Provider 使用教程:入门指南
Hostinger Terraform 提供程序让你通过 Terraform 的基础设施即代码(IaC)方法来管理基础设施。借助该提供程序,你可以自动化部署和管理你的 Hostinger 资源,例如 VPS 实例、DNS 区域和 DNS 记录。
提供程序设置
首先,在你的 Terraform 配置中定义 Hostinger 提供程序:
terraform { required_providers { hostinger = { source = "hostinger/hostinger" version = "0.1.3" } }}
provider "hostinger" { api_token = "your_hostinger_api_token"}请将 your_hostinger_api_token 替换为你的 Hostinger API 令牌,你可以在 Hostinger 账户的 API 设置中获取该令牌。
使用示例
创建 VPS 实例
以下是创建新 VPS 实例的方法:
resource "hostinger_vps" "box" { plan = "hostingercom-vps-kvm2-usd-1m" data_center_id = 13 template_id = 1002 hostname = "web-01.example.com" password = "SecureP@ssw0rd!" post_install_script_id = hostinger_vps_post_install_script.nginx.id ssh_key_ids = [hostinger_vps_ssh_key.inline_key.id]}应用 Terraform 配置
定义好资源后,运行以下命令:
terraform initterraform planterraform applyTerraform 会提示你确认更改。确认后,Terraform 将开通你的 Hostinger 资源。
如需了解更多功能,请查阅官方文档:
将 Terraform 集成到你的工作流程中,可以高效、可重复地管理你的 Hostinger 基础设施,助你实现无缝扩展。