CloudWatch / Client / associate_dataset_kms_key
associate_dataset_kms_key¶
- CloudWatch.Client.associate_dataset_kms_key(**kwargs)¶
Associates 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:Decryptpermission on the key to read the encrypted data.Only the
defaultdataset is supported. Thedefaultdataset is implicit for every account in every Region — you do not need to create it before calling this operation.You can call
AssociateDatasetKmsKeyon 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 havekms:Decryptpermission on both the current key and the new key.The KMS key that you specify must meet all of the following requirements:
It must be a symmetric encryption KMS key (key spec
SYMMETRIC_DEFAULT, key usageENCRYPT_DECRYPT). Asymmetric keys, HMAC keys, and key material types other thanSYMMETRIC_DEFAULTare not supported.It must be enabled and not pending deletion.
Its key policy must grant the CloudWatch service principal (
cloudwatch.amazonaws.com) these permissions:kms:DescribeKey,kms:GenerateDataKey,kms:Encrypt,kms:Decrypt, andkms:ReEncrypt*. Amazon CloudWatch requires these permissions to manage the data on your behalf.The calling principal must have
kms:Decryptpermission on the key.It must be specified as a fully qualified key ARN. Key IDs, aliases, and alias ARNs are not accepted.
It must be in the same Amazon Web Services Region as the dataset.
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, andkms:ReEncrypt*. After those succeed, akms:Decryptdry-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’skms:Decryptdry-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:Decryptpermission 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.
See also: AWS API Documentation
Request Syntax
response = client.associate_dataset_kms_key( DatasetIdentifier='string', KmsKeyArn='string' )
- Parameters:
DatasetIdentifier (string) –
[REQUIRED]
Specifies the identifier of the dataset that you want to associate the KMS key with. For the
defaultdataset, you can specify eitherdefaultor the full dataset Amazon Resource Name (ARN) in the formatarn:aws:cloudwatch:Region:account-id:dataset/default.KmsKeyArn (string) –
[REQUIRED]
Specifies the Amazon Resource Name (ARN) of the customer managed KMS key to associate with the dataset. The key must be a symmetric encryption KMS key (
SYMMETRIC_DEFAULT) in the same Amazon Web Services Region as the dataset.The ARN must be in the format ``arn:aws:kms:Region:account-id:key/key-id ``. Key IDs, aliases, and alias ARNs are not accepted.
For more information about KMS key ARNs, see Key ARN in the Amazon Web Services Key Management Service Developer Guide.
- Return type:
dict
- Returns:
Response Syntax
{}Response Structure
(dict) –
Exceptions
CloudWatch.Client.exceptions.KmsAccessDeniedExceptionCloudWatch.Client.exceptions.KmsKeyNotFoundExceptionCloudWatch.Client.exceptions.ConflictExceptionCloudWatch.Client.exceptions.KmsKeyDisabledExceptionCloudWatch.Client.exceptions.ResourceNotFoundException