新闻详情

新闻详情

首页 / 资讯中心 / 详情

terraform-module-library - SKILL

发布时间:2026/10/2 16:41:27来源:尧图网络
terraform-module-library - SKILL
name: terraform-module-librarydescription: “Production-ready Terraform module patterns for AWS, Azure, and GCP infrastructure.”risk: criticalsource: communitydate_added: “2026-02-27”Terraform 模块库适用于 AWS、Azure 和 GCP 基础设施的生产就绪 Terraform 模块模式。不要在此情况下使用此技能任务与 terraform 模块库无关你需要此范围之外的其他领域或工具说明澄清目标、约束和必需的输入。应用相关最佳实践并验证结果。提供可操作的步骤和验证。如果需要详细示例请打开resources/implementation-playbook.md。目的为跨多个云提供商的常见云基础设施模式创建可重用、经过良好测试的 Terraform 模块。何时使用此技能构建可重用的基础设施组件标准化云资源预置实施基础设施即代码最佳实践创建多云兼容模块建立组织的 Terraform 标准模块结构terraform-modules/ ├── aws/ │ ├── vpc/ │ ├── eks/ │ ├── rds/ │ └── s3/ ├── azure/ │ ├── vnet/ │ ├── aks/ │ └── storage/ └── gcp/ ├── vpc/ ├── gke/ └── cloud-sql/标准模块模式module-name/ ├── main.tf # Main resources ├── variables.tf # Input variables ├── outputs.tf # Output values ├── versions.tf # Provider versions ├── README.md # Documentation ├── examples/ # Usage examples │ └── complete/ │ ├── main.tf │ └── variables.tf └── tests/ # Terratest files └── module_test.goAWS VPC 模块示例main.tf:resource aws_vpc main { cidr_block var.cidr_block enable_dns_hostnames var.enable_dns_hostnames enable_dns_support var.enable_dns_support tags merge( { Name var.name }, var.tags ) } resource aws_subnet private { count length(var.private_subnet_cidrs) vpc_id aws_vpc.main.id cidr_block var.private_subnet_cidrs[count.index] availability_zone var.availability_zones[count.index] tags merge( { Name ${var.name}-private-${count.index 1} Tier private }, var.tags ) } resource aws_internet_gateway main { count var.create_internet_gateway ? 1 : 0 vpc_id aws_vpc.main.id tags merge( { Name ${var.name}-igw }, var.tags ) }variables.tf:variable name { description Name of the VPC type string } variable cidr_block { description CIDR block for VPC type string validation { condition can(regex(^([0-9]{1,3}\\.){3}[0-9]{1,3}/[0-9]{1,2}$, var.cidr_block)) error_message CIDR block must be valid IPv4 CIDR notation. } } variable availability_zones { description List of availability zones type list(string) } variable private_subnet_cidrs { description CIDR blocks for private subnets type list(string) default [] } variable enable_dns_hostnames { description Enable DNS hostnames in VPC type bool default true } variable tags { description Additional tags type map(string) default {} }outputs.tf:output vpc_id { description ID of the VPC value aws_vpc.main.id } output private_subnet_ids { description IDs of private subnets value aws_subnet.private[*].id } output vpc_cidr_block { description CIDR block of VPC value aws_vpc.main.cidr_block }最佳实践对模块使用语义化版本管理为所有变量编写文档并附带描述在 examples/ 目录中提供示例使用验证块进行输入验证输出重要属性以支持模块组合在 versions.tf 中固定提供程序版本使用 locals存储计算值使用 count/for_each 实现条件资源使用 Terratest 测试模块一致地为所有资源打标签模块组合module vpc { source ../../modules/aws/vpc name production cidr_block 10.0.0.0/16 availability_zones [us-west-2a, us-west-2b, us-west-2c] private_subnet_cidrs [ 10.0.1.0/24, 10.0.2.0/24, 10.0.3.0/24 ] tags { Environment production ManagedBy terraform } } module rds { source ../../modules/aws/rds identifier production-db engine postgres engine_version 15.3 instance_class db.t3.large vpc_id module.vpc.vpc_id subnet_ids module.vpc.private_subnet_ids tags { Environment production } }参考文件assets/vpc-module/- 完整的 VPC 模块示例assets/rds-module/- RDS 模块示例references/aws-modules.md- AWS 模块模式references/azure-modules.md- Azure 模块模式references/gcp-modules.md- GCP 模块模式测试// tests/vpc_test.gopackagetestimport(testinggithub.com/gruntwork-io/terratest/modules/terraformgithub.com/stretchr/testify/assert)funcTestVPCModule(t*testing.T){terraformOptions:terraform.Options{TerraformDir:../examples/complete,}deferterraform.Destroy(t,terraformOptions)terraform.InitAndApply(t,terraformOptions)vpcID:terraform.Output(t,terraformOptions,vpc_id)assert.NotEmpty(t,vpcID)}相关技能multi-cloud-architecture- 用于架构决策cost-optimization- 用于经济高效的设计局限性仅当任务明确符合上述范围时使用此技能。不要将输出视为环境特定验证、测试或专家审查的替代品。如果缺少必需的输入、权限、安全边界或成功标准请停下来询问澄清。
网站建设高端定制企业官网
RELATED

