【问题标题】:Cloud KMS error when attempting to use boot disk encryption key尝试使用启动磁盘加密密钥时出现 Cloud KMS 错误
【发布时间】:2021-12-11 02:08:03
【问题描述】:

我正在使用 terraform 在 GCP 项目中构建集群。我在同一个 GCP 项目中手动创建了一个服务帐户,并在 terraform GKE 模块中指定了这个相同的服务帐户,如下所示

module "gke" {
...
    service_account = "tf-service-account@<project>.iam.gserviceaccount.com"
...
}

基本上这应该使用此服务帐户创建集群。我还在服务帐户中添加了 Cloud KMS CrytpoKey Decrypter、Encrypter 和 Encrypter/Descypter,如下图所示。

已授予同一服务帐户对 KMS 密钥的权限。如下图

我已通过将其添加到我的节点池配置中指定了要使用的正确加密密钥

boot_disk_kms_key = "projects/<PROJECT>/locations/europe-west2/keyRings/<KEY RING NAME>"

错误

我正在通过 GCP 云 shell 运行 terraform,当我收到以下错误时

Error: Error waiting for creating GKE NodePool: 
│       (1) deploy error: Not all instances running in IGM after 33.708999334s. Expected 2, running 0, transitioning 2. Current errors: [KMS_PERMISSION_DENIED]: Instance '<INSTANCE>' creation failed: Cloud KMS error when using key <KEY PATH>: Permission 'cloudkms.cryptoKeyVersions.useToEncrypt' denied on resource '<KEY PATH>' (or it may not exist).; [KMS_PERMISSION_DENIED]: Instance '<INSTANCE>' creation failed: Cloud KMS error when using key <KEY PATH>: Permission 'cloudkms.cryptoKeyVersions.useToEncrypt' denied on resource '<KEY PATH>' (or it may not exist)

【问题讨论】:

    标签: google-cloud-platform service-accounts terraform-provider-gcp google-cloud-kms


    【解决方案1】:

    您需要向 GCE 服务帐户(而不是您的工作负载服务帐户)授予权限。 GCE 服务帐号采用以下格式:

    service-[PROJECT_NUMBER]@compute-system.iam.gserviceaccount.com
    

    注意这是PROJECT_NUMBER,而不是PROJECT_ID

    【讨论】:

    • 谢谢,我还以为是工作负载服务帐号呢。
    猜你喜欢
    • 2019-04-22
    • 1970-01-01
    • 1970-01-01
    • 2020-06-30
    • 1970-01-01
    • 2018-08-19
    • 2014-11-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多