yandex-cloud-terraform
Terraform IaC patterns for Yandex Cloud. Use when creating, modifying, or refactoring Terraform configurations for YDB, S3, Message Queue, Cloud Functions, API Gateway, or Serverless Containers. Provides resource patterns, naming conventions, and best practices from production projects.
📖 中文导读:Terraform IaC patterns for Yandex Cloud. Use when creating, modifying, or refactoring Terraform configurations for YDB, S3, Message Queue, Cloud Functions, API Gateway, or Serverless Containers. Provides resource patterns, naming conventions, and best practices from production projects. 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
name: yandex-cloud-terraform description: Terraform IaC patterns for Yandex Cloud. Use when creating, modifying, or refactoring Terraform configurations for YDB, S3, Message Queue, Cloud Functions, API Gateway, or Serverless Containers. Provides resource patterns, naming conventions, and best practices from production projects.
Terraform Yandex Cloud
Quick Start
Choose Structure
Modular (environments/ + modules/): Multiple environments (dev/stage/prod), reusable components
Flat (functional files): Single environment, small-medium projects
Essential Patterns
# Resource naming with prefix
locals {
resource_prefix = "${var.project_name}-${var.environment}"
}
# YDB tables require wait for database readiness
resource "time_sleep" "wait_for_database" {
depends_on = [yandex_ydb_database_serverless.this]
create_duration = "30s"
}
# TTL on temporary data
ttl {
column_name = "expires_at"
expire_interval = "PT0S" # immediate
}
# Secondary index with concurrency guard
resource "yandex_ydb_table_index" "index2" {
# ...
depends_on = [yandex_ydb_table_index.index1]
}
Common Tasks
- Add YDB table: See YDB.md for table patterns, TTL, indexes
- Add Cloud Function: See FUNCTIONS.md for build+deploy patterns
- Add Message Queue: See QUEUE.md for DLQ and retry patterns
- Add Serverless Container: See CONTAINERS.md for Docker registry, triggers, sizing
- IAM roles: See IAM.md for common role combinations
Key Pitfalls
- YDB tables fail without
depends_on = [time_sleep.wait_for_database] - Multiple indexes need sequential
depends_onto avoid concurrent schema modifications - TTL format:
P5D= 5 days,PT0S= immediate - Service accounts need explicit IAM role bindings
- Functions need
user_hashfor redeployment triggers - Docker images MUST be built with
--platform=linux/amd64(ARM images fail with "Internal error")