コード例 #1
0
        public void KeyManagementServiceCreateGrant()
        {
            #region to-create-a-grant-1477972226782

            var response = client.CreateGrant(new CreateGrantRequest
            {
                GranteePrincipal = "arn:aws:iam::111122223333:role/ExampleRole",                                  // The identity that is given permission to perform the operations specified in the grant.
                KeyId            = "arn:aws:kms:us-east-2:444455556666:key/1234abcd-12ab-34cd-56ef-1234567890ab", // The identifier of the CMK to which the grant applies. You can use the key ID or the Amazon Resource Name (ARN) of the CMK.
                Operations       = new List <string> {
                    "Encrypt",
                    "Decrypt"
                } // A list of operations that the grant allows.
            });

            string grantId    = response.GrantId;    // The unique identifier of the grant.
            string grantToken = response.GrantToken; // The grant token.

            #endregion
        }
コード例 #2
0
 private Amazon.KeyManagementService.Model.CreateGrantResponse CallAWSServiceOperation(IAmazonKeyManagementService client, Amazon.KeyManagementService.Model.CreateGrantRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Key Management Service", "CreateGrant");
     try
     {
         #if DESKTOP
         return(client.CreateGrant(request));
         #elif CORECLR
         return(client.CreateGrantAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }