Я вызываю метод dlp.deidentify_content в следующем коде. KeyRing производится в регионе us-east1, а ключи генерируются с помощью HSM. GCP не позволил сгенерировать ключ HSM для глобального набора ключей.
# Import the client library
import google.cloud.dlp
# Instantiate a client
dlp = google.cloud.dlp_v2.DlpServiceClient()
# Convert the project id into a full resource id.
parent = dlp.project_path(project)
# The wrapped key is base64-encoded, but the library expects a binary
# string, so decode it here.
import base64
wrapped_key = base64.b64decode(wrapped_key)
# Construct FPE configuration dictionary
crypto_replace_ffx_fpe_config = {
"crypto_key": {
"kms_wrapped": {
"wrapped_key": wrapped_key,
"crypto_key_name": key_name,
}
},
"common_alphabet": alphabet,
}
# Add surrogate type
if surrogate_type:
crypto_replace_ffx_fpe_config["surrogate_info_type"] = {
"name": surrogate_type
}
# Construct inspect configuration dictionary
inspect_config = {
"info_types": [{"name": info_type} for info_type in info_types]
}
# Construct deidentify configuration dictionary
deidentify_config = {
"info_type_transformations": {
"transformations": [
{
"primitive_transformation": {
"crypto_replace_ffx_fpe_config": crypto_replace_ffx_fpe_config
}
}
]
}
}
# Convert string to item
item = {"value": string}
# Call the API
response = dlp.deidentify_content(
parent,
inspect_config=inspect_config,
deidentify_config=deidentify_config,
item=item,
#location_id="us-east1",
)
# Print results
print(response.item.value)
Когда я запускаю код, я получаю сообщение об ошибке,
google.api_core.exceptions.NotFound: 404 Получено следующее сообщение об ошибке из Cloud KMS при развертывании KmsWrappedCryptoKey "проектов / PROJ_NAME / location / us-east1 / keyRings / dlp-test3 / cryptoKeys / key7 ": запрос касается местоположения" us-east1 ", но был отправлен в местоположение" global ". Прочтите go / storky-stubby для получения дополнительной информации.
Я не могу понять, как отправить запрос из указанного c региона. В идеале я бы хотел, чтобы брелок был глобальным. Однако GCP не позволяет использовать ключи HSM для глобальных наборов ключей, и в результате не может иметь обернутый ключ для этого ключа.
Может кто-нибудь подсказать, как устранить ошибку?