iac_modules/terraform-hcl-standard/gcp-cloud
2025-12-22 13:40:01 +08:00
..
bootstrap refactor: reorganize IaC modules and examples structure 2025-12-22 13:40:01 +08:00
config refactor: reorganize IaC modules and examples structure 2025-12-22 13:40:01 +08:00
envs/dev refactor: reorganize IaC modules and examples structure 2025-12-22 13:40:01 +08:00
instance refactor: reorganize IaC modules and examples structure 2025-12-22 13:40:01 +08:00
modules refactor: reorganize IaC modules and examples structure 2025-12-22 13:40:01 +08:00
templates refactor: reorganize IaC modules and examples structure 2025-12-22 13:40:01 +08:00
README.md refactor: reorganize IaC modules and examples structure 2025-12-22 13:40:01 +08:00

GCP Cloud Terraform Standard

该目录提供与 aws-cloud 模板一一对应的 GCP 版本,用于在 GCP 上快速引导基础设施。结构与 AWS 目录保持一致,包括引导阶段 (bootstrap)、实例示例 (instance) 与模块库 (modules)。

模板映射

  • bootstrap/identity → IAM:创建基础服务账号与自定义角色,替代 AWS IAM 角色与策略。
  • bootstrap/state → Cloud Storage:创建启用版本化和 generation-based locking 的 GCS 存储桶,对应 AWS S3 + DynamoDB 锁表。
  • modules保留原始模块命名alb、nlb、vpc 等),内部实现改为 GCP 资源:
    • alb/nlb:使用 Google HTTP(S) / TCP 负载均衡。
    • ec2:映射到 Compute Engine 实例或 MIG。
    • keypair:生成 SSH 密钥并写入元数据。
    • msk:映射到 Pub/Sub发布/订阅)。
    • rds:映射到 Cloud SQL。
    • s3:映射到 Cloud Storage。
    • vpc:使用 VPC 网络与子网。
    • ami_lookup映射到最新公共镜像查找debian/ubuntu
    • iam:分配 IAM 角色与绑定。
    • landingzone:创建基础网络、日志与审计配置。
    • redis:映射到 Memorystore。
    • sg:映射到 VPC 防火墙规则。

使用方式

  1. templates/backend.tf 中配置远端状态GCS 存储桶)。
  2. templates/provider.tf 中设置 projectregioncredentials 等参数。
  3. 按需修改 instance 下的实例示例,执行:
    terraform -chdir=instance/vpc init
    terraform -chdir=instance/vpc apply
    

本目录仅新增 GCP 代码,不改动现有 AWS 模板。