Client
kms | R Documentation |
AWS Key Management Service¶
Description¶
Key Management Service
Key Management Service (KMS) is an encryption and key management web service. This guide describes the KMS operations that you can call programmatically. For general information about KMS, see the Key Management Service Developer Guide .
KMS has replaced the term customer master key (CMK) with KMS key and KMS key. The concept has not changed. To prevent breaking changes, KMS is keeping some variations of this term.
Amazon Web Services provides SDKs that consist of libraries and sample code for various programming languages and platforms (Java, Ruby, .Net, macOS, Android, etc.). The SDKs provide a convenient way to create programmatic access to KMS and other Amazon Web Services services. For example, the SDKs take care of tasks such as signing requests (see below), managing errors, and retrying requests automatically. For more information about the Amazon Web Services SDKs, including how to download and install them, see Tools for Amazon Web Services.
We recommend that you use the Amazon Web Services SDKs to make programmatic API calls to KMS.
If you need to use FIPS 140-2 validated cryptographic modules when communicating with Amazon Web Services, use the FIPS endpoint in your preferred Amazon Web Services Region. For more information about the available FIPS endpoints, see Service endpoints in the Key Management Service topic of the Amazon Web Services General Reference.
All KMS API calls must be signed and be transmitted using Transport Layer Security (TLS). KMS recommends you always use the latest supported TLS version. Clients must also support cipher suites with Perfect Forward Secrecy (PFS) such as Ephemeral Diffie-Hellman (DHE) or Elliptic Curve Ephemeral Diffie-Hellman (ECDHE). Most modern systems such as Java 7 and later support these modes.
Signing Requests
Requests must be signed using an access key ID and a secret access key. We strongly recommend that you do not use your Amazon Web Services account root access key ID and secret access key for everyday work. You can use the access key ID and secret access key for an IAM user or you can use the Security Token Service (STS) to generate temporary security credentials and use those to sign requests.
All KMS requests must be signed with Signature Version 4.
Logging API Requests
KMS supports CloudTrail, a service that logs Amazon Web Services API calls and related events for your Amazon Web Services account and delivers them to an Amazon S3 bucket that you specify. By using the information collected by CloudTrail, you can determine what requests were made to KMS, who made the request, when it was made, and so on. To learn more about CloudTrail, including how to turn it on and find your log files, see the CloudTrail User Guide.
Additional Resources
For more information about credentials and request signing, see the following:
-
Amazon Web Services Security Credentials - This topic provides general information about the types of credentials used to access Amazon Web Services.
-
Temporary Security Credentials - This section of the IAM User Guide describes how to create and use temporary security credentials.
-
Signature Version 4 Signing Process - This set of topics walks you through the process of signing a request using an access key ID and a secret access key.
Commonly Used API Operations
Of the API operations discussed in this guide, the following will prove the most useful for most applications. You will likely perform operations other than these, such as creating keys and assigning policies, by using the console.
-
encrypt
-
decrypt
-
generate_data_key
-
generate_data_key_without_plaintext
Usage¶
Arguments¶
config
Optional configuration of credentials, endpoint, and/or region.
credentials:
creds:
access_key_id: AWS access key ID
secret_access_key: AWS secret access key
session_token: AWS temporary session token
profile: The name of a profile to use. If not given, then the default profile is used.
anonymous: Set anonymous credentials.
endpoint: The complete URL to use for the constructed client.
region: The AWS Region used in instantiating the client.
close_connection: Immediately close all HTTP connections.
timeout: The time in seconds till a timeout exception is thrown when attempting to make a connection. The default is 60 seconds.
s3_force_path_style: Set this to
true
to force the request to use path-style addressing, i.e.http://s3.amazonaws.com/BUCKET/KEY
.sts_regional_endpoint: Set sts regional endpoint resolver to regional or legacy https://docs.aws.amazon.com/sdkref/latest/guide/feature-sts-regionalized-endpoints.html
credentials
Optional credentials shorthand for the config parameter
creds:
access_key_id: AWS access key ID
secret_access_key: AWS secret access key
session_token: AWS temporary session token
profile: The name of a profile to use. If not given, then the default profile is used.
anonymous: Set anonymous credentials.
endpoint
Optional shorthand for complete URL to use for the constructed client.
region
Optional shorthand for AWS Region used in instantiating the client.
Value¶
A client for the service. You can call the service's operations using
syntax like svc$operation(...)
, where svc
is the name you've
assigned to the client. The available operations are listed in the
Operations section.
Service syntax¶
svc <- kms(
config = list(
credentials = list(
creds = list(
access_key_id = "string",
secret_access_key = "string",
session_token = "string"
),
profile = "string",
anonymous = "logical"
),
endpoint = "string",
region = "string",
close_connection = "logical",
timeout = "numeric",
s3_force_path_style = "logical",
sts_regional_endpoint = "string"
),
credentials = list(
creds = list(
access_key_id = "string",
secret_access_key = "string",
session_token = "string"
),
profile = "string",
anonymous = "logical"
),
endpoint = "string",
region = "string"
)
Operations¶
- cancel_key_deletion
- Cancels the deletion of a KMS key
- connect_custom_key_store
- Connects or reconnects a custom key store to its backing key store
- create_alias
- Creates a friendly name for a KMS key
- create_custom_key_store
- Creates a custom key store backed by a key store that you own and manage
- create_grant
- Adds a grant to a KMS key
- create_key
- Creates a unique customer managed KMS key in your Amazon Web Services account and Region
- decrypt
- Decrypts ciphertext that was encrypted by a KMS key using any of the following operations:
- delete_alias
- Deletes the specified alias
- delete_custom_key_store
- Deletes a custom key store
- delete_imported_key_material
- Deletes key material that was previously imported
- derive_shared_secret
- Derives a shared secret using a key agreement algorithm
- describe_custom_key_stores
- Gets information about custom key stores in the account and Region
- describe_key
- Provides detailed information about a KMS key
- disable_key
- Sets the state of a KMS key to disabled
- disable_key_rotation
- Disables automatic rotation of the key material of the specified symmetric encryption KMS key
- disconnect_custom_key_store
- Disconnects the custom key store from its backing key store
- enable_key
- Sets the key state of a KMS key to enabled
- enable_key_rotation
- Enables automatic rotation of the key material of the specified symmetric encryption KMS key
- encrypt
- Encrypts plaintext of up to 4,096 bytes using a KMS key
- generate_data_key
- Returns a unique symmetric data key for use outside of KMS
- generate_data_key_pair
- Returns a unique asymmetric data key pair for use outside of KMS
- Returns a unique asymmetric data key pair for use outside of KMS
- generate_data_key_without_plaintext
- Returns a unique symmetric data key for use outside of KMS
- generate_mac
- Generates a hash-based message authentication code (HMAC) for a message using an HMAC KMS key and a MAC algorithm that the key supports
- generate_random
- Returns a random byte string that is cryptographically secure
- get_key_policy
- Gets a key policy attached to the specified KMS key
- get_key_rotation_status
- Provides detailed information about the rotation status for a KMS key, including whether automatic rotation of the key material is enabled for the specified KMS key, the rotation period, and the next scheduled rotation date
- get_parameters_for_import
- Returns the public key and an import token you need to import or reimport key material for a KMS key
- get_public_key
- Returns the public key of an asymmetric KMS key
- import_key_material
- Imports or reimports key material into an existing KMS key that was created without key material
- list_aliases
- Gets a list of aliases in the caller's Amazon Web Services account and region
- list_grants
- Gets a list of all grants for the specified KMS key
- list_key_policies
- Gets the names of the key policies that are attached to a KMS key
- list_key_rotations
- Returns information about all completed key material rotations for the specified KMS key
- list_keys
- Gets a list of all KMS keys in the caller's Amazon Web Services account and Region
- list_resource_tags
- Returns all tags on the specified KMS key
- list_retirable_grants
- Returns information about all grants in the Amazon Web Services account and Region that have the specified retiring principal
- put_key_policy
- Attaches a key policy to the specified KMS key
- re_encrypt
- Decrypts ciphertext and then reencrypts it entirely within KMS
- replicate_key
- Replicates a multi-Region key into the specified Region
- retire_grant
- Deletes a grant
- revoke_grant
- Deletes the specified grant
- rotate_key_on_demand
- Immediately initiates rotation of the key material of the specified symmetric encryption KMS key
- schedule_key_deletion
- Schedules the deletion of a KMS key
- sign
- Creates a digital signature for a message or message digest by using the private key in an asymmetric signing KMS key
- tag_resource
- Adds or edits tags on a customer managed key
- untag_resource
- Deletes tags from a customer managed key
- update_alias
- Associates an existing KMS alias with a different KMS key
- update_custom_key_store
- Changes the properties of a custom key store
- update_key_description
- Updates the description of a KMS key
- update_primary_region
- Changes the primary key of a multi-Region key
- verify
- Verifies a digital signature that was generated by the Sign operation
- verify_mac
- Verifies the hash-based message authentication code (HMAC) for a specified message, HMAC KMS key, and MAC algorithm
Examples¶
## Not run:
svc <- kms()
# The following example cancels deletion of the specified KMS key.
svc$cancel_key_deletion(
KeyId = "1234abcd-12ab-34cd-56ef-1234567890ab"
)
## End(Not run)