ConnectCustomKeyStore
Connects or reconnects a custom key store to its associated AWS CloudHSM cluster.
The custom key store must be connected before you can create customer master keys (CMKs) in the key store or use the CMKs it contains. You can disconnect and reconnect a custom key store at any time.
To connect a custom key store, its associated AWS CloudHSM cluster must have at least
one active
HSM. To get the number of active HSMs in a cluster, use the DescribeClusters operation. To add HSMs
to the cluster, use the CreateHsm operation. Also, the
kmsuser
crypto
user (CU) must not be logged into the cluster. This prevents AWS KMS from using this
account to log in.
The connection process can take an extended amount of time to complete; up to 20 minutes. This operation starts the connection process, but it does not wait for it to complete. When it succeeds, this operation quickly returns an HTTP 200 response and a JSON object with no properties. However, this response does not indicate that the custom key store is connected. To get the connection state of the custom key store, use the DescribeCustomKeyStores operation.
During the connection process, AWS KMS finds the AWS CloudHSM cluster that is associated
with the
custom key store, creates the connection infrastructure, connects to the cluster,
logs into
the AWS CloudHSM client as the kmsuser
CU, and rotates its password.
The ConnectCustomKeyStore
operation might fail for various reasons. To find
the reason, use the DescribeCustomKeyStores operation and see the
ConnectionErrorCode
in the response. For help interpreting the
ConnectionErrorCode
, see CustomKeyStoresListEntry.
To fix the failure, use the DisconnectCustomKeyStore operation to
disconnect the custom key store, correct the error, use the UpdateCustomKeyStore operation if necessary, and then use
ConnectCustomKeyStore
again.
If you are having trouble connecting or disconnecting a custom key store, see Troubleshooting a Custom Key Store in the AWS Key Management Service Developer Guide.
Cross-account use: No. You cannot perform this operation on a custom key store in a different AWS account.
Required permissions: kms:ConnectCustomKeyStore (IAM policy)
Related operations
Request Syntax
{
"CustomKeyStoreId": "string
"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
In the following list, the required parameters are described first.
- CustomKeyStoreId
-
Enter the key store ID of the custom key store that you want to connect. To find the ID of a custom key store, use the DescribeCustomKeyStores operation.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 64.
Required: Yes
Response Elements
If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.
Errors
For information about the errors that are common to all actions, see Common Errors.
- CloudHsmClusterInvalidConfigurationException
-
The request was rejected because the associated AWS CloudHSM cluster did not meet the configuration requirements for a custom key store.
-
The cluster must be configured with private subnets in at least two different Availability Zones in the Region.
-
The security group for the cluster (cloudhsm-cluster-<cluster-id>-sg) must include inbound rules and outbound rules that allow TCP traffic on ports 2223-2225. The Source in the inbound rules and the Destination in the outbound rules must match the security group ID. These rules are set by default when you create the cluster. Do not delete or change them. To get information about a particular security group, use the DescribeSecurityGroups operation.
-
The cluster must contain at least as many HSMs as the operation requires. To add HSMs, use the AWS CloudHSM CreateHsm operation.
For the CreateCustomKeyStore, UpdateCustomKeyStore, and CreateKey operations, the AWS CloudHSM cluster must have at least two active HSMs, each in a different Availability Zone. For the ConnectCustomKeyStore operation, the AWS CloudHSM must contain at least one active HSM.
For information about the requirements for an AWS CloudHSM cluster that is associated with a custom key store, see Assemble the Prerequisites in the AWS Key Management Service Developer Guide. For information about creating a private subnet for an AWS CloudHSM cluster, see Create a Private Subnet in the AWS CloudHSM User Guide. For information about cluster security groups, see Configure a Default Security Group in the AWS CloudHSM User Guide .
HTTP Status Code: 400
-
- CloudHsmClusterNotActiveException
-
The request was rejected because the AWS CloudHSM cluster that is associated with the custom key store is not active. Initialize and activate the cluster and try the command again. For detailed instructions, see Getting Started in the AWS CloudHSM User Guide.
HTTP Status Code: 400
- CustomKeyStoreInvalidStateException
-
The request was rejected because of the
ConnectionState
of the custom key store. To get theConnectionState
of a custom key store, use the DescribeCustomKeyStores operation.This exception is thrown under the following conditions:
-
You requested the CreateKey or GenerateRandom operation in a custom key store that is not connected. These operations are valid only when the custom key store
ConnectionState
isCONNECTED
. -
You requested the UpdateCustomKeyStore or DeleteCustomKeyStore operation on a custom key store that is not disconnected. This operation is valid only when the custom key store
ConnectionState
isDISCONNECTED
. -
You requested the ConnectCustomKeyStore operation on a custom key store with a
ConnectionState
ofDISCONNECTING
orFAILED
. This operation is valid for all otherConnectionState
values.
HTTP Status Code: 400
-
- CustomKeyStoreNotFoundException
-
The request was rejected because AWS KMS cannot find a custom key store with the specified key store name or ID.
HTTP Status Code: 400
- KMSInternalException
-
The request was rejected because an internal exception occurred. The request can be retried.
HTTP Status Code: 500
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: