Smaws_Client_KMS.CreateGrant
val request :
Smaws_Lib.Context.t ->
create_grant_request ->
(create_grant_response,
[> Smaws_Lib.Protocols.AwsJson.error
| `DependencyTimeoutException of dependency_timeout_exception
| `DisabledException of disabled_exception
| `DryRunOperationException of dry_run_operation_exception
| `InvalidArnException of invalid_arn_exception
| `InvalidGrantTokenException of invalid_grant_token_exception
| `KMSInternalException of kms_internal_exception
| `KMSInvalidStateException of kms_invalid_state_exception
| `LimitExceededException of limit_exceeded_exception
| `NotFoundException of not_found_exception ])
Stdlib.result
Adds a grant to a KMS key.
A grant is a policy instrument that allows Amazon Web Services principals to use KMS keys in cryptographic operations. It also can allow them to view a KMS key (DescribeKey
) and create and manage grants. When authorizing access to a KMS key, grants are considered along with key policies and IAM policies. Grants are often used for temporary permissions because you can create one, use its permissions, and delete it without changing your key policies or IAM policies.
For detailed information about grants, including grant terminology, see Grants in KMS in the Key Management Service Developer Guide. For examples of working with grants in several programming languages, see Programming grants.
The CreateGrant
operation returns a GrantToken
and a GrantId
.
When you create, retire, or revoke a grant, there might be a brief delay, usually less than five minutes, until the grant is available throughout KMS. This state is known as eventual consistency. Once the grant has achieved eventual consistency, the grantee principal can use the permissions in the grant without identifying the grant.
However, to use the permissions in the grant immediately, use the GrantToken
that CreateGrant
returns. For details, see Using a grant token in the Key Management Service Developer Guide.
CreateGrant
operation also returns a GrantId
. You can use the GrantId
and a key identifier to identify the grant in the RetireGrant
and RevokeGrant
operations. To find the grant ID, use the ListGrants
or ListRetirableGrants
operations.The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide.
Cross-account use: Yes. To perform this operation on a KMS key in a different Amazon Web Services account, specify the key ARN in the value of the KeyId
parameter.
Required permissions: kms:CreateGrant (key policy)
Related operations:
ListGrants
ListRetirableGrants
RetireGrant
RevokeGrant
Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency.