private static string CreateGrant(KmsClient kmsClient) { var operations = new List <string> { "describe-key", "create-datakey" }; try { var request = new CreateGrantRequest { VersionId = "v1.0", Body = new CreateGrantRequestBody() { KeyId = GetKeyByStatus.GetKeyByKeyStatus(kmsClient, "2"), GranteePrincipal = "99104bff46109531b9ac70e606d3ffdf", GranteePrincipalType = CreateGrantRequestBody.GranteePrincipalTypeEnum.DOMAIN, Operations = operations } }; var resp = kmsClient.CreateGrant(request); Console.WriteLine(resp.GrantId); return(resp.GrantId); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } return(null); }