【问题标题】:Terraform : how to dynamically create microservices with ECS?Terraform:如何使用 ECS 动态创建微服务?
【发布时间】:2017-10-29 11:38:49
【问题描述】:

我被 terraform 困住了。我想用 terraform 动态创建 ECS 服务。 我有这样的配置:

module/cluster/cluster.tf
module/service/service.tf

我想要做的是将 jenkins 的服务名称注入到 terraform 配置中,所以如果服务不存在,它会创建它(如果存在则更新它) 我尝试设置不同的后端 s3 远程状态,但我无法在一个 terraform apple 中构建整个基础架构。

有没有办法动态指定服务配置以便按需创建它们?

【问题讨论】:

    标签: terraform amazon-ecs


    【解决方案1】:

    terraform 支持使用变量TF_VAR_<variable> 进行动态更改。

    From environment variables
    
    Terraform will read environment variables in the form of TF_VAR_name to find the value for a variable. For example, the TF_VAR_access_key variable can be set to set the access_key variable.
    
    Note: Environment variables can only populate string-type variables. List and map type variables must be populated via one of the other mechanisms.
    

    例如,

    TF_VAR_environment=development terraform plan
    

    https://www.terraform.io/intro/getting-started/variables.html#from-environment-variables

    【讨论】:

      猜你喜欢
      • 2019-05-31
      • 2018-06-14
      • 2018-07-04
      • 2021-05-29
      • 1970-01-01
      • 2023-02-03
      • 2019-04-09
      • 2021-09-17
      • 2019-11-17
      相关资源
      最近更新 更多