Enables or updates server-side encryption using an Amazon Web Services KMS key for a specified stream.
When invoking this API, you must use either the StreamARN or the StreamName parameter, or both. It is recommended that you use the StreamARN input parameter when you invoke this API.
Starting encryption is an asynchronous operation. Upon receiving the request, Kinesis Data Streams returns immediately and sets the status of the stream to UPDATING. After the update is complete, Kinesis Data Streams sets the status of the stream back to ACTIVE. Updating or applying encryption normally takes a few seconds to complete, but it can take minutes. You can continue to read and write data to your stream while its status is UPDATING. Once the status of the stream is ACTIVE, encryption begins for records written to the stream.
API Limits: You can successfully apply a new Amazon Web Services KMS key for server-side encryption 25 times in a rolling 24-hour period.
Note: It can take up to 5 seconds after the stream is in an ACTIVE status before all records written to the stream are encrypted. After you enable encryption, you can verify that encryption is applied by inspecting the API response from PutRecord or PutRecords.
Parameters:
-
stream_name
(Optional[StreamName], default:
None
)
–
The name of the stream for which to start encrypting records.
-
encryption_type
(EncryptionType)
–
The encryption type to use. The only valid value is KMS.
-
key_id
(KeyId)
–
The GUID for the customer-managed Amazon Web Services KMS key to use for encryption. This value can be a globally unique identifier, a fully specified Amazon Resource Name (ARN) to either an alias or a key, or an alias name prefixed by "alias/".You can also use a master key owned by Kinesis Data Streams by specifying the alias aws/kinesis.
-
Key ARN example: arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
-
Alias ARN example: arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
-
Globally unique key ID example: 12345678-1234-1234-1234-123456789012
-
Alias name example: alias/MyAliasName
-
Master key owned by Kinesis Data Streams: alias/aws/kinesis
-
stream_arn
(Optional[StreamARN], default:
None
)
–
-
stream_id
(Optional[StreamId], default:
None
)
–
Not Implemented. Reserved for future use.
Raises:
-
AccessDeniedException
–
Specifies that you do not have the permissions required to perform this operation.
-
InvalidArgumentException
–
A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.
-
KMSAccessDeniedException
–
The ciphertext references a key that doesn't exist or that you don't have access to.
-
KMSDisabledException
–
The request was rejected because the specified customer master key (CMK) isn't enabled.
-
KMSInvalidStateException
–
-
KMSNotFoundException
–
The request was rejected because the specified entity or resource can't be found.
-
KMSOptInRequired
–
The Amazon Web Services access key ID needs a subscription for the service.
-
KMSThrottlingException
–
The request was denied due to request throttling. For more information about throttling, see Limits in the Amazon Web Services Key Management Service Developer Guide.
-
LimitExceededException
–
The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.
-
ResourceInUseException
–
The resource is not available for this operation. For successful operation, the resource must be in the ACTIVE state.
-
ResourceNotFoundException
–
The requested resource could not be found. The stream might not be specified correctly.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_kinesis/_services/async_kinesis.py
| async def start_stream_encryption(
self,
encryption_type: "capo_kinesis.types.encryption_type.EncryptionType",
key_id: "capo_kinesis.types.key_id.KeyId",
*,
config_overrides: Optional[AsyncKinesisClientConfig] = None,
stream_name: Optional["capo_kinesis.types.stream_name.StreamName"] = None,
stream_arn: Optional["capo_kinesis.types.stream_arn.StreamARN"] = None,
stream_id: Optional["capo_kinesis.types.stream_id.StreamId"] = None,
) -> None:
"""<p>Enables or updates server-side encryption using an Amazon Web Services KMS key for a specified stream. </p> <note> <p>When invoking this API, you must use either the <code>StreamARN</code> or the <code>StreamName</code> parameter, or both. It is recommended that you use the <code>StreamARN</code> input parameter when you invoke this API.</p> </note> <p>Starting encryption is an asynchronous operation. Upon receiving the request, Kinesis Data Streams returns immediately and sets the status of the stream to <code>UPDATING</code>. After the update is complete, Kinesis Data Streams sets the status of the stream back to <code>ACTIVE</code>. Updating or applying encryption normally takes a few seconds to complete, but it can take minutes. You can continue to read and write data to your stream while its status is <code>UPDATING</code>. Once the status of the stream is <code>ACTIVE</code>, encryption begins for records written to the stream. </p> <p>API Limits: You can successfully apply a new Amazon Web Services KMS key for server-side encryption 25 times in a rolling 24-hour period.</p> <p>Note: It can take up to 5 seconds after the stream is in an <code>ACTIVE</code> status before all records written to the stream are encrypted. After you enable encryption, you can verify that encryption is applied by inspecting the API response from <code>PutRecord</code> or <code>PutRecords</code>.</p>
Args:
stream_name: <p>The name of the stream for which to start encrypting records.</p>
encryption_type: <p>The encryption type to use. The only valid value is <code>KMS</code>.</p>
key_id: <p>The GUID for the customer-managed Amazon Web Services KMS key to use for encryption. This value can be a globally unique identifier, a fully specified Amazon Resource Name (ARN) to either an alias or a key, or an alias name prefixed by "alias/".You can also use a master key owned by Kinesis Data Streams by specifying the alias <code>aws/kinesis</code>.</p> <ul> <li> <p>Key ARN example: <code>arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012</code> </p> </li> <li> <p>Alias ARN example: <code>arn:aws:kms:us-east-1:123456789012:alias/MyAliasName</code> </p> </li> <li> <p>Globally unique key ID example: <code>12345678-1234-1234-1234-123456789012</code> </p> </li> <li> <p>Alias name example: <code>alias/MyAliasName</code> </p> </li> <li> <p>Master key owned by Kinesis Data Streams: <code>alias/aws/kinesis</code> </p> </li> </ul>
stream_arn: <p>The ARN of the stream.</p>
stream_id: <p>Not Implemented. Reserved for future use.</p>
Raises:
capo_kinesis.errors.access_denied_exception.AccessDeniedException: <p>Specifies that you do not have the permissions required to perform this operation.</p>
capo_kinesis.errors.invalid_argument_exception.InvalidArgumentException: <p>A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.</p>
capo_kinesis.errors.kms_access_denied_exception.KMSAccessDeniedException: <p>The ciphertext references a key that doesn't exist or that you don't have access to.</p>
capo_kinesis.errors.kms_disabled_exception.KMSDisabledException: <p>The request was rejected because the specified customer master key (CMK) isn't enabled.</p>
capo_kinesis.errors.kms_invalid_state_exception.KMSInvalidStateException: <p>The request was rejected because the state of the specified resource isn't valid for this request. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html">How Key State Affects Use of a Customer Master Key</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>
capo_kinesis.errors.kms_not_found_exception.KMSNotFoundException: <p>The request was rejected because the specified entity or resource can't be found.</p>
capo_kinesis.errors.kms_opt_in_required.KMSOptInRequired: <p>The Amazon Web Services access key ID needs a subscription for the service.</p>
capo_kinesis.errors.kms_throttling_exception.KMSThrottlingException: <p>The request was denied due to request throttling. For more information about throttling, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/limits.html#requests-per-second">Limits</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>
capo_kinesis.errors.limit_exceeded_exception.LimitExceededException: <p>The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed. </p>
capo_kinesis.errors.resource_in_use_exception.ResourceInUseException: <p>The resource is not available for this operation. For successful operation, the resource must be in the <code>ACTIVE</code> state.</p>
capo_kinesis.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource could not be found. The stream might not be specified correctly.</p>
capo_kinesis.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_kinesis.types.start_stream_encryption_input.StartStreamEncryptionInput]",
) -> AsyncOperationResponse[None]:
import capo_kinesis._operations.kinesis_20131202.start_stream_encryption
(
output,
http_response,
) = await capo_kinesis._operations.kinesis_20131202.start_stream_encryption.async_start_stream_encryption(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("StartStreamEncryption")
)
input_: capo_kinesis.types.start_stream_encryption_input.StartStreamEncryptionInput = {
"encryption_type": encryption_type,
"key_id": key_id,
}
if stream_name is not None:
input_["stream_name"] = stream_name
if stream_arn is not None:
input_["stream_arn"] = stream_arn
if stream_id is not None:
input_["stream_id"] = stream_id
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|