KMSKey
查询密钥管理服务 (Key Management Service) 密钥的 KMSClient.*
方法返回一些 KMSKey
实例。特别是,listKeys()
返回一个 KMSKey
对象数组。KMSKey
对象描述了一个 Amazon 密钥管理服务密钥。
名称 | 类型 | 描述 |
---|---|---|
KMSKey.keyId | string | 密钥的唯一标识符 |
KMSKey.keyArn | string | 密钥的 ARN |
示例
import exec from 'k6/execution';
import {
AWSConfig,
KMSClient,
} from 'https://jslib.k6.io/aws/0.13.0/kms.js';
const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
accessKeyId: __ENV.AWS_ACCESS_KEY_ID,
secretAccessKey: __ENV.AWS_SECRET_ACCESS_KEY,
});
const kms = new KMSClient(awsConfig);
const testKeyId = 'e67f95-4c047567-4-a0b7-62f7ce8ec8f48';
export default async function () {
// List the KMS keys the AWS authentication configuration
// gives us access to.
const keys = await kms.listKeys();
// If our test key does not exist, abort the execution.
if (keys.filter((b) => b.keyId === testKeyId).length == 0) {
exec.test.abort();
}
}
一个 k6 脚本,查询用户的密钥管理服务密钥并验证其测试密钥是否存在