AWS IAM角色策略声明中的Terraform concat 2列表

时间:2019-12-16 12:15:34

标签: amazon-web-services variables terraform amazon-iam concat

我在编写concat语句以动态构建策略语句时遇到一些问题。

我需要在IAM Role语句中添加一个Secrets Manager机密的动态列表,但是我被困在这里。

有人可以帮忙吗?

我收到此错误:

template<class T, class Head, class ...Args>
auto
make_vector(Head size, Args... args)
{
    if constexpr (sizeof...(Args) > 0)
        return std::vector(size, make_vector<T, Args...>(args...));
    else
        return std::vector<T>(size);
}

我的变量:

Error: Invalid template interpolation value

  on terraform/lambda.tf line 89, in resource "aws_iam_role_policy" "iam_policy_for_lambda_secrets":
  88:
  89:               concat(
  90:                 ["arn:aws:secretsmanager:${lookup(local.region, local.environment)}:111111111111:secret:customer*"],
  91:                 [
  92:                   for name in lookup(local.lambda_secrets_access, local.environment):
  93:                   "arn:aws:secretsmanager:${lookup(local.region, local.environment)}:111111111111:secret:${name}"
  94:                 ]
  95:               )
  96:

    |----------------
    | local.environment is "dev"
    | local.lambda_secrets_access is object with 2 attributes
    | local.region is object with 2 attributes

Cannot include the given value in a string template: string required.

这是我有问题的代码:

  // Lookup for Region
  region = {
    "dev"         = "eu-west-1"
  }
  // Region lookup relation to workspace
  environment     = "${terraform.workspace}"
  // List of extra Secrets Manager secrets to gain access to
  lambda_secrets_access = {
    "dev"         = ["my-secret-i-want-access-JHKku8"]
  }

0 个答案:

没有答案