相关资讯

更多精彩内容,欢迎继续阅读

较早相关资讯

最新相关资讯

OpenPose 1.7.0 Win64 GPU+FLIR 3D 部署实操指南 2026/10/2 18:28:03

OpenPose 1.7.0 Win64 GPU+FLIR 3D 部署实操指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

阅读更多 →
深度学习入门实战:从零搭建多层感知机训练MNIST手写数字识别 2026/10/2 18:28:03

深度学习入门实战:从零搭建多层感知机训练MNIST手写数字识别

我翻了翻自己前两篇《从零开始的深度学习》的留言区,发现一个很有意思的现象:环境配置那篇评论全是“终于装好了”“conda又炸了”,第二篇线性回归那篇评论变成了“懂了,但好像又没完全懂”“然后呢?这能干啥&#xff…

阅读更多 →
Python零基础试卷切题工具:OCR定位+PIL精准裁切 2026/10/2 18:28:03

Python零基础试卷切题工具:OCR定位+PIL精准裁切

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

阅读更多 →
Eclipse启动Spring Boot原理与排错指南 2026/10/2 18:27:57

Eclipse启动Spring Boot原理与排错指南

1. 为什么在Eclipse里启动Spring Boot项目,总像在解一道逻辑谜题? “eclipse启动一个Springboot项目”——这行字看起来平平无奇,但在我过去三年带过的27个Java开发新人里,有23个人第一次卡在这一步超过4小时。不是代码写错了&…

阅读更多 →
Squid CVE-2025-54574漏洞应急缓解脚本:拒绝服务攻击的快速响应方案 2026/10/2 18:27:57

Squid CVE-2025-54574漏洞应急缓解脚本:拒绝服务攻击的快速响应方案

如果你手上正好跑着一批 Squid 代理缓存节点,那么这几天你应该留意一下 CVE-2025-54574 这个编号。这个漏洞指向的是 Squid 在处理特定 HTTP 请求时存在拒绝服务风险,攻击者不需要任何认证就能触发,严重情况下可以直接把 Squid 进程打崩溃&am…

阅读更多 →
Redis实战:从内存数据库到AI应用基础设施的演进 2026/10/2 18:27:56

Redis实战:从内存数据库到AI应用基础设施的演进

干我们这行的,Redis 的地位有点特殊。很多人早期把它当缓存用,键值对存一存,顶多处理下排行榜、会话数据,觉得它就是一个“高级版 HashMap”。但这两年,随着大模型、AI Agent、RAG 这些词从概念变成工程落地&#xff0…

阅读更多 →

今日资讯

本周资讯

本月资讯

看完文章仍有疑问?

联系尧图顾问,获取一对一建站咨询

立即免费咨询 📞 400-888-8888
📞 ✉