1

我已经用生成器配置了 SOPS:

.sops.yaml

creation_rules:
  - path_regex: \.dev\.yaml$
    kms: *kms_arn*
    aws_profile: dev

生成文件 sops secrets.dev.yaml

它生成加密文件为:

hello: ENC[AES256_GCM,data:8gtnzBNu2AG9l2zHFy3ovCS0gWFj3bdjgb3B/X8CUkvgox8GcxLQv/99aMUndQ==,iv:lw8VYzpWQUrm6bWQgJ6/KEYizhe8VxJAmdysF+Q6zTM=,tag:vRrdCo/iH4ec4dPzI7DB5Q==,type:str]
sops:
    kms:
    -   arn: *kms_arn*
        created_at: '2021-01-12T05:24:17Z'
        enc: *enc_key*
        aws_profile: dev
    gcp_kms: []
    azure_kv: []
    hc_vault: []
    lastmodified: "2021-01-12T05:24:43Z"
    mac: *mac_key*
    pgp: []
    unencrypted_suffix: _unencrypted
    version: 3.6.1

在 terragrunt 中使用:

terragrunt.hcl

locals {
  secret_vars = yamldecode(sops_decrypt_file(find_in_parent_folders("secrets.dev.yaml")))
}

错误:

Error: Error in function call:

Call to function "sops_decrypt_file" failed: Error getting data key: 0 successful groups required, got 0.

4

1 回答 1

0

使用export AWS_PROFILE=dev不是我的选择,因为我正在使用生成provider.tf

account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
generate "provider" {
  path      = "provider.tf"
  if_exists = "overwrite_terragrunt"
  contents  = <<EOF
provider "aws" {
  region = "${local.aws_region}"
  shared_credentials_file = "~/.aws/credentials"
  profile                 = "${local.account_name}"
}
EOF
}

我最终得到了一种解决方法,直接在关键组内设置角色

creation_rules:
  - path_regex: \.dev\.yaml$
    key_groups:
      - kms:
          - arn: <<kms_arn>>
            role: <<role_arn>>
于 2021-04-01T07:03:46.727 回答