目前我正在研究 Lambda 函数,以使用 Python 2.7 脚本创建、重启、删除、修改 ElastiCache Redis。
为此,我还需要 IAM 规则和政策。
我已经完成了 EC2、RDS 以及停止和启动操作。我还没有看到 ElastiCache Redis 的任何解决方案,所以你们能不能给我提供至少删除、创建 ElastiCache Redis 的脚本或解决方案。
请您参考如下方法:
您可以使用 AWS ElastiCache Python SDK使用 boto3 创建、重启、删除和修改。
- 创建:create_cache_cluster()
- 重启:reboot_cache_cluster()
- 删除:delete_cache_cluster()
- 修改:modify_cache_cluster()
例子:
import boto3
client = boto3.client('elasticache')
response = client.create_cache_cluster(
CacheClusterId='string',
ReplicationGroupId='string',
AZMode='single-az'|'cross-az',
PreferredAvailabilityZone='string',
PreferredAvailabilityZones=[
'string',
],
NumCacheNodes=123,
CacheNodeType='string',
Engine='string',
EngineVersion='string',
CacheParameterGroupName='string',
CacheSubnetGroupName='string',
CacheSecurityGroupNames=[
'string',
],
SecurityGroupIds=[
'string',
],
Tags=[
{
'Key': 'string',
'Value': 'string'
},
],
SnapshotArns=[
'string',
],
SnapshotName='string',
PreferredMaintenanceWindow='string',
Port=123,
NotificationTopicArn='string',
AutoMinorVersionUpgrade=True|False,
SnapshotRetentionLimit=123,
SnapshotWindow='string',
AuthToken='string'
)
有关参数的更多详细信息,请参阅 this链接。
