出于某种原因,我似乎无法更新 us-central1
中的 key 。地区。我的 IAM 具有更新和列表角色,我使用以下代码:
import google.cloud.kms as kms
self.client = kms.KeyManagementServiceClient()
name = 'client-1'
key_path = self.client.crypto_key_path(config.PROJECT, config.KMS_LOCATION, config.KMS_RING, name)
update_mask = {'paths': ['rotation_period', 'next_rotation_time']}
self.client.update_crypto_key({
'name': key_path,
'rotation_period': {'seconds': 0},
'next_rotation_time': {'seconds': 0}
}, update_mask)
它给了我以下错误:
google.api_core.exceptions.NotFound: 404 The request concerns location 'us-central1' but was sent to location 'global'. Either Cloud KMS is not available in 'us-central1' or the request was misrouted.
奇怪的是,列表和获取工作正常。我也看到了一个解决方案,他们改变了客户端的传输参数,但我似乎找不到正确的地址。
提前致谢 !
最佳答案
这是一个错误,我们正在跟踪 https://github.com/googleapis/gapic-generator/issues/3066
同时,该bug的原因是当第一个参数为dict
时,UpdateCryptoKey无法正确计算区域。 .如果是 resources_pb2.CryptoKey
,它工作正常。举个例子:
import google.cloud.kms as kms
from google.cloud.kms_v1.proto import resources_pb2
client = kms.KeyManagementServiceClient()
ck = resources_pb2.CryptoKey()
ck.name = 'projects/{proj}/locations/us-central1/keyRings/{kr}/cryptoKeys/{key}'
ck.next_rotation_time.GetCurrentTime()
update_mask = {'paths': ['next_rotation_time']}
client.update_crypto_key(ck, update_mask)
希望这可以让您在我们解决此问题的同时解决此问题。给您带来的不便深表歉意,并感谢您的耐心等待!
关于python - 无法在 us-central1 中更新加密 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59617920/