更新一个项目的静态加密配置
使用您通过云提供商管理的密钥更新静态加密配置。即使您不使用自己的密钥管理,MongoDB Cloud 也会加密所有存储。此资源要求请求的服务帐户或 API 密钥具有项目所有者角色。此功能不适用于 M0
免费集群、M2
、M5
或无服务器集群。
使用客户密钥管理提供程序为 MongoDB Cloud 项目配置至少一项静态加密后,项目所有者可以为需要加密的每个 MongoDB Cloud 集群启用使用客户密钥管理的静态加密。使用客户密钥管理提供程序的静态加密不必与集群云服务提供商匹配。MongoDB Cloud 不会自动轮换用户管理的加密密钥。使用客户密钥管理提供程序的文档和密钥轮换最佳实践指南,遵循您首选的静态加密。当您在 MongoDB Cloud 项目中使用密钥管理配置使用客户密钥管理的静态加密时,MongoDB Cloud 会自动创建 90 天密钥轮换警报。无论您是否使用自己的密钥管理,MongoDB Cloud 都会加密所有存储。
路径参数
-
用于标识项目的唯一 24-十六进制数字字符串。 使用 /groups 端点检索身份验证的用户有权访问权限的所有项目。
注意:群组和项目是同义词。您的群组 ID 与项目 ID 相同。对于现有群组,群组/项目 ID 保持不变。资源和相应的端点使用“群组”一词。
格式应符合以下模式:
^([a-f0-9]{24})$
。
查询参数
-
指示应用程序是否将响应包装在
envelope
JSON 对象中的标志。某些 API 客户端无法访问 HTTP 响应标头或状态代码。要修复此问题,请在查询中设置 Envelope=true。返回结果列表的端点将结果对象用作 envelope。应用程序将状态参数添加到响应正文中。默认值为
false
。 -
指示响应正文是否应采用 prettyprint 格式的标记。
默认值为
false
。Prettyprint
body
必需
所需参数取决于是否有人启用了使用客户密钥管理的静态加密:
如果已使用客户密钥管理 (CMK) 启用静态加密,Atlas 需要所需加密提供商的所有参数。
- 如需使用“AWS 密钥管理服务”(KMS),MongoDB Cloud 需要 awsKms 对象中的所有字段。
- 要使用 Azure Key Vault,MongoDB Cloud 需要 azureKeyVault 对象中的所有字段。
- 要使用 Google Cloud Platform KMS (KMS), MongoDB Cloud 需要 googleCloudKms 对象中的所有字段。对于身份验证,您必须提供 serviceAccountKey(静态凭证)或 roleId(基于服务帐户的身份验证)。配置 roleId 后,serviceAccountKey 不是不再受支持。
如果启用了使用客户密钥管理的静态加密,管理员只能传递 awsKms、azureKeyVault 或 googleCloudKms 对象中已更改的字段,以更新此端点的配置。
-
Amazon Web Services (AWS) KMS 配置详细信息和指定项目的静态加密配置集。
Amazon Web Services Key Management Service -
定义使用 Azure Key Vault (AKV) 的静态加密配置的详细信息。
Azure Key Vault -
指示是否在指定项目中启用专用搜索节点的静态加密的标志。
-
定义使用 Google Cloud Key Management Service (KMS) 的静态加密配置的详细信息。
Google Cloud Key Management Service
atlas api encryptionAtRestUsingCustomerKeyManagement updateGroupEncryptionAtRest --help
import (
"os"
"context"
"log"
sdk "go.mongodb.org/atlas-sdk/v20241113001/admin"
)
func main() {
ctx := context.Background()
clientID := os.Getenv("MONGODB_ATLAS_CLIENT_ID")
clientSecret := os.Getenv("MONGODB_ATLAS_CLIENT_SECRET")
// See https://dochub.mongodb.org/core/atlas-go-sdk-oauth
client, err := sdk.NewClient(sdk.UseOAuthAuth(clientID, clientSecret))
if err != nil {
log.Fatalf("Error: %v", err)
}
params = &sdk.UpdateGroupEncryptionAtRestApiParams{}
sdkResp, httpResp, err := client.EncryptionatRestusingCustomerKeyManagementApi.
UpdateGroupEncryptionAtRestWithParams(ctx, params).
Execute()
}
curl --include --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Accept: application/vnd.atlas.2024-11-13+json" \
--header "Content-Type: application/json" \
-X PATCH "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/encryptionAtRest" \
-d '{ <Payload> }'
curl --user "${PUBLIC_KEY}:${PRIVATE_KEY}" \
--digest --include \
--header "Accept: application/vnd.atlas.2024-11-13+json" \
--header "Content-Type: application/json" \
-X PATCH "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/encryptionAtRest" \
-d '{ <Payload> }'
{
"awsKms": {
"accessKeyID": "019dd98d94b4bb778e7552e4",
"customerMasterKeyID": "string",
"enabled": true,
"region": "US_GOV_WEST_1",
"requirePrivateNetworking": true,
"roleId": "32b6e34b3d91647abb20e7b8",
"secretAccessKey": "string"
},
"azureKeyVault": {
"azureEnvironment": "AZURE",
"clientID": "string",
"enabled": true,
"keyIdentifier": "https://EXAMPLEKeyVault.vault.azure.net/keys/EXAMPLEKey/d891821e3d364e9eb88fbd3d11807b86",
"keyVaultName": "string",
"requirePrivateNetworking": true,
"resourceGroupName": "string",
"secret": "string",
"subscriptionID": "string",
"tenantID": "string"
},
"enabledForSearchNodes": true,
"googleCloudKms": {
"enabled": true,
"keyVersionResourceID": "projects/my-project-common-0/locations/us-east4/keyRings/my-key-ring-0/cryptoKeys/my-key-0/cryptoKeyVersions/1",
"roleId": "32b6e34b3d91647abb20e7b8",
"serviceAccountKey": "string"
}
}
{
"awsKms": {
"accessKeyID": "019dd98d94b4bb778e7552e4",
"customerMasterKeyID": "string",
"enabled": true,
"region": "US_GOV_WEST_1",
"requirePrivateNetworking": true,
"valid": true
},
"azureKeyVault": {
"azureEnvironment": "AZURE",
"clientID": "string",
"enabled": true,
"keyIdentifier": "https://EXAMPLEKeyVault.vault.azure.net/keys/EXAMPLEKey/d891821e3d364e9eb88fbd3d11807b86",
"keyVaultName": "string",
"requirePrivateNetworking": true,
"resourceGroupName": "string",
"subscriptionID": "string",
"tenantID": "string",
"valid": true
},
"enabledForSearchNodes": true,
"googleCloudKms": {
"enabled": true,
"keyVersionResourceID": "projects/my-project-common-0/locations/us-east4/keyRings/my-key-ring-0/cryptoKeys/my-key-0/cryptoKeyVersions/1",
"roleId": "32b6e34b3d91647abb20e7b8",
"valid": true
}
}
{
"error": 400,
"detail": "(This is just an example, the exception may not be related to this endpoint) No provider AWS exists.",
"reason": "Bad Request",
"errorCode": "VALIDATION_ERROR"
}
{
"error": 401,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Unauthorized",
"errorCode": "NOT_ORG_GROUP_CREATOR"
}
{
"error": 403,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Forbidden",
"errorCode": "CANNOT_CHANGE_GROUP_NAME"
}
{
"error": 404,
"detail": "(This is just an example, the exception may not be related to this endpoint) Cannot find resource AWS",
"reason": "Not Found",
"errorCode": "RESOURCE_NOT_FOUND"
}
{
"error": 409,
"detail": "(This is just an example, the exception may not be related to this endpoint) Cannot delete organization link while there is active migration in following project ids: 60c4fd418ebe251047c50554",
"reason": "Conflict",
"errorCode": "CANNOT_DELETE_ORG_ACTIVE_LIVE_MIGRATION_ATLAS_ORG_LINK"
}
{
"error": 500,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Internal Server Error",
"errorCode": "UNEXPECTED_ERROR"
}