Terraform Registry
registry.terraform.io — แหล่งรวม provider และ module สำหรับ Terraform — เป็นจุดเริ่มต้นเวลาอยากรู้ว่ามี provider ตัวไหนใช้กับ service อะไรได้บ้าง
Terraform Registry คืออะไร?
Terraform Registry เป็น marketplace อย่างเป็นทางการของ HashiCorp ที่:
- รวม 3,000+ providers (AWS, GCP, Azure, GitHub, Datadog, ...)
- รวม 17,000+ modules ที่ community แชร์
- มี documentation ทุก resource ของทุก provider
- เช็ค version history + changelog
URL: https://registry.terraform.io
ประเภทของ Provider ใน Registry
1. Official (HashiCorp Tier)
Provider ที่ HashiCorp เป็นคนดูแล — เสถียรที่สุด
ตัวอย่าง: hashicorp/aws, hashicorp/google, hashicorp/azurerm, hashicorp/random, hashicorp/null
2. Partner (Verified Tier)
บริษัทใหญ่ที่ HashiCorp partner ด้วย เช่น Datadog, Cloudflare, GitLab
ตัวอย่าง: datadog/datadog, cloudflare/cloudflare, gitlabhq/gitlab
3. Community
ใครก็ publish ได้ — ใช้ด้วยความระวัง
ตัวอย่าง: integrations/github, mongodb/mongodbatlas
- ✅ Official + Partner — ใช้ใน production ได้สบาย
- ⚠️ Community — เช็ค download count + last update + GitHub stars ก่อน
วิธีหา Provider
- ไปที่ registry.terraform.io
- คลิก Browse Providers
- ค้นหา service ที่อยากใช้ (เช่น "aws", "github")
- คลิกเข้าไปดู documentation
หรือ search ใน Google: terraform provider <service>
วิธีใช้ Provider
หา source string ของ provider — อยู่ที่ปุ่ม USE PROVIDER บน registry:
terraform {
required_providers {
aws = {
source = "hashicorp/aws" # ← จาก registry
version = "~> 5.0"
}
}
}
hashicorp/aws = <NAMESPACE>/<NAME>
วิธีหา Module
ไปที่ registry.terraform.io/browse/modules หรือใช้ search
ตัวอย่าง modules ยอดนิยม:
terraform-aws-modules/vpc/aws— VPC + subnets + NATterraform-aws-modules/eks/aws— EKS clusterterraform-aws-modules/rds/aws— RDS databaseterraform-google-modules/network/google— GCP networkAzure/aks/azurerm— Azure AKS cluster
วิธีเรียกใช้ Module
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.13.0"
name = "my-vpc"
cidr = "10.0.0.0/16"
azs = ["ap-southeast-1a", "ap-southeast-1b"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24"]
}
source = <NAMESPACE>/<NAME>/<PROVIDER>
อ่าน Documentation ใน Registry
เปิดหน้า provider ใน registry → จะเห็น:
| Tab | มีอะไร |
|---|---|
| Overview | overview ของ provider + ตัวอย่าง |
| Documentation | resources, data sources, functions ทุกตัว ⭐ |
| Versions | version history + breaking changes |
| Source Code | link ไป GitHub |
ใน Documentation จะหาทุกอย่าง:
aws_s3_bucket— resource สร้าง S3 bucketaws_ami— data source ค้น AMIaws_instance.web.public_ip— attribute reference
Private Registry
สำหรับองค์กรที่ต้องการ private modules — ใช้:
- Terraform Cloud / Enterprise (มี private registry ในตัว)
- GitHub / GitLab / Bitbucket (อ้างอิง module ผ่าน Git URL)
module "my_internal" {
source = "git::ssh://[email protected]/myorg/terraform-modules.git//vpc?ref=v1.2.0"
}
Terraform รองรับ source หลายแบบ:
- Registry:
terraform-aws-modules/vpc/aws - GitHub:
github.com/owner/repo - Git:
git::https://example.com/repo.git - HTTP:
https://example.com/module.zip - Local:
./modules/vpc - S3:
s3::https://s3-bucket.amazonaws.com/...
ตัวอย่าง: เลือก Provider + Module ครบทุก Layer
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
github = {
source = "integrations/github" # partner provider
version = "~> 6.0"
}
}
}
# ใช้ module จาก registry
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.13.0"
name = "prod-vpc"
cidr = "10.0.0.0/16"
azs = ["ap-southeast-1a", "ap-southeast-1b"]
}
สรุป
- Terraform Registry = แหล่งรวม provider + module ทั้งหมด
- 3 tiers: Official (HashiCorp), Partner (verified), Community (anyone)
- Provider source format:
<NAMESPACE>/<NAME>เช่นhashicorp/aws - Module source: ใช้ registry path หรือ Git/HTTP/local
- Production อย่าใช้ community provider ที่ไม่ดังโดยไม่ตรวจสอบ
ต่อไป → Configuring Providers