def check_write_instance_metadata(name, value):
 if is_google_instance():
  check_run_quick('gcloud compute instances add-metadata {hostname} --zone={zone} --metadata={name}={value}'.format(hostname=socket.gethostname(), zone=check_get_zone(), name=name, value=value))
 elif is_aws_instance():
  result = check_fetch(os.path.join(AWS_METADATA_URL, 'instance-id'))
  id = result.content.strip()
  result = check_fetch(os.path.join(AWS_METADATA_URL, 'placement/availability-zone'))
  region = result.content.strip()[:(-1)]
  command = ['aws ec2 create-tags --resources', id, '--region', region, '--tags Key={key},Value={value}'.format(key=name, value=value)]
  check_run_quick(' '.join(command), echo=False)
 else:
  raise NotImplementedError('This platform does not support metadata.')

def check_write_instance_metadata ( name , value ) : if is_google_instance ( ) : check_run_quick ( 'gcloud compute instances add-metadata {hostname} --zone={zone} --metadata={name}={value}' . format ( hostname = socket . gethostname ( ) , zone = check_get_zone ( ) , name = name , value = value ) ) elif is_aws_instance ( ) : result = check_fetch ( os . path . join ( AWS_METADATA_URL , 'instance-id' ) ) id = result . content . strip ( ) result = check_fetch ( os . path . join ( AWS_METADATA_URL , 'placement/availability-zone' ) ) region = result . content . strip ( ) [ : ( - 1 ) ] command = [ 'aws ec2 create-tags --resources' , id , '--region' , region , '--tags Key={key},Value={value}' . format ( key = name , value = value ) ] check_run_quick ( ' ' . join ( command ) , echo = False ) else : raise NotImplementedError ( 'This platform does not support metadata.' )
add a name/value pair to our instance metadata .