Smaws_Client_CloudWatch.AssociateDatasetKmsKeyAssociates an Amazon Web Services Key Management Service (Amazon Web Services KMS) customer managed key with the specified dataset. After this operation completes, all data published to the dataset is encrypted at rest using the specified KMS key. Callers must have kms:Decrypt permission on the key to read the encrypted data.
Only the default dataset is supported. The default dataset is implicit for every account in every Region — you do not need to create it before calling this operation.
You can call AssociateDatasetKmsKey on a dataset that is already associated with a KMS key to replace the existing key with a different one. To replace a key, the caller must have kms:Decrypt permission on both the current key and the new key.
The KMS key that you specify must meet all of the following requirements:
SYMMETRIC_DEFAULT, key usage ENCRYPT_DECRYPT). Asymmetric keys, HMAC keys, and key material types other than SYMMETRIC_DEFAULT are not supported.cloudwatch.amazonaws.com) these permissions: kms:DescribeKey, kms:GenerateDataKey, kms:Encrypt, kms:Decrypt, and kms:ReEncrypt*. Amazon CloudWatch requires these permissions to manage the data on your behalf.kms:Decrypt permission on the key.Before completing the association, Amazon CloudWatch validates the key by performing a series of dry-run KMS operations. Service-principal checks run first to verify that the key policy grants the required access to Amazon CloudWatch. These checks include kms:DescribeKey, kms:GenerateDataKey, kms:Encrypt, kms:Decrypt, and kms:ReEncrypt*. After those succeed, a kms:Decrypt dry-run is run with the caller's credentials to verify that the calling principal can use the key. When you are replacing an existing key, the caller's kms:Decrypt dry-run is run on the current key first, and only then on the new key.
If any of these checks fails, the operation fails and the existing key association (if any) remains unchanged. Common failure causes include the key being disabled, the key policy not granting the required permissions to Amazon CloudWatch, or the caller lacking kms:Decrypt permission on the key.
For more information about using customer managed keys with Amazon CloudWatch, see Encryption at rest with customer managed keys in the Amazon CloudWatch User Guide.
val error_to_string :
[ Smaws_Lib.Protocols.AwsQuery.error
| `ConflictException of Types.conflict_exception
| `KmsAccessDeniedException of Types.kms_access_denied_exception
| `KmsKeyDisabledException of Types.kms_key_disabled_exception
| `KmsKeyNotFoundException of Types.kms_key_not_found_exception
| `ResourceNotFoundException of Types.resource_not_found_exception ] ->
stringval request :
'http_type Smaws_Lib.Context.t ->
Types.associate_dataset_kms_key_input ->
(Types.associate_dataset_kms_key_output,
[> Smaws_Lib.Protocols.AwsQuery.error
| `ConflictException of Types.conflict_exception
| `KmsAccessDeniedException of Types.kms_access_denied_exception
| `KmsKeyDisabledException of Types.kms_key_disabled_exception
| `KmsKeyNotFoundException of Types.kms_key_not_found_exception
| `ResourceNotFoundException of Types.resource_not_found_exception ])
Stdlib.resultval request_with_metadata :
'http_type Smaws_Lib.Context.t ->
Types.associate_dataset_kms_key_input ->
(Types.associate_dataset_kms_key_output Smaws_Lib.Response.t,
[> Smaws_Lib.Protocols.AwsQuery.error
| `ConflictException of Types.conflict_exception
| `KmsAccessDeniedException of Types.kms_access_denied_exception
| `KmsKeyDisabledException of Types.kms_key_disabled_exception
| `KmsKeyNotFoundException of Types.kms_key_not_found_exception
| `ResourceNotFoundException of Types.resource_not_found_exception ]
* Smaws_Lib.Response.metadata)
Stdlib.result