2017-08-20 24 views
2

目前我正在使用Lambda函數來使用Python 2.7腳本創建,重新引導,刪除和修改ElastiCache Redis。
爲此,我還需要IAM規則和策略。
我完成了EC2,RDS與停止&開始操作。我還沒有看到ElastiCache Redis的任何解決方案,那麼您是否可以向任何人提供腳本或解決方案,至少可以刪除,創建ElastiCache Redis。如何在Python 2.7中創建Lambda函數來創建,重新引導,刪除和修改ElastiCache Redis?

回答

2

您可以使用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' 
) 

更多細節s參數參考this鏈接。

+0

Ashan,我試過但我沒有得到解決方案。我想知道如何在Lambda函數中呈現代碼以使其工作。 – Raju

+0

您是否爲Lambda訪問ElastiCache分配了具有所需權限的IAM角色? – Ashan

+0

是的,我給了完全訪問權限。你能提供給我精確的代碼在Python中。 – Raju

相關問題