要了解AWS如何管理RDS的自动KMS密钥轮换,您需要使用AWS KMS(密钥管理服务)和AWS RDS(关系数据库服务)的API和工具。
以下是一个基本的代码示例,演示如何使用AWS CLI和AWS SDK for Python(Boto3)来启用和配置RDS实例的自动KMS密钥轮换。
首先,您需要安装并配置AWS CLI,并使用您的AWS凭证进行身份验证。
使用以下命令启用自动KMS密钥轮换:
aws rds modify-db-instance \
--db-instance-identifier \
--enable-key-rotation
替换
为您要启用自动KMS密钥轮换的RDS实例的标识符。
aws rds describe-db-instances \
--db-instance-identifier \
--query 'DBInstances[0].KeyRotationEnabled'
如果返回值为true
,则表示自动KMS密钥轮换已成功启用。
import boto3
rds_client = boto3.client('rds')
response = rds_client.modify_db_instance(
DBInstanceIdentifier='',
EnableKeyRotation=True
)
print(response)
替换
为您要启用自动KMS密钥轮换的RDS实例的标识符。
这样,您就可以使用AWS CLI和AWS SDK for Python(Boto3)来管理RDS实例的自动KMS密钥轮换。请参考AWS文档以了解更多详细信息和选项。