public bool AddAccount(string accountName, string profilename, string accesskey, string secretkey) { try { AWSProfile profile = new AWSProfile(); profile.ProfileName = profilename; profile.Accesskey = accesskey; profile.Secretkey = secretkey; var regions = Amazon.RegionEndpoint.EnumerableAllRegions; string region_ = ""; int count = 0; foreach (var r in regions) { if (count == 0) { region_ = r.SystemName; } count++; } var region = RegionEndpoint.GetBySystemName(region_); AmazonEC2Client client = new AmazonEC2Client(accesskey, secretkey, region); DescribeInstancesRequest request = new DescribeInstancesRequest(); DescribeInstancesResponse response = client.DescribeInstances(request); if (response.HttpStatusCode.ToString() == "OK" && SqlHelper.AddNewAccount("AWS", accountName) && SqlHelper.AddAWSAccountDetails(profile, accountName)) { return(true); } return(false); } catch (Exception e) { this.log.Error(e); return(false); } }