【发布时间】:2021-09-28 15:44:18
【问题描述】:
我想获取 elasticache cache_cluster_id 以填充 jinja2 模板。
我正在使用 boto 从 API 中获取一些东西,例如 ec2 实例或 elb 数据,但对于 elasticache 来说似乎更困难。
import boto.elasticache
conn = boto.elasticache.connect_to_region(region)
elasticache_data = conn.describe_cache_clusters()
这就是我设法得到的,但我不确定如何循环通过 cache_cluster_id 来获取我需要的所有数据。
参考:http://docs.pythonboto.org/en/latest/ref/elasticache.html
api 答案是这样的:
> {u'DescribeCacheClustersResponse':
> {u'ResponseMetadata':
> {u'RequestId': u'ID'},
> u'DescribeCacheClustersResult':
> {u'Marker': None,
> u'CacheClusters':
> [
> {u'Engine': u'redis', u'CacheParameterGroup':
> {u'CacheNodeIdsToReboot': [],
> u'CacheParameterGroupName': u'default',
> u'ParameterApplyStatus': u'in-sync'},
> u'CacheClusterId': u'whatever',
> u'CacheSecurityGroups': [],
> u'ConfigurationEndpoint': None,
> u'CacheClusterCreateTime': 1415217879.493,
> u'ReplicationGroupId': u'whatever',
> u'AutoMinorVersionUpgrade': True,
> u'CacheClusterStatus': u'available',
> u'NumCacheNodes': 1,
> u'ClientDownloadLandingPage': u'https://console.aws.amazon.com...',
> u'PreferredAvailabilityZone': u'us-east-1a',
> u'SecurityGroups': [{u'Status': u'active', u'SecurityGroupId': u'123'}],
> u'CacheSubnetGroupName': u'whatever',
> u'EngineVersion': u'2.8.6',
> u'PendingModifiedValues':
> {u'NumCacheNodes': None,
> u'EngineVersion': None,
> u'CacheNodeIdsToRemove': None},
> u'CacheNodeType': u'cache.m1.small',
> u'NotificationConfiguration': None,
> u'PreferredMaintenanceWindow':
> u'sat:04:30-sat:05:30',
> u'CacheNodes': None
> }
> ]
> }
> } }
【问题讨论】:
标签: python amazon-web-services boto amazon-elasticache