#创建Multi-AZ Redis Cache Cluster import boto3
elasticache = boto3.client('elasticache')
response = elasticache.create_cache_cluster( CacheClusterId='my-redis-cluster', NumCacheNodes=1, CacheNodeType='cache.t2.micro', Engine='redis', EngineVersion='5.0.6', CacheSubnetGroupName='my-subnet-group', PreferredAvailabilityZone='us-east-1c', AutoMinorVersionUpgrade=True, PreferredMaintenanceWindow='sun:05:00-sun:06:00', AZMode='cross-az', Port=6379, SecurityGroupIds=['cache-sg-group'], )
#设置备份策略 import boto3
elasticache = boto3.client('elasticache')
response = elasticache.modify_replication_group( ReplicationGroupId='my-replication-group', AutomaticFailoverEnabled=True, AutoMinorVersionUpgrade=True, CacheNodeType='cache.t2.micro', CacheParameterGroupName='default.redis5.0', CacheSecurityGroupNames=['cache-sg-group'], Engine='redis', EngineVersion='5.0.6', NumCacheClusters=1, PreferredMaintenanceWindow='sun:05:00-sun:06:00', ReplicasPerNodeGroup=1, SnapshotRetentionLimit=7, SnapshottingClusterId='my-redis-cluster', SnapshotWindow='22:00-23:00', TransitEncryptionEnabled=False, MultiAZEnabled=True, )