Membuat rahasia dan menyimpan versi awalnya.
Deskripsi operasi
-
For information about the access policy required for a Resource Access Management (RAM) user or RAM role to call this operation, see Resource Access Management.
-
Specify the secret name, the secret value for the initial version, and the version number. The initial version is marked with the ACSCurrent stage label.
-
Key Management Service (KMS) uses the key that you specify to encrypt the secret value. The key and the secret must be in the same KMS instance. The key must be a symmetric key.
CatatanKMS encrypts the secret value of each version. Metadata such as the secret name, version number, and version stage labels are not encrypted.
-
Before you encrypt the secret value, you must have the
kms:GenerateDataKeypermission on the key.
This topic provides an example of how to create an RDS secret. The secret is named mydbconninfo. The VersionId of the initial version is v1. The SecretData is {"Accounts":[{"AccountName":"user1","AccountPassword":"****"}]}.
Coba sekarang
Test
RAM authorization
Parameter permintaan
|
Parameter |
Type |
Required |
Description |
Example |
| SecretName |
string |
Yes |
Nama rahasia. Nama harus unik dalam wilayah yang sama. Nama dapat memiliki panjang hingga 192 karakter dan dapat berisi huruf, digit, garis bawah (_), garis miring (/), tanda plus (+), tanda sama dengan (=), titik (.), tanda hubung (-), dan tanda at (@). Batasan berikut berlaku untuk nama rahasia untuk berbagai tipe rahasia:
|
mydbconninfo |
| VersionId |
string |
Yes |
Nomor versi dari versi awal. Nomor versi harus unik dalam rahasia. Nomor versi dapat memiliki panjang hingga 64 karakter. |
v1 |
| EncryptionKeyId |
string |
No |
ID kunci yang digunakan untuk mengenkripsi nilai rahasia. Catatan
Kunci dan rahasia harus berada di instans KMS yang sama. Kunci harus berupa kunci simetris. |
key-gzz63ff0db5hg3qje**** |
| SecretData |
string |
Yes |
Nilai rahasia. Nilai dapat memiliki panjang hingga 30.720 byte (30 KB). KMS mengenkripsi nilai rahasia dengan kunci yang ditentukan dan menyimpan nilai terenkripsi tersebut di versi awal.
|
{"Accounts":[{"AccountName":"user1","AccountPassword":"****"}]} |
| SecretDataType |
string |
No |
Tipe nilai rahasia. Nilai valid:
Catatan
Jika SecretType diatur ke Rds, Redis, PolarDB Basis Data Relasional Cloud-Native, RAMCredentials, atau ECS, SecretDataType harus diatur ke text. |
text |
| Description |
string |
No |
Deskripsi rahasia. |
mydbinfo |
| Tags |
string |
No |
Tag rahasia. Setiap tag terdiri dari pasangan kunci-nilai. Sebuah tag terdiri dari kunci tag dan nilai tag. Kunci tag dan nilai tag dapat memiliki panjang hingga 128 karakter dan dapat berisi huruf, digit, garis miring (/), garis miring terbalik (\), garis bawah (_), tanda hubung (-), titik (.), tanda plus (+), tanda sama dengan (=), titik dua (:), dan tanda at (@).
|
[{\"TagKey\":\"key1\",\"TagValue\":\"val1\"},{\"TagKey\":\"key2\",\"TagValue\":\"val2\"}] |
| SecretType |
string |
No |
Tipe rahasia. Nilai valid:
|
Rds |
| ExtendedConfig |
object |
No |
Konfigurasi yang diperluas dari rahasia. Parameter ini menentukan properti rahasia dari tipe tertentu. Nilai dapat memiliki panjang hingga 1.024 karakter.
Catatan
Jika SecretType diatur ke Rds, Redis, PolarDB Basis Data Relasional Cloud-Native, RAMCredentials, atau ECS, Anda harus mengonfigurasi parameter ini. |
{"SecretSubType":"SingleUser", "DBInstanceId":"rm-bp1b3dd3a506e****" ,"CustomData":{"Key1": "v1", "fds":"fdsf"}} |
| EnableAutomaticRotation |
boolean |
No |
Apakah akan mengaktifkan rotasi otomatis. Nilai valid:
Catatan
Parameter ini hanya valid jika SecretType diatur ke Rds, PolarDB Basis Data Relasional Cloud-Native, Redis, RAMCredentials, atau ECS. Jika SecretType diatur ke Generic, rotasi otomatis tidak didukung. Anda dapat memanggil operasi PutSecretValue untuk merotasi rahasia secara manual. |
true |
| RotationInterval |
string |
No |
Interval untuk rotasi otomatis. Nilai dalam rentang 6 jam hingga 8.760 jam (365 hari). Catatan
Anda harus menentukan parameter ini jika mengatur EnableAutomaticRotation ke true. Anda tidak perlu menentukan parameter ini jika mengatur EnableAutomaticRotation ke false. |
30d |
| DKMSInstanceId |
string |
No |
ID instans KMS. |
kst-bjj62d8f5e0sgtx8h**** |
| Policy |
string |
No |
Konten Kebijakan rahasia. Nilai dalam format JSON. Nilai dapat memiliki panjang hingga 32.768 byte. Untuk informasi selengkapnya tentang Kebijakan rahasia, lihat Ikhtisar Kebijakan rahasia. Jika Anda tidak menentukan parameter ini, Kebijakan rahasia default digunakan. Sebuah Kebijakan rahasia berisi bagian berikut:
Berikut adalah format Kebijakan rahasia:
Detail tentang sebuah pernyataan:
Catatan
Setelah Anda memberikan izin kepada Pengguna RAM atau Peran RAM dari akun Alibaba Cloud lain, Anda harus menggunakan akun Alibaba Cloud tempat Pengguna RAM atau Peran RAM berada untuk memberikan izin kepada Pengguna RAM atau Peran RAM tersebut agar dapat menggunakan rahasia di Konsol RAM. Kemudian, Pengguna RAM atau Peran RAM dapat menggunakan rahasia tersebut. Untuk informasi selengkapnya, lihat kebijakan kustom untuk KMS, Memberikan izin kepada Pengguna RAM, dan Memberikan izin kepada Peran RAM. |
{"Version":"1","Statement": [{"Sid":"kms default secret policy","Effect":"Allow","Principal":{"RAM": ["acs:ram::119285303511****:*"]},"Action":["kms:*"],"Resource": ["*"] }] } |
Untuk informasi tentang parameter permintaan umum, lihat Parameter umum.
Elemen respons
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The ID of the request, which is a unique identifier generated by Alibaba Cloud. You can use this ID to troubleshoot issues. |
3bf02f7a-015b-4f93-be0f-cc043fda2dd3 |
| AutomaticRotation |
string |
Indicates whether automatic rotation is enabled. Valid values:
Catatan
This parameter is returned if SecretType is set to Rds, Redis, PolarDB, RAMCredentials, or ECS. |
Enabled |
| SecretName |
string |
The name of the secret. |
mydbconninfo |
| VersionId |
string |
The version number of the secret. |
v1 |
| NextRotationDate |
string |
The time when the secret is next rotated. Catatan
This parameter is returned if automatic rotation is enabled. |
2023-07-06T18:22:03Z |
| SecretType |
string |
The type of the secret. Valid values:
|
Rds |
| RotationInterval |
string |
The interval for automatic rotation. Catatan
This parameter is returned if automatic rotation is enabled. |
604800s |
| Arn |
string |
The Alibaba Cloud Resource Name (ARN) of the secret. |
acs:kms:cn-hangzhou:154035569884****:secret/mydbconninfo |
| ExtendedConfig |
string |
The extended configuration of the secret. Catatan
This parameter is returned if SecretType is set to Rds, Redis, PolarDB, RAMCredentials, or ECS. |
{\"SecretSubType\":\"SingleUser\", \"DBInstanceId\":\"rm-uf667446pc955****\", \"CustomData\":"Key1": "v1", "fds":"fdsf"} } |
| DKMSInstanceId |
string |
The ID of the KMS instance. |
kst-bjj62d8f5e0sgtx8h**** |
Contoh
Respons sukses
JSONformat
{
"RequestId": "3bf02f7a-015b-4f93-be0f-cc043fda2dd3",
"AutomaticRotation": "Enabled",
"SecretName": "mydbconninfo",
"VersionId": "v1",
"NextRotationDate": "2023-07-06T18:22:03Z",
"SecretType": "Rds",
"RotationInterval": "604800s",
"Arn": "acs:kms:cn-hangzhou:154035569884****:secret/mydbconninfo",
"ExtendedConfig": "{\\\"SecretSubType\\\":\\\"SingleUser\\\", \\\"DBInstanceId\\\":\\\"rm-uf667446pc955****\\\", \\\"CustomData\\\":\"Key1\": \"v1\", \"fds\":\"fdsf\"} }",
"DKMSInstanceId": "kst-bjj62d8f5e0sgtx8h****"
}
Kode kesalahan
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | UnsupportedOperation | This action is not supported. | The operation is not supported. |
| 400 | Rejected.LimitExceeded | The request was rejected because user create resource limit was exceeded | The request is rejected because the number of created resources reaches the upper limit. |
| 400 | InvalidParameter | The specified parameter is not valid. | An invalid value is specified for the parameter. |
| 400 | Rejected.ShareQuotaExceedLimit | Instance Share Quota Exceed Limit. | The instance share quota exceeds the limit. |
| 500 | InternalFailure | Internal Failure | An internal error occurred. |
| 403 | Forbidden.DKMSInstanceNotFound | The specified DKMS Instance is not found. | Your dedicated KMS instance is not found. |
| 404 | Forbidden.ResourceNotFound | The resource is not found. | The resource does not exist. |
| 409 | Rejected.ResourceExist | The resource already exists. | The resource already exists. |
| 409 | Rejected.ResourceInDeleteWindow | The secret is planned to be deleted. | The secret is to be deleted. |
Lihat Error Codes untuk daftar lengkap.
Catatan rilis
Lihat Release Notes untuk daftar lengkap.