def _diff_cache_cluster(current, desired):
 if (current.get('SecurityGroups') is not None):
  current['SecurityGroupIds'] = [s['SecurityGroupId'] for s in current['SecurityGroups']]
 if (current.get('CacheSecurityGroups') is not None):
  current['CacheSecurityGroupNames'] = [c['CacheSecurityGroupName'] for c in current['CacheSecurityGroups']]
 if (current.get('NotificationConfiguration') is not None):
  current['NotificationTopicArn'] = current['NotificationConfiguration']['TopicArn']
  current['NotificationTopicStatus'] = current['NotificationConfiguration']['TopicStatus']
 if (current.get('CacheParameterGroup') is not None):
  current['CacheParameterGroupName'] = current['CacheParameterGroup']['CacheParameterGroupName']
 modifiable = {'AutoMinorVersionUpgrade': 'AutoMinorVersionUpgrade', 'AZMode': 'AZMode', 'CacheNodeType': 'CacheNodeType', 'CacheNodeIdsToRemove': None, 'CacheParameterGroupName': 'CacheParameterGroupName', 'CacheSecurityGroupNames': 'CacheSecurityGroupNames', 'EngineVersion': 'EngineVersion', 'NewAvailabilityZones': None, 'NotificationTopicArn': 'NotificationTopicArn', 'NotificationTopicStatus': 'NotificationTopicStatus', 'NumCacheNodes': 'NumCacheNodes', 'PreferredMaintenanceWindow': 'PreferredMaintenanceWindow', 'SecurityGroupIds': 'SecurityGroupIds', 'SnapshotRetentionLimit': 'SnapshotRetentionLimit', 'SnapshotWindow': 'SnapshotWindow'}
 need_update = {}
 for (m, o) in modifiable.items():
  if (m in desired):
   if (not o):
    need_update[m] = desired[m]
   elif (m in current):
    if (current[m] != desired[m]):
     need_update[m] = desired[m]
 return need_update

def _diff_cache_cluster ( current , desired ) : if ( current . get ( 'SecurityGroups' ) is not None ) : current [ 'SecurityGroupIds' ] = [ s [ 'SecurityGroupId' ] for s in current [ 'SecurityGroups' ] ] if ( current . get ( 'CacheSecurityGroups' ) is not None ) : current [ 'CacheSecurityGroupNames' ] = [ c [ 'CacheSecurityGroupName' ] for c in current [ 'CacheSecurityGroups' ] ] if ( current . get ( 'NotificationConfiguration' ) is not None ) : current [ 'NotificationTopicArn' ] = current [ 'NotificationConfiguration' ] [ 'TopicArn' ] current [ 'NotificationTopicStatus' ] = current [ 'NotificationConfiguration' ] [ 'TopicStatus' ] if ( current . get ( 'CacheParameterGroup' ) is not None ) : current [ 'CacheParameterGroupName' ] = current [ 'CacheParameterGroup' ] [ 'CacheParameterGroupName' ] modifiable = { 'AutoMinorVersionUpgrade' : 'AutoMinorVersionUpgrade' , 'AZMode' : 'AZMode' , 'CacheNodeType' : 'CacheNodeType' , 'CacheNodeIdsToRemove' : None , 'CacheParameterGroupName' : 'CacheParameterGroupName' , 'CacheSecurityGroupNames' : 'CacheSecurityGroupNames' , 'EngineVersion' : 'EngineVersion' , 'NewAvailabilityZones' : None , 'NotificationTopicArn' : 'NotificationTopicArn' , 'NotificationTopicStatus' : 'NotificationTopicStatus' , 'NumCacheNodes' : 'NumCacheNodes' , 'PreferredMaintenanceWindow' : 'PreferredMaintenanceWindow' , 'SecurityGroupIds' : 'SecurityGroupIds' , 'SnapshotRetentionLimit' : 'SnapshotRetentionLimit' , 'SnapshotWindow' : 'SnapshotWindow' } need_update = { } for ( m , o ) in modifiable . items ( ) : if ( m in desired ) : if ( not o ) : need_update [ m ] = desired [ m ] elif ( m in current ) : if ( current [ m ] != desired [ m ] ) : need_update [ m ] = desired [ m ] return need_update
if you need to enhance what modify_cache_cluster() considers when deciding what is to be updated .