def describe(): #client = boto3.client('cloudfront') client = hp.getBotoClient('cloudfront', region_name="us-east-1") dists = client.list_distributions()['DistributionList'].get('Items') if dists is None: # set to emmpty to list if no distribution found dists = [] ids, dnses, cnames, prices, originIDs, originDNSs, defaultPaths, defaultViewers, defaultAlloweds, defaultminTTL, defaultDefaultTTL, defaultMaxTTL, defaultSmooth, others = [ ], [], [], [], [], [], [], [], [], [], [], [], [], [] # OriginProtocolPolicys = [] for dist in dists: id = hp.getFromJSON(dist, 'Id') dns = hp.getFromJSON(dist, 'DomainName') cname = hp.getFromJSON(dist, 'Aliases') if hp.getFromJSON(cname, 'Quantity') is not 0: cname = hp.listToString(hp.getFromJSON(cname, 'Items ')) else: cname = np.NaN price = hp.getFromJSON(dist, 'PriceClass') origin = hp.getFromJSON(hp.getFromJSON(dist, 'Origins'), 'Items') originID = hp.listToString(origin, 'Id') originDNS = hp.listToString(origin, 'DomainName') default = hp.getFromJSON(dist, 'DefaultCacheBehavior') path, viewer, allowed, minTTL, defaultTTL, maxTTL, smooth = parseCloudFrontBehaviour( default, True) other = formatOtherCloudFrontBehaviours( hp.getFromJSON(hp.getFromJSON(dist, 'CacheBehaviors'), 'Items')) ids.append(id) dnses.append(dns) prices.append(price) cnames.append(cname) originIDs.append(originID) originDNSs.append(originDNS) defaultPaths.append(path) defaultViewers.append(viewer) defaultAlloweds.append(allowed) defaultminTTL.append(minTTL) defaultDefaultTTL.append(defaultTTL) defaultMaxTTL.append(maxTTL) defaultSmooth.append(smooth) others.append(other) # OriginProtocolPolicys.append(dist['Origins']['Items'][0]['CustomOriginConfig']['OriginProtocolPolicy']) df = pd.DataFrame({ "ID": ids, "DNS": dnses, "Cname": cnames, "Price Class": prices, "Origin ID": originIDs, "Origin DNS": originDNSs, "Default Behaviour: Path": defaultPaths, "Viewer Protocol Policy": defaultViewers, "Allowed Methods": defaultAlloweds, "Min TTL": defaultminTTL, "Default TTL": defaultDefaultTTL, "Max TTL": defaultMaxTTL, "Smooth Streaming": defaultSmooth, "Other Cache Behaviours": others }) return df
def describe(): #print("Start describing IAM") iam = hp.getBotoClient('iam', region_name="us-east-1") users = iam.list_users()['Users'] usernames = [] inlines = [] attacheds = [] for user in users: username = hp.getFromJSON(user, 'UserName') usernames.append(username) inline = iam.list_user_policies(UserName=username)['PolicyNames'] attached = iam.list_attached_user_policies( UserName=username)['AttachedPolicies'] # find inline policies inline = hp.listToString(inline, None) inlines.append(inline) # find attached policy attached = hp.listToString(attached, 'PolicyName') attacheds.append(attached) df = pd.DataFrame({ "Username": usernames, "Inline policy": inlines, "Attached policy": attacheds }) return df
def describe_VPN(): # client = boto3.client('ec2') client = hp.getBotoClient('ec2') vpns = client.describe_vpn_connections()['VpnConnections'] vpnnames, vpnids, vgwnames, vgwids, cgwnames, cgwids, statics, routeses = [],[],[],[],[],[],[],[] vgw_vpcs, cgw_ips = [], [] for vpn in vpns: vgwid = hp.getFromJSON(vpn, 'VpnGatewayId') # get vgw name from vgw id if not hp.isEmpty(vgwid): vgw = client.describe_vpn_gateways( VpnGatewayIds=[vgwid])['VpnGateways'][0] vgwname = hp.findNameinTags(vgw) else: vgwname = vgwid cgwid = hp.getFromJSON(vpn, 'CustomerGatewayId') # get cgw name from cgw id if not hp.isEmpty(cgwid): cgw = client.describe_customer_gateways( CustomerGatewayIds=[cgwid])['CustomerGateways'][0] cgwname = hp.findNameinTags(cgw) else: cgwname = cgwid vpnid = hp.getFromJSON(vpn, 'VpnConnectionId') vpnname = hp.findNameinTags(vpn) static = hp.getFromJSON(hp.getFromJSON(vpn, 'Options'), 'StaticRoutesOnly') routes = hp.getFromJSON(vpn, 'Routes') routes = hp.listToString(routes, 'DestinationCidrBlock') if vgwname not in vgwnames: vgwnames.append(vgwname) vgwids.append(vgwid) vgw_vpcs.append(get_vgw_vpc(vgwid)) cgwnames.append(cgwname) cgwids.append(cgwid) vpnnames.append(vpnname) vpnids.append(vpnid) statics.append(static) routeses.append(routes) cgw_ips.append(get_cgw_ip(cgwid)) cgwdf = pd.DataFrame({ "CGW Name": cgwnames, "CGW ID": cgwids, "CGW IP": cgw_ips }) vgwdf = pd.DataFrame({ "VGW Name": vgwnames, "VGW ID": vgwids, "VGW VPC": vgw_vpcs }) vpndf = pd.DataFrame({ "VPN Name": vpnnames, "VPN ID": vpnids, "Routes": routeses }) return cgwdf, vgwdf, vpndf
def parseSourceDest(permission): ipRanges = hp.getFromJSON(permission, 'IpRanges') ipRanges = hp.listToString(ipRanges, 'CidrIp') groups = hp.getFromJSON(permission, 'UserIdGroupPairs') groups = hp.listToString(groups, 'GroupId') prefixlist = hp.getFromJSON(permission, 'PrefixListIds') prefixlist = hp.listToString(prefixlist, 'PrefixListId') # print(ipRanges, groups, prefixlist) if not isinstance(ipRanges, str): ipRanges = '' if not isinstance(groups, str): groups = '' if not isinstance(prefixlist, str): prefixlist = '' ret = checktype(ipRanges) + ';' + checktype(groups) + ';' + checktype( prefixlist) # print(ret) return ret.strip(';')
def parseCloudFrontBehaviour(behaviour, default=False): if default: path = "*" else: path = hp.getFromJSON(behaviour, 'PathPattern') viewer = hp.getFromJSON(behaviour, 'ViewerProtocolPolicy') allowed = hp.getFromJSON(behaviour, 'AllowedMethods') allowed = hp.listToString(hp.getFromJSON(allowed, 'Items')) minTTL = hp.getFromJSON(behaviour, 'MinTTL') maxTTL = hp.getFromJSON(behaviour, 'MaxTTL') defaultTTL = hp.getFromJSON(behaviour, 'DefaultTTL') smooth = hp.getFromJSON(behaviour, 'SmoothStreaming') return path, viewer, allowed, minTTL, defaultTTL, maxTTL, smooth
def describe(): client = hp.getBotoClient('rds') #placeholder names, dbNames, endpoints, rendpoints, multiAZs, engines, engineVersions, ports, masterUsers, sgs, instanceClasses = [],[],[],[],[],[],[],[],[],[],[] DBids, storage_types, storage_sizes, MaxAllocatedStorages, DBSecurityGroups, DeletionProtections, PerformanceInsightsEnableds, EnabledCloudwatchLogsExports = [],[],[],[],[],[],[],[] # Aurora Cluster #TODO: currently only show the first 100 clusters = client.describe_db_clusters()['DBClusters'] for cluster in clusters: name = hp.getFromJSON(cluster, 'DBClusterIdentifier') dbName = hp.getFromJSON(cluster, 'DatabaseName') endpoint= hp.getFromJSON(cluster,'Endpoint') rendpoint= hp.getFromJSON(cluster,'ReaderEndpoint') multiAZ = hp.getFromJSON(cluster,'MultiAZ') engine = hp.getFromJSON(cluster,'Engine') engineVersion = hp.getFromJSON(cluster, 'EngineVersion') port = hp.getFromJSON(cluster, 'Port') masterUser = hp.getFromJSON(cluster, 'MasterUsername') sg = hp.getFromJSON(cluster, 'VpcSecurityGroups') sg = hp.listToString(sg,'VpcSecurityGroupId') arn = hp.getFromJSON(cluster, 'DBClusterArn') instances = client.describe_db_instances(Filters=[{'Name': "db-cluster-id", "Values":[arn]}])['DBInstances'] instanceClass = hp.listToString(instances, 'DBInstanceClass') names.append(name) dbNames.append(dbName) endpoints.append(endpoint) rendpoints.append(rendpoint) multiAZs.append(multiAZ) engines.append(engine) engineVersions.append(engineVersion) ports.append(port) masterUsers.append(masterUser) sgs.append(sg) instanceClasses.append(instanceClass) DBids.append('') storage_types.append('') storage_sizes.append('') MaxAllocatedStorages.append('') DBSecurityGroups.append(get_security_group_name(cluster['VpcSecurityGroups'])) DeletionProtections.append(cluster['DeletionProtection']) PerformanceInsightsEnableds.append('N/A') if 'EnabledCloudwatchLogsExports' in cluster: EnabledCloudwatchLogsExports.append(','.join(cluster['EnabledCloudwatchLogsExports'])) else: EnabledCloudwatchLogsExports.append('') # RDS Instance # TODO: currently only showing the first 100 instances = client.describe_db_instances()['DBInstances'] for instance in instances: engine = hp.getFromJSON(instance,'Engine') if engine == "aurora": continue name = hp.getFromJSON(instance,'DBInstanceIdentifier') instanceClass = hp.getFromJSON(instance, 'DBInstanceClass') dbName = hp.getFromJSON(instance,'DBName') endpoint=hp.getFromJSON(hp.getFromJSON(instance,'Endpoint'), 'Address') port = hp.getFromJSON(hp.getFromJSON(instance,'Endpoint'), 'Port') multiAZ = hp.getFromJSON(instance,'MultiAZ') engineVersion = hp.getFromJSON(instance, 'EngineVersion') masterUser = hp.getFromJSON(instance,'MasterUsername') sg = hp.getFromJSON(instance, 'VpcSecurityGroups') sg = hp.listToString(sg,'VpcSecurityGroupId') names.append(name) dbNames.append(dbName) endpoints.append(endpoint) rendpoints.append(np.NaN) multiAZs.append(multiAZ) engines.append(engine) engineVersions.append(engineVersion) ports.append(port) masterUsers.append(masterUser) sgs.append(sg) instanceClasses.append(instanceClass) DBids.append(instance['DbiResourceId']) storage_types.append(instance['StorageType']) storage_sizes.append(instance['AllocatedStorage']) if 'MaxAllocatedStorage' in instance: MaxAllocatedStorages.append(instance['MaxAllocatedStorage']) else: MaxAllocatedStorages.append('') DBSecurityGroups.append(get_security_group_name(instance['VpcSecurityGroups'])) DeletionProtections.append(instance['DeletionProtection']) PerformanceInsightsEnableds.append(instance['PerformanceInsightsEnabled']) if 'EnabledCloudwatchLogsExports' in instance: EnabledCloudwatchLogsExports.append(','.join(instance['EnabledCloudwatchLogsExports'])) else: EnabledCloudwatchLogsExports.append('') df = pd.DataFrame({"Identifier": names, "Engine": engines, "Engine Version": engineVersions, "Multi AZ": multiAZs, \ "Endpoint": endpoints, "Reader Endpoint": rendpoints, "DB Name": dbNames,"Port": ports ,"User Name": masterUsers, \ "Security Group": sgs, "Instance Class": instanceClasses, "DB instance id": DBids, "Storage type": storage_types, \ "Storage Size": storage_sizes, "Maximum storage threshold": MaxAllocatedStorages, "Deletion protection" : DeletionProtections, \ "Performance Insights enabled": PerformanceInsightsEnableds, "CloudWatch Logs": EnabledCloudwatchLogsExports }) return df
def describe(): #client = boto3.client('ec2') client = hp.getBotoClient('ec2') reservations = client.describe_instances()['Reservations'] names = [] instancetypes = [] azs = [] amis = [] publicips = [] publicDNSes = [] privateips = [] privateDNSes = [] vpcIds = [] subnets = [] keys = [] securitygroups = [] ebsVolumes = [] ebsSizes = [] encrypteds, deletonterminates = [], [] for reservation in reservations: instances = reservation['Instances'] for instance in instances: if instance['State']['Name'] == 'terminated': continue name = hp.findNameinTags(instance) instanceType = hp.getFromJSON(instance,'InstanceType') az = hp.getFromJSON(hp.getFromJSON(instance,'Placement'),'AvailabilityZone') ami = hp.getFromJSON(instance,'ImageId') publicip = hp.getFromJSON(instance, 'PublicIpAddress') if not isinstance(publicip, str): publicip = 'N/A' publicDNS = hp.getFromJSON(instance, 'PublicDnsName') if publicDNS == '': publicDNS = 'N/A' privateip = hp.getFromJSON(instance, 'PrivateIpAddress') privateDNS = hp.getFromJSON(instance, 'PrivateDnsName') vpcId = hp.getFromJSON(instance, 'VpcId') subnetId = hp.getFromJSON(instance, 'SubnetId') key = hp.getFromJSON(instance, 'KeyName') sgs = hp.getFromJSON(instance, 'SecurityGroups') sgs = hp.listToString(sgs, 'GroupName') #EBS id = hp.getFromJSON(instance, 'InstanceId') filters = [{'Name': "attachment.instance-id", 'Values': [id]}] volumes = client.describe_volumes(Filters=filters)['Volumes'] types = hp.listToString(volumes, 'VolumeType') sizes = hp.listToString(volumes,'Size') size_list = sizes.split(';') tmp = [] for item in size_list: tmp.append(item + 'GB') sizes = ';'.join(tmp) ebs_id = hp.listToString(volumes,'VolumeId') names.append(name) instancetypes.append(instanceType) azs.append(az) amis.append(ami) publicips.append(publicip) publicDNSes.append(publicDNS) if privateip == np.NaN: privateip = 'N/A' privateips.append(privateip) privateDNSes.append(privateDNS) vpcIds.append(vpcId) subnets.append(subnetId) keys.append(key) securitygroups.append(sgs) ebsVolumes.append(types) ebsSizes.append(sizes) ebs_attr = get_volumes_attribute(ebs_id) # ebs_attr = get_volume_attribute(ebs_id) encrypteds.append(ebs_attr['Encrypted']) deletonterminates.append(ebs_attr['DeleteOnTermination']) print(publicDNSes) df = pd.DataFrame({"EC2 Name": names, "Instance Type": instancetypes, "AZ": azs, "AMI": amis, "Public IP": publicips, "Public DNS": publicDNSes, "Private IP": privateips, "Private DNS": privateDNSes, "VPC ID": vpcIds, "Subnet ID": subnets, "Key": keys,"Security Groups": securitygroups, "EBS Type": ebsVolumes, "EBS Size": ebsSizes, "Encrypted": encrypteds}) return df
def describe_ELB(): #TODO: Change sg -> name # instance -> name # client = boto3.client('elbv2') client = hp.getBotoClient('elbv2') elbs = client.describe_load_balancers()['LoadBalancers'] #place holder for elb elbname, elbdns, elbscheme, elbVpc, elbType, elbAZ, elbSubnet, elbSG = [],[],[], [], [], [], [], [] #place holder for listener listenerProtocol,listenerPort,listenerDefaultSSL,listenerOtherSSL,listenerElb = [],[],[], [], [] #place holder for tg targetELB, targetNames, protocols, ports, unhealthys, healthys, healthpaths, healthports, healthprotocols, healthTimeouts, healthIntervals, registereds = [],[],[], [], [], [], [], [], [], [], [], [] targettypes = [] for elb in elbs: name = hp.getFromJSON(elb, 'LoadBalancerName') dns = hp.getFromJSON(elb, 'DNSName') scheme = hp.getFromJSON(elb, 'Scheme') vpc = hp.getFromJSON(elb, 'VpcId') type = hp.getFromJSON(elb, 'Type') azs = hp.listToString(hp.getFromJSON(elb, 'AvailabilityZones'), 'ZoneName') subnets = hp.listToString(hp.getFromJSON(elb, 'AvailabilityZones'), 'SubnetId') sgs = hp.listToString(hp.getFromJSON(elb, 'SecurityGroups'), None) arn = hp.getFromJSON(elb, 'LoadBalancerArn') elbname.append(name) elbdns.append(dns) elbscheme.append(scheme) elbType.append(type) elbVpc.append(vpc) elbAZ.append(azs) elbSubnet.append(subnets) elbSG.append(sgs) # Listeners listeners = client.describe_listeners(LoadBalancerArn=arn)['Listeners'] for listener in listeners: protocol = hp.getFromJSON(listener, 'Protocol') port = hp.getFromJSON(listener, 'Port') sslids = hp.getFromJSON(listener, 'Certificates') default_ssl = np.NaN other_ssls = [] if not hp.isEmpty(sslids): for sslid in sslids: ssl = hp.getFromJSON(sslid, 'CertificateArn') ssl = ssl + " (" + hp.getDomainsFromACM(ssl) + ")" if hp.getFromJSON(sslid, 'IsDefault'): default_ssl = ssl else: other_ssls.append(ssl) other_ssls = hp.listToString(other_ssls, None) listenerElb.append(name) listenerProtocol.append(protocol) listenerPort.append(port) listenerDefaultSSL.append(default_ssl) listenerOtherSSL.append(other_ssls) # Target Group targets = client.describe_target_groups( LoadBalancerArn=arn)['TargetGroups'] for target in targets: targetName = hp.getFromJSON(target, 'TargetGroupName') protocol = hp.getFromJSON(target, 'Protocol') port = hp.getFromJSON(target, 'Port') arn = hp.getFromJSON(target, 'TargetGroupArn') targetType = hp.getFromJSON(target, 'TargetType') #Health Check unhealthy = hp.getFromJSON(target, 'UnhealthyThresholdCount') healthy = hp.getFromJSON(target, 'HealthyThresholdCount') healthpath = hp.getFromJSON(target, 'HealthCheckPath') healthport = hp.getFromJSON(target, 'HealthCheckPort') healthprotocol = hp.getFromJSON(target, 'HealthCheckProtocol') healthTimeout = hp.getFromJSON(target, 'HealthCheckTimeoutSeconds') healthInterval = hp.getFromJSON(target, 'HealthCheckIntervalSeconds') #Instances healths = client.describe_target_health( TargetGroupArn=arn)['TargetHealthDescriptions'] instances = [] for health in healths: instance = hp.getFromJSON(health, 'Target') instanceId = hp.getFromJSON(instance, 'Id') instances.append(instanceId) instances = hp.listToString(instances, None) targetELB.append(name) targetNames.append(targetName) protocols.append(protocol) ports.append(port) unhealthys.append(unhealthy) healthys.append(healthy) healthpaths.append(healthpath) healthports.append(healthport) healthprotocols.append(healthprotocol) healthTimeouts.append(healthTimeout) healthIntervals.append(healthInterval) registereds.append(instances) targettypes.append(target['TargetType']) elbdf = pd.DataFrame({ "ELB Name": elbname, "Type": elbType, "DNS": elbdns, "Internal/Internet Facing": elbscheme, "VPC": elbVpc, "AZ": elbAZ, "Subnet": elbSubnet, "SG": elbSG }) listenerdf = pd.DataFrame({ "ELB Name": listenerElb, "Protocol": listenerProtocol, "Port": listenerPort, "Default Cert": listenerDefaultSSL, "Other Certs": listenerOtherSSL }) tgdf = pd.DataFrame({ "ELB Name": targetELB, "Target Group Name": targetNames, "Protocol": protocols, "Port": ports, "Registered Instances": registereds, "Healthy Threshold": healthys, "Unhealthy Threshold": unhealthys, "Health Check Path": healthpaths, "Health Check Protocol": healthprotocols, "Health Check Port": healthports, "Health Check Timeout": healthTimeouts, "Health Check Interval": healthIntervals, 'Target Type': targettypes }) return elbdf, listenerdf, tgdf
def describe_CLB(): #client = boto3.client('elb') client = hp.getBotoClient('elb') clbs = client.describe_load_balancers()['LoadBalancerDescriptions'] # placeholder for clb names, dnses, schemes, vpcs, listenerProtocols, listenerPorts, instanceProtocols, instancePorts, ssls, azes, subnetIds,securitys, registereds, healthTargets, healthIntervals, healthTimeouts, unhealthys, healthys= [], [],[],[], [], [], [], [], [], [], [], [], [], [], [], [], [], [] for clb in clbs: name = hp.getFromJSON(clb, 'LoadBalancerName') dns = hp.getFromJSON(clb, 'DNSName') scheme = hp.getFromJSON(clb, 'Scheme') vpc = hp.getFromJSON(clb, 'VPCId') azs = hp.listToString(hp.getFromJSON(clb, 'AvailabilityZones'), None) subnets = hp.listToString(hp.getFromJSON(clb, 'Subnets'), None) sgs = hp.listToString(hp.getFromJSON(clb, 'SecurityGroups'), None) instances = hp.getFromJSON(clb, 'Instances') instances = hp.listToString(instances, 'InstanceId') healthCheck = hp.getFromJSON(clb, 'HealthCheck') target = hp.getFromJSON(healthCheck, 'Target') interval = hp.getFromJSON(healthCheck, 'Interval') timeout = hp.getFromJSON(healthCheck, 'Timeout') unhealthy = hp.getFromJSON(healthCheck, 'UnhealthyThreshold') healthy = hp.getFromJSON(healthCheck, 'HealthyThreshold') listeners = hp.getFromJSON(clb, 'ListenerDescriptions') for listener in listeners: listener = hp.getFromJSON(listener, 'Listener') protocol = hp.getFromJSON(listener, 'Protocol') port = hp.getFromJSON(listener, 'LoadBalancerPort') instanceProtocol = hp.getFromJSON(listener, 'InstanceProtocol') instancePort = hp.getFromJSON(listener, 'InstancePort') sslid = hp.getFromJSON(listener, 'SSLCertificateId') ssl = sslid + " (" + hp.getDomainsFromACM(sslid) + ")" names.append(name) dnses.append(dns) schemes.append(scheme) vpcs.append(vpc) registereds.append(instances) azes.append(azs) subnetIds.append(subnets) securitys.append(sgs) listenerProtocols.append(protocol) listenerPorts.append(port) instanceProtocols.append(instanceProtocol) instancePorts.append(instancePort) ssls.append(ssl) healthTargets.append(target) healthIntervals.append(interval) healthTimeouts.append(timeout) unhealthys.append(unhealthy) healthys.append(healthy) #TODO: Change security group -> name # Change instance -> instance name df = pd.DataFrame({ "CLB Name": names, "CLB DNS": dnses, "Internal/Internet Facing": schemes, "VPC": vpcs, "Registered Instances": registereds, "AZ": azes, "Subnet": subnetIds, "Security Group": securitys, "Listener Protocol": listenerProtocols, "Listener Port": listenerPorts, "Instance Protocol": instancePorts, "SSL": ssls, "Health Check": healthTargets, "Health Check Interval": healthIntervals, "Health Check Timeout": healthTimeouts, "Unhealthy Threshold": unhealthys, "Healthy Threshold": healthys }) return df
def describe(): #client = boto3.client('elasticache') client = hp.getBotoClient('elasticache') # For Memcached clusters = client.describe_cache_clusters( ShowCacheClustersNotInReplicationGroups=True)['CacheClusters'] names, endpoints, ports, engines, engineversions, subnetgroups, nodeTypes, azs, sgs, maintenances, backups = [],[],[],[],[],[],[],[],[], [], [] for cluster in clusters: name = hp.getFromJSON(cluster, 'CacheClusterId') engine = hp.getFromJSON(cluster, 'Engine') engineversion = hp.getFromJSON(cluster, 'EngineVersion') endpoint = hp.getFromJSON( hp.getFromJSON(cluster, 'ConfigurationEndpoint'), 'Address') port = hp.getFromJSON(hp.getFromJSON(cluster, 'ConfigurationEndpoint'), 'Port') subnetgroup = hp.getFromJSON(cluster, 'CacheSubnetGroupName') nodeType = hp.getFromJSON(cluster, 'CacheNodeType') az = hp.getFromJSON(cluster, 'PreferredAvailabilityZone') sg = hp.getFromJSON(cluster, 'SecurityGroups') sg = hp.listToString(sg, 'SecurityGroupId') maintenance = hp.getFromJSON(cluster, 'PreferredMaintenanceWindow') backup = hp.getFromJSON(cluster, 'SnapshotWindow') names.append(name) endpoints.append(endpoint) ports.append(port) engines.append(engine) engineversions.append(engineversion) subnetgroups.append(subnetgroup) nodeTypes.append(nodeType) azs.append(az) sgs.append(sg) maintenances.append(maintenance) backups.append(backup) # For Redis replications = client.describe_replication_groups()['ReplicationGroups'] for replication in replications: name = hp.getFromJSON(replication, 'ReplicationGroupId') if hp.getFromJSON(replication, 'ClusterEnabled'): endpoint = hp.getFromJSON( hp.getFromJSON(replication, 'ConfigurationEndpoint'), 'Address') port = hp.getFromJSON( hp.getFromJSON(replication, 'ConfigurationEndpoint'), 'Port') else: endpoint = hp.getFromJSON( hp.getFromJSON( hp.getFromJSON(replication, 'NodeGroups')[0], 'PrimaryEndpoint'), 'Address') port = hp.getFromJSON( hp.getFromJSON( hp.getFromJSON(replication, 'NodeGroups')[0], 'PrimaryEndpoint'), 'Port') backup = hp.getFromJSON(replication, 'SnapshotWindow') # Get Info from one of the cluster under the replication group cluster = hp.getFromJSON(replication, 'MemberClusters')[0] cluster = client.describe_cache_clusters( CacheClusterId=cluster)['CacheClusters'][0] engineversion = hp.getFromJSON(cluster, 'EngineVersion') subnetgroup = hp.getFromJSON(cluster, 'CacheSubnetGroupName') sg = hp.getFromJSON(cluster, 'SecurityGroups') sg = hp.listToString(sg, 'SecurityGroupId') maintenance = hp.getFromJSON(cluster, 'PreferredMaintenanceWindow') names.append(name) endpoints.append(endpoint) ports.append(port) engines.append("redis") nodeType = hp.getFromJSON(replication, 'CacheNodeType') engineversions.append(engineversion) subnetgroups.append(subnetgroup) nodeTypes.append(nodeType) azs.append("Multiple") sgs.append(sg) maintenances.append(maintenance) backups.append(backup) df = pd.DataFrame({ "Name": names, "Endpoint": endpoints, "Port": ports, "Engine": engines, "Engine Version": engineversions, "Subnet Group": subnetgroups, "Node Type": nodeTypes, "AZ": azs, "Security Group": sgs, "Maintenance Window": maintenances, "Back Up Window": backups }) return df