static string get_region(KPLNETConfiguration config, Ec2Metadata ec2_md) { if (AWSRegions.Unknown != config.region) { return(config.region.ToString()); } var ec2_region = ec2_md.get_region(); if (null != ec2_region) { StdErrorOut.Instance.StdError("Could not configure the region. It was not given in the config and we were unable to retrieve it from EC2 metadata."); throw new Exception("Could not configure the region. It was not given in the config and we were unable to retrieve it from EC2 metadata."); } return(ec2_region); }