Skip to main content
 首页 » 编程设计

python之如何在 Python 2.7 中创建 Lambda 函数来创建、重启、删除、修改 ElastiCache Redis

2024年10月01日9bonelee

目前我正在研究 Lambda 函数,以使用 Python 2.7 脚本创建、重启、删除、修改 ElastiCache Redis。
为此,我还需要 IAM 规则和政策。
我已经完成了 EC2、RDS 以及停止和启动操作。我还没有看到 ElastiCache Redis 的任何解决方案,所以你们能不能给我提供至少删除、创建 ElastiCache Redis 的脚本或解决方案。

请您参考如下方法:

您可以使用 AWS ElastiCache Python SDK使用 boto3 创建、重启、删除和修改。

例子:

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链接。