Key management in Amazon Managed Service for Apache Flink
In Amazon MSF, you can choose to use either AWS managed keys or your own customer managed keys (CMKs) to encrypt data. CMKs in AWS Key Management Service (AWS KMS) are encryption keys that you create, own, and manage yourself.
On this page
Transparent encryption in Amazon MSF
By default, Amazon MSF uses AWS owned keys (AOKs) to encrypt your data in ephemeral (running application storage) and durable (durable application storage) storage. This means all data subject to a Flink checkpoint or snapshot will be encrypted by default. AOKs are the default encryption method in Amazon MSF and no additional set up is required. To encrypt data in transit, Amazon MSF uses TLS and HTTP+SSL by default and requires no additional set up or configuration.
Customer managed keys in Amazon MSF
In Amazon MSF, CMK is a feature where you can encrypt your application's data with a key that you create, own, and manage on AWS KMS.
In this section
What is encrypted with CMKs?
In an Amazon MSF application, data subject to a Flink checkpoint or snapshot will be encrypted with a CMK you define for that application. Consquently, your CMK will encrypt data stored in either running application storage or durable application storage. The following sections describe the procedure to set up CMKs for your Amazon MSF applications.
The following rules set the key that encrypts an enhanced snapshot and its exported objects:
-
Enhanced snapshots: Managed Service for Apache Flink encrypts each enhanced snapshot with the key that the application uses when Managed Service for Apache Flink creates the enhanced snapshot. This rule applies to snapshots that you create with
CreateSnapshotand to system snapshots.CreateSnapshotalways uses the key of the application. -
Imported enhanced snapshots: Managed Service for Apache Flink encrypts the new enhanced snapshot with the key in
DestinationEncryptionConfigurationof theImportSnapshotrequest. If you omitDestinationEncryptionConfiguration, Managed Service for Apache Flink uses an AWS owned key. -
Exported enhanced snapshots: Managed Service for Apache Flink encrypts the exported Amazon S3 objects with the key in
DestinationEncryptionConfigurationof theExportSnapshotrequest. If the key type inDestinationEncryptionConfigurationisAWS_OWNED_KEY, or if you omitDestinationEncryptionConfiguration, Managed Service for Apache Flink specifies no key. Amazon S3 encrypts the exported objects with the default encryption of the destination bucket, which is SSE-S3 or a customer managed key of the bucket. Managed Service for Apache Flink does not encrypt the exported objects with an AWS owned key.
For more information, see Encryption for imported and exported snapshots.
When you change the CMK of an application to a different key, the operator (API caller) needs permissions for both the previous key and the new key. For more information, see Key transition.
What isn't encrypted with CMKs?
Sources and sinks
Encryption of data sources and sinks isn't managed by Amazon MSF. It's managed by your source or sink configuration or application connector configuration.
Retroactive application of encryption
CMK in Amazon MSF doesn't provide support to retroactively apply CMKs to an existing historic snapshot.
Log encryption
Currently, Amazon MSF doesn't support log encryption using KMS CMK for logs generated by your application code jar. You'll need to make sure logs don't contain data that require CMK encryption.
Encryption of data in transit
You can't use CMK to encrypt data in transit. By default, Amazon MSF encrypts all data in transit using TLS or HTTP and SSL.
Supported KMS key types
CMK in Amazon MSF supports symmetric keys.
KMS key permissions
CMK in Amazon MSF requires permission to perform the following KMS actions. These permissions are necessary to validate access, create CMK encrypted running application storage, and store CMK encrypted application state in durable application storage.
-
kms:DescribeKey
Grants permission to resolve a KMS key alias to the key ARN.
-
kms:Decrypt
Grants permission to accesses durable application state and provision running application storage.
-
kms:GenerateDataKey
Grants permission to store durable application state.
-
kms:GenerateDataKeyWithoutPlaintext
Grants permission to provision running application storage.
-
kms:CreateGrant
Grants permission to access running application storage.
Enhanced snapshot operations need the following AWS KMS permissions when a customer managed key encrypts the data. Managed Service for Apache Flink checks the caller permissions when it validates the request. Managed Service for Apache Flink does not check them for an AWS owned key. The following table lists the AWS KMS permissions for each enhanced snapshot operation.
| Operation | Principal | Permissions on the key |
|---|---|---|
CreateSnapshot |
The caller | kms:Decrypt and kms:GenerateDataKey on the key of the application. |
Restore with StartApplication, UpdateApplication, or RollbackApplication |
The caller | kms:DescribeKey, kms:Decrypt, and kms:GenerateDataKey on the key that encrypts the enhanced snapshot. |
ImportSnapshot and ExportSnapshot |
The caller | For ExportSnapshot, kms:DescribeKey, kms:Decrypt, and kms:GenerateDataKey on the key of the enhanced snapshot. For ImportSnapshot, kms:Decrypt and kms:GenerateDataKey on the key in DestinationEncryptionConfiguration. |
ImportSnapshot and ExportSnapshot |
The IAM role that you pass in the ImportSnapshot or ExportSnapshot request, and the caller |
kms:Decrypt, kms:GenerateDataKey, and kms:DescribeKey on the key that encrypts the imported source or exported destination Amazon S3 objects. For the role policies and their conditions, see IAM role for import and export. |
ImportSnapshot and ExportSnapshot |
kinesisanalytics.amazonaws.com and infrastructure.kinesisanalytics.amazonaws.com |
For ImportSnapshot, kinesisanalytics.amazonaws.com needs kms:Decrypt and kms:GenerateDataKey on the key in DestinationEncryptionConfiguration. For ExportSnapshot, both principals need kms:DescribeKey, and kinesisanalytics.amazonaws.com also needs kms:Decrypt and kms:GenerateDataKey, on the key of the enhanced snapshot. For the key policy, see Key policy for enhanced snapshot import and export. |
Grant each principal in the table the permissions in its row to avoid an AccessDeniedException.
For more information, see Encryption for imported and exported snapshots.
KMS encryption context and constraints
CMK in Amazon MSF provides encryption context when accessing keys to read or write encrypted data, that is, kms:EncryptionContext:aws:kinesisanalytics:arn. In addition to encryption context, source contexts aws:SourceArn
and aws:SourceAccount are provided when reading or writing durable application storage.
When creating grant to provision encrypted running application storage, Amazon MSF CMK creates grants with constraint type EncryptionContextSubset ensuring that only Decrypt operation is allowed through "kms:GrantOperations": "Decrypt".
For enhanced snapshots, the value of kms:EncryptionContext:aws:kinesisanalytics:arn depends on the operation:
-
Create: For
CreateSnapshotand system snapshots, the value is the ARN of the application. -
Restore: Allow both the ARN of the application that restores the enhanced snapshot and the source ARN of the enhanced snapshot. The source ARN is the ARN of the application that created the enhanced snapshot, or the snapshot ARN for an imported enhanced snapshot. The same two values apply to
aws:SourceArn. -
Import: The value is the ARN of the new enhanced snapshot.
-
Export: To read the enhanced snapshot, the value is the same as for a restore. To encrypt the exported objects with the customer managed key in
DestinationEncryptionConfiguration, the value is the ARN of the enhanced snapshot that you export.
The key policy must allow each value that your operations use. Keep the ARN of the application that created an enhanced snapshot in the key policy after you delete that application. Without that ARN, you cannot restore or export the enhanced snapshots of that application.
Key transition
A key transition is a change from one CMK to a different CMK. When you change the CMK of an application to a different key, make sure that the operator (API caller) has permissions for both the previous key and the new key.
An application can start from a snapshot which was encrypted with AOK after it's configured to use CMK. An application can also start from a snapshot which was encrypted with an older CMK. To start an application from a snapshot, the operator (API caller) must have permissions for both the old and new key.
If you're changing the AWS KMS key ARN used for CMK you should use UpdateApplication in Amazon MSF. This will ensure your Flink application will restart as part of UpdateApplication applying the CMK changes.
When you provide an alias or alias ARN, Amazon MSF resolves the alias to key ARN and stores the key ARN as the configured key for the application.
Least-privileged key policy statements
For information about key policy statements, see Create a KMS key policy and Application lifecycle operator (API caller) permissions.
AWS CloudTrail log entries
When Amazon MSF uses CMKs in AWS KMS, AWS CloudTrail logs the AWS KMS API calls. The log entries show the AWS service that made the request, the KMS key ARN, the API action, and the timestamp. They don't include the encrypted data.
To find the calls that Amazon MSF makes, look for AWS KMS events where userIdentity.invokedBy is kinesisanalytics.amazonaws.com. The aws:kinesisanalytics:arn value in the encryption context of the event identifies the application or the enhanced snapshot. For more information, see Logging AWS KMS API calls with AWS CloudTrail in the AWS Key Management Service Developer Guide.