-
Notifications
You must be signed in to change notification settings - Fork 1
/
aws-list-elasticache.sh
executable file
·142 lines (138 loc) · 4.94 KB
/
aws-list-elasticache.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
# Parse arguments:
VERBOSE=0
while getopts ":r:p:v" opt; do
case $opt in
r) REGION="--region $OPTARG";;
p) PROFILE="--profile $OPTARG";;
v) VERBOSE=$(( VERBOSE + 1 ));;
:) echo "Option -$OPTARG requires an argument." >&2; exit 1;;
\?) echo "Invalid option: -$OPTARG" >&2;;
esac
done
shift $((OPTIND-1))
if ! which jq > /dev/null 2>&1; then echo "The 'jq' command is not installed, aborting." >&2; exit 1; fi
if [[ "$VERBOSE" == 0 ]]; then aws $PROFILE $REGION elasticache describe-replication-groups | jq -r '.ReplicationGroups[] | select(.Status != "deleting") | .ReplicationGroupId'; exit 0; fi
if [[ "$VERBOSE" == 1 ]]; then aws $PROFILE $REGION elasticache describe-replication-groups | jq .; exit 0; fi
# {
# "ReplicationGroups": [
# {
# "Status": "available",
# "Description": "Something Demo001 Redis server -- https://w.amazon.com/index.php/AWS/Something/Operations",
# "NodeGroups": [
# {
# "Status": "available",
# "NodeGroupMembers": [
# {
# "CurrentRole": "primary",
# "PreferredAvailabilityZone": "us-west-2a",
# "CacheNodeId": "0001",
# "ReadEndpoint": {
# "Port": 6379,
# "Address": "something-001.jvxwxy.0001.usw2.cache.amazonaws.com"
# },
# "CacheClusterId": "something-001"
# },
# {
# "CurrentRole": "replica",
# "PreferredAvailabilityZone": "us-west-2b",
# "CacheNodeId": "0001",
# "ReadEndpoint": {
# "Port": 6379,
# "Address": "something-002.jvxwxy.0001.usw2.cache.amazonaws.com"
# },
# "CacheClusterId": "something-002"
# },
# {
# "CurrentRole": "replica",
# "PreferredAvailabilityZone": "us-west-2c",
# "CacheNodeId": "0001",
# "ReadEndpoint": {
# "Port": 6379,
# "Address": "something-003.jvxwxy.0001.usw2.cache.amazonaws.com"
# },
# "CacheClusterId": "something-003"
# }
# ],
# "NodeGroupId": "0001",
# "PrimaryEndpoint": {
# "Port": 6379,
# "Address": "something.jvxwxy.ng.0001.usw2.cache.amazonaws.com"
# }
# }
# ],
# "ClusterEnabled": false,
# "ReplicationGroupId": "something",
# "SnapshotRetentionLimit": 1,
# "AutomaticFailover": "disabled",
# "SnapshotWindow": "12:00-13:00",
# "SnapshottingClusterId": "something-002",
# "MemberClusters": [
# "something-001",
# "something-002",
# "something-003"
# ],
# "CacheNodeType": "cache.r3.large",
# "PendingModifiedValues": {}
# },
# {
# "Status": "available",
# "Description": "A redis server running with Events v0.3 to bridge between the old redis message bus and the new APIs",
# "NodeGroups": [
# {
# "Status": "available",
# "NodeGroupMembers": [
# {
# "CurrentRole": "primary",
# "PreferredAvailabilityZone": "us-west-2c",
# "CacheNodeId": "0001",
# "ReadEndpoint": {
# "Port": 6379,
# "Address": "eventsv3redis-001.jvxwxy.0001.usw2.cache.amazonaws.com"
# },
# "CacheClusterId": "eventsv3redis-001"
# },
# {
# "CurrentRole": "replica",
# "PreferredAvailabilityZone": "us-west-2a",
# "CacheNodeId": "0001",
# "ReadEndpoint": {
# "Port": 6379,
# "Address": "eventsv3redis-002.jvxwxy.0001.usw2.cache.amazonaws.com"
# },
# "CacheClusterId": "eventsv3redis-002"
# },
# {
# "CurrentRole": "replica",
# "PreferredAvailabilityZone": "us-west-2b",
# "CacheNodeId": "0001",
# "ReadEndpoint": {
# "Port": 6379,
# "Address": "eventsv3redis-003.jvxwxy.0001.usw2.cache.amazonaws.com"
# },
# "CacheClusterId": "eventsv3redis-003"
# }
# ],
# "NodeGroupId": "0001",
# "PrimaryEndpoint": {
# "Port": 6379,
# "Address": "eventsv3redis.jvxwxy.ng.0001.usw2.cache.amazonaws.com"
# }
# }
# ],
# "ClusterEnabled": false,
# "ReplicationGroupId": "eventsv3redis",
# "SnapshotRetentionLimit": 1,
# "AutomaticFailover": "disabled",
# "SnapshotWindow": "11:30-12:30",
# "SnapshottingClusterId": "eventsv3redis-002",
# "MemberClusters": [
# "eventsv3redis-001",
# "eventsv3redis-002",
# "eventsv3redis-003"
# ],
# "CacheNodeType": "cache.r3.large",
# "PendingModifiedValues": {}
# }
# ]
# }