如何将 KeyManager 添加到使用 moto 模拟的 kms 密钥

Stu*_*Cat 6 python amazon-web-services boto3 moto

我想创建一个由 AWS 管理的密钥。到目前为止,这就是我所拥有的

@mock_kms
def test_mocking_getting_keys(self):
    session = boto3.Session(profile_name=profile)
    client = session.client('kms', 'us-east-2')
    key = client.create_key(
        Policy='string',
        Description='string',
        KeyUsage='SIGN_VERIFY',
        CustomerMasterKeySpec='RSA_2048',
        Origin='AWS_KMS',
        CustomKeyStoreId='string',
        BypassPolicyLockoutSafetyCheck=True,
        Tags=[
            {
                'TagKey': 'string',
                'TagValue': 'string'
            },
        ]
    )
    print(key)
Run Code Online (Sandbox Code Playgroud)

但密钥似乎没有 KeyManager 字段:

 {'KeyMetadata': {'AWSAccountId': '012345678912', 'KeyId': '7fc3e676-0d1c-4526-9161-41b27a776033', 'Arn': 'arn:aws:kms:us-east-2:012345678912:key/7fc3e676-0d1c-4526-9161-41b27a776033', 'CreationDate': datetime.datetime(2020, 1, 3, 13, 31, 17, tzinfo=tzutc()), 'Enabled': True, 'Description': 'string', 'KeyUsage': 'SIGN_VERIFY', 'KeyState': 'Enabled'}, 'ResponseMetadata': {'HTTPStatusCode': 200, 'HTTPHeaders': {'server': 'amazon.com'}, 'RetryAttempts': 0}}
Run Code Online (Sandbox Code Playgroud)

我尝试在 create_key 调用期间将 KeyManager 添加为参数,但这也不起作用。

似乎 moto 不返回 KeyManager 字段。有没有办法专门模拟该返回值,但不更改其余参数的 dictionary.get 方法的行为?

IE

key['KeyMetadata']['AWSAccountId']将返回模拟值,然后 key['KeyMetadata']['KeyManager']返回另一个我可以指定的模拟值。

Nio*_*bos 2

Moto 目前未返回KeyManager属性,您可以在 Moto GitHub 上打开问题,或自行添加(本地或 PR 到上游)