【问题标题】:error within if condition - 'encrypt' expected type 'bool', got unconvertible type 'string'if 条件中的错误 - “加密”预期类型“布尔”,得到不可转换类型“字符串”
【发布时间】:2021-02-21 09:26:12
【问题描述】:

我正在尝试为两个环境(本地和云)定义一个配置块,并且我正在使用 if/else 条件,但我收到了 s3 存储桶的加密属性的错误消息:'encrypt' expected type' bool',得到不可转换的类型'string'。 如果我删除 if/else 条件块,那么它可以工作,但我需要在两个环境之间进行选择,所以我必须使用 if/else 条件。 配置块代码:

config = local.is_local_environment ? {
    # Local configuration
    path = "${path_relative_to_include()}/terraform.tfstate"
  } : {
    # Cloud configuration
    bucket = "my-bucket"
    key = "terraform/${path_relative_to_include()}/terraform.tfstate"
    region = local.region
    encrypt = true
    dynamodb_table = "terraform-lock"
  }
}

【问题讨论】:

    标签: config terragrunt


    【解决方案1】:

    问题是本地后端不接受任何配置,使用 null

    config = local.is_local_environment ? null : {
        # Cloud configuration
        bucket = "my-bucket"
        key = "terraform/${path_relative_to_include()}/terraform.tfstate"
        region = local.region
        encrypt = true
        dynamodb_table = "terraform-lock"
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2020-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多