def build_instance_groups(parsed_instance_groups):
 instance_groups = []
 for instance_group in parsed_instance_groups:
  ig_config = {}
  keys = instance_group.keys()
  if ('Name' in keys):
   ig_config['Name'] = instance_group['Name']
  else:
   ig_config['Name'] = instance_group['InstanceGroupType']
  ig_config['InstanceType'] = instance_group['InstanceType']
  ig_config['InstanceCount'] = instance_group['InstanceCount']
  ig_config['InstanceRole'] = instance_group['InstanceGroupType'].upper()
  if ('BidPrice' in keys):
   ig_config['BidPrice'] = instance_group['BidPrice']
   ig_config['Market'] = constants.SPOT
  else:
   ig_config['Market'] = constants.ON_DEMAND
  if ('EbsConfiguration' in keys):
   ig_config['EbsConfiguration'] = instance_group['EbsConfiguration']
  if ('AutoScalingPolicy' in keys):
   ig_config['AutoScalingPolicy'] = instance_group['AutoScalingPolicy']
  instance_groups.append(ig_config)
 return instance_groups

def build_instance_groups ( parsed_instance_groups ) : instance_groups = [ ] for instance_group in parsed_instance_groups : ig_config = { } keys = instance_group . keys ( ) if ( 'Name' in keys ) : ig_config [ 'Name' ] = instance_group [ 'Name' ] else : ig_config [ 'Name' ] = instance_group [ 'InstanceGroupType' ] ig_config [ 'InstanceType' ] = instance_group [ 'InstanceType' ] ig_config [ 'InstanceCount' ] = instance_group [ 'InstanceCount' ] ig_config [ 'InstanceRole' ] = instance_group [ 'InstanceGroupType' ] . upper ( ) if ( 'BidPrice' in keys ) : ig_config [ 'BidPrice' ] = instance_group [ 'BidPrice' ] ig_config [ 'Market' ] = constants . SPOT else : ig_config [ 'Market' ] = constants . ON_DEMAND if ( 'EbsConfiguration' in keys ) : ig_config [ 'EbsConfiguration' ] = instance_group [ 'EbsConfiguration' ] if ( 'AutoScalingPolicy' in keys ) : ig_config [ 'AutoScalingPolicy' ] = instance_group [ 'AutoScalingPolicy' ] instance_groups . append ( ig_config ) return instance_groups
helper method that converts --instance-groups option value in create-cluster and add-instance-groups to amazon elastic mapreduce instancegroupconfig data type .