Creating a client - Amazon Key Management Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Creating a client

To use the Amazon SDK for Java, the Amazon SDK for .NET, the Amazon SDK for Python (Boto3), the Amazon SDK for Ruby, the Amazon SDK for PHP, or the Amazon SDK for JavaScript in Node.js to write code that uses the Amazon Key Management Service (Amazon KMS) API, start by creating an Amazon KMS client.

The client object that you create is used in the example code in the topics that follow.

Java

To create an Amazon KMS client in Java, use the client builder.

AWSKMS kmsClient = AWSKMSClientBuilder.standard().build();

For more information about using the Java client builder, see the following resources.

C#
AmazonKeyManagementServiceClient kmsClient = new AmazonKeyManagementServiceClient();
Python
kms_client = boto3.client('kms')
Ruby
require 'aws-sdk-kms' # in v2: require 'aws-sdk' kmsClient = Aws::KMS::Client.new
PHP

To create an Amazon KMS client in PHP, use an Amazon KMS client object, and specify version 2014-11-01. For more information see the KMSClient class in the Amazon SDK for PHP API Reference.

// Create a KMSClient $KmsClient = new Aws\Kms\KmsClient([ 'profile' => 'default', 'version' => '2014-11-01', 'region' => 'us-east-1' ]);
Node.js
const kmsClient = new AWS.KMS();