【问题标题】:How to make the Terraspace stack common for a few environments?如何使 Terraspace 堆栈在一些环境中通用?
【发布时间】:2020-11-17 11:19:16
【问题描述】:

请告诉我是否有任何方法可以使某些 Terraspace 堆栈在某些环境中通用?例如,我有一个适用于所有非生产环境的 AWS 账户,并且我想对所有环境使用相同的 VPC,所有其他资源(例如 EC2、RDS、SQS 等)将因每个环境而异且特定.那么有没有办法将公共 VPC 堆栈的状态(首先是输出)共享给其他环境(开发、阶段、测试等)以及如何防止将 VPC 堆栈分别应用于terraspace build <environment> 阶段的每个环境?

【问题讨论】:

    标签: terraform terragrunt terraspace


    【解决方案1】:

    您好,您可以创建模块,每个模块将代表一个堆栈并在您的环境中使用。 模块是一起使用的多个资源的容器。模块可用于创建轻量级抽象,以便您可以根据架构来描述您的基础架构,而不是直接根据物理对象。

    这是ref

    例如,您的堆栈是这样的:

    stage
      └ vpc
      └ services
          └ frontend-app
          └ backend-app
      └ data-storage
          └ mysql
          └ redis
    prod
      └ vpc
      └ services
          └ frontend-app
          └ backend-app
      └ data-storage
          └ mysql
          └ redis
    mgmt
      └ vpc
      └ services
          └ bastion-host
          └ jenkins
    global
      └ iam
      └ s3
    

    因此,如果您想在单独的 git 项目中创建模块并在每个 env 中使用模块:

    live.git
      └ stage
          └ vpc
          └ services
              └ frontend-app
              └ backend-app
          └ data-storage
              └ mysql
              └ redis
      └ prod
          └ vpc
          └ services
              └ frontend-app
              └ backend-app
          └ data-storage
              └ mysql
              └ redis
      └ mgmt
          └ vpc
          └ services
              └ bastion-host
              └ jenkins
      └ global
          └ iam
          └ s3
    modules.git
      └ data-stores
           └ mysql
           └ redis           
      └ mgmt
           └ vpc           
           └ jenkins           
      └ security
           └ iam
           └ s3
           └ bastion-host
      └ services
           └ webserver-cluster
    

    这里有一个 Link 关于如何创建模块

    【讨论】:

    • 感谢您的回答。在本主题中,我宁愿尝试了解如何将其中一个堆栈(此处为 Terraspace 术语中的堆栈)的输出共享到几个 Terraspace 环境。这个问题一般不是关于模块或共享输出,而是关于 Terraspace 特定的案例。
    猜你喜欢
    • 2010-09-26
    • 2015-11-09
    • 1970-01-01
    • 2015-07-02
    • 2012-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多