21 C
New York
Sunday, September 7, 2025

Obtain full management over your information encryption utilizing buyer managed keys in Amazon Managed Service for Apache Flink


Encryption of each information at relaxation and in transit is a non-negotiable characteristic for many organizations. Moreover, organizations working in extremely regulated and security-sensitive environments—comparable to these within the monetary sector—usually require full management over the cryptographic keys used for his or her workloads.

Amazon Managed Service for Apache Flink makes it simple to course of real-time information streams with strong safety features, together with encryption by default to assist defend your information in transit and at relaxation. The service removes the complexity of managing the important thing lifecycle and controlling entry to the cryptographic materials.

If that you must retain full management over your key lifecycle and entry, Managed Service for Apache Flink now helps the usage of buyer managed keys (CMKs) saved in AWS Key Administration Service (AWS KMS) for encrypting utility information.

This characteristic helps you handle your individual encryption keys and key insurance policies, so you may meet strict compliance necessities and keep full management over delicate information. With CMK integration, you may make the most of the scalability and ease of use that Managed Service for Apache Flink provides, whereas assembly your group’s safety and compliance insurance policies.

On this put up, we discover how the CMK performance works with Managed Service for Apache Flink purposes, the use instances it unlocks, and key issues for implementation.

Knowledge encryption in Managed Service for Apache Flink

In Managed Service for Apache Flink, there are a number of facets the place information must be encrypted:

  • Knowledge at relaxation instantly managed by the service – Sturdy utility storage (checkpoints and snapshots) and operating utility state storage (disk volumes utilized by RocksDB state backend) are mechanically encrypted
  • Knowledge in transit inner to the Flink cluster – Routinely encrypted utilizing TLS/HTTPS
  • Knowledge in transit to and at relaxation in exterior techniques that your Flink utility accesses – For instance, an Amazon Managed Streaming for Apache Kafka (Amazon MSK) matter via the Kafka connector or calling an endpoint via a customized AsyncIO); encryption is dependent upon the exterior service, consumer settings, and code

For information at relaxation managed by the service, checkpoints, snapshots, and operating utility state storage are encrypted by default utilizing AWS owned keys. In case your safety necessities require you to instantly management the encryption keys, you need to use the CMK held in AWS KMS.

Key parts and roles

To know how CMKs work in Managed Service for Apache Flink, we first must introduce the parts and roles concerned in managing and operating an utility utilizing CMK encryption:

  • Buyer managed key (CMK):
    • Resides in AWS KMS inside the similar AWS account as your utility
    • Has an connected key coverage that defines entry permissions and utilization rights to different parts and roles
    • Encrypts each sturdy utility storage (checkpoints and snapshots) and operating utility state storage
  • Managed Service for Apache Flink utility:
    • The appliance whose storage you wish to encrypt utilizing the CMK
    • Has an connected AWS Id and Entry Administration (IAM) execution position that grants permissions to entry exterior providers
    • The execution position doesn’t have to offer any particular permissions to make use of the CMK for encryption operations
  • Key administrator:
    • Manages the CMK lifecycle (creation, rotation, coverage updates, and so forth)
    • Might be an IAM consumer or IAM position, and utilized by a human operator or by automation
    • Requires administrative entry to the CMK
    • Permissions are outlined by the connected IAM insurance policies and the important thing coverage
  • Utility operator:
    • Manages the applying lifecycle (begin/cease, configuration updates, snapshot administration, and so forth)
    • Might be an IAM Consumer or IAM position, and utilized by a human operator or by automation
    • Requires permissions to handle the Flink utility and use the CMK for encryption operations
    • Permissions are outlined by the connected IAM insurance policies and the important thing coverage

The next diagram illustrates the answer structure.

Actors

Enabling CMK following the precept of least privilege

When deploying purposes in manufacturing environments or dealing with delicate information, you need to comply with the precept of least privilege. CMK help in Managed Service for Apache Flink has been designed with this precept in thoughts, so every element receives solely the minimal permissions essential to operate.

For detailed details about the permissions required by the applying operator and key coverage configurations, consult with Key administration in Amazon Managed Service for Apache Flink. Though these insurance policies may seem advanced at first look, this complexity is intentional and vital. For extra particulars concerning the necessities for implementing essentially the most restrictive key administration potential whereas sustaining performance, consult with Least-privilege permissions.

For this put up, we spotlight some essential factors about CMK permissions:

  • Utility execution position – Requires no further permissions to make use of a CMK. You don’t want to vary the permissions of an current utility; the service handles CMK operations transparently throughout runtime.
  • Utility operator permissions – The operator is the consumer or position who controls the applying lifecycle. For the permissions required to function an utility that makes use of CMK encryption, consult with Key administration in Amazon Managed Service for Apache Flink. Along with these permissions, an operator usually has permissions on actions with the kinesisanalytics prefix. It’s a finest apply to limit these permissions to a particular utility defining the Useful resource. The operator should even have the iam:PassRole permission to go the service execution position to the applying.

To simplify managing the permissions of the operator, we advocate creating two separate IAM insurance policies, to be connected to the operator’s position or consumer:

  • A base operator coverage defining the fundamental permissions to function the applying lifecycle with no CMK
  • An extra CMK operator coverage that provides permissions to function the applying with a CMK

The next IAM coverage instance illustrates the permissions that must be included within the base operator coverage:

{
  "Model": "2012-10-17",
  "Assertion": [
    {
      "Sid": "Allow Managed Flink operations",
      "Effect": "Allow",
      "Action": "kinesisanalytics:*",
      "Resource": "arn:aws:kinesisanalytics:::application/MyApplication"
    },
    {
      "Sid": "Allow passing service execution role",
      "Effect": "Allow",
      "Action": [
        "iam:PassRole"
      ],
      "Useful resource": "arn:aws:iam:::position/MyApplicationRole"
    },
  ]
} 

Check with Utility lifecycle operator (API caller) permissions for the permissions to be included with the extra CMK operator coverage.

Separating these two insurance policies has an extra good thing about simplifying the method of establishing an utility for the CMK, as a result of dependencies we illustrate within the following part.

Dependencies between the important thing coverage and CMK operator coverage

If you happen to fastidiously observe the operator’s permissions and the important thing coverage defined in Create a KMS key coverage, you’ll discover some interdependencies, illustrated by the next diagram.

Dependencies

Particularly, we spotlight the next:

  • CMK key coverage dependencies – The CMK coverage requires references to each the applying Amazon Useful resource Title (ARN) and the important thing administrator or operator IAM roles or customers. This coverage should be outlined at key creation time by the important thing administrator.
  • IAM coverage dependencies – The operator’s IAM coverage should reference each the applying ARN and the CMK key itself. The operator position is answerable for varied duties, together with configuring the applying to make use of the CMK.

To correctly comply with the precept of least privilege, every element requires the others to exist earlier than it may be accurately configured. This necessitates a fastidiously orchestrated deployment sequence.

Within the following part, we reveal the exact order required to resolve these dependencies whereas sustaining safety finest practices.

Sequence of operations to create a brand new utility with a CMK

When deploying a brand new utility that makes use of CMK encryption, we advocate following this sequenced method to resolve dependency conflicts whereas sustaining safety finest practices:

  1. Create the operator IAM position or consumer with a base coverage that features utility lifecycle permissions. Don’t embody CMK permissions at this stage, as a result of the important thing doesn’t exist but.
  2. The operator creates the applying utilizing the default AWS owned key. Hold the applying in a stopped state to stop information creation—there must be no information at relaxation to encrypt throughout this section.
  3. Create the important thing administrator IAM position or consumer, if not already accessible, with permissions to create and handle KMS keys. Check with Utilizing IAM insurance policies with AWS KMS for detailed permission necessities.
  4. The important thing administrator creates the CMK in AWS KMS. At this level, you could have the required parts for the important thing coverage: utility ARN, operator IAM position or consumer ARN, and key administrator IAM position or consumer ARN.
  5. Create and connect to the operator an extra IAM coverage that features the CMK-specific permissions. See Utility lifecycle operator (API caller) permissions for the entire operator coverage definition.
  6. The operator can now modify the applying configuration utilizing the UpdateApplication motion, to allow CMK encryption, as illustrated within the following part.
  7. The appliance is now able to run with all information at relaxation encrypted utilizing your CMK.

Allow the CMK with UpdateApplication

You’ll be able to configure a Managed Service for Apache Flink utility to make use of a CMK utilizing the AWS Administration Console, the AWS API, AWS Command Line Interface (AWS CLI), or infrastructure as code (IaC) instruments just like the AWS Cloud Growth Package (AWS CDK) or AWS CloudFormation templates.

When establishing CMK encryption in a manufacturing atmosphere, you’ll in all probability use an automation software relatively than the console. These instruments finally use the AWS API beneath the hood, and the UpdateApplication motion of the kinesisanalyticsv2 API particularly. On this put up, we analyze the additions to the API that you need to use to regulate the encryption configuration.

An extra top-level block ApplicationEncryptionConfigurationUpdate has been added to the UpdateApplication request payload. With this block, you may allow and disable the CMK.

You need to add the next block to the UpdateApplication request:

{
  "ApplicationEncryptionConfigurationUpdate": {
    "KeyTypeUpdate": "CUSTOMER_MANAGED_KEY",
    "KeyIdUpdate": "arn:aws:kms:us-east-1:123456789012:key/01234567-99ab-cdef-0123-456789abcdef"
  }
}

The KeyIdUpdate worth may be the important thing ARN, key ID, key alias title, or key alias ARN.

Disable the CMK

Equally, the next requests disable the CMK, switching again to the default AWS owned key:

{
  "ApplicationEncryptionConfigurationUpdate": {
    "KeyTypeUpdate": "AWS_OWNED_KEY"
  }
}

Allow the CMK with CreateApplication

Theoretically, you may allow the CMK instantly while you first create the applying utilizing the CreateApplication motion.

A top-level block ApplicationEncryptionConfiguration has been added to the CreateApplication request payload, with a syntax just like UpdateApplication.

Nonetheless, as a result of interdependencies described within the earlier part, you’ll most frequently create an utility with the default AWS owned key and later use UpdateApplication to allow the CMK.

If you happen to omit ApplicationEncryptionConfiguration while you create the applying, the default habits is utilizing the AWS owned key, for backward compatibility.

Pattern CloudFormation templates to create IAM roles and the KMS key

The method you utilize to create the roles and key and configure the applying to make use of the CMK will fluctuate, relying on the automation you utilize and your approval and safety processes. Any automation instance we will present will seemingly not suit your processes or tooling.

Nonetheless, the next GitHub repository gives some instance CloudFormation templates to generate a few of the IAM insurance policies and the KMS key with the right key coverage:

  • IAM coverage for the important thing administrator – Permits managing the important thing
  • Base IAM coverage for the operator – Permits managing the conventional utility lifecycle operations with out the CMK
  • CMK IAM coverage for the operator – Offers further permissions required to handle the applying lifecycle when the CMK is enabled
  • KMS key coverage – Permits the applying to encrypt and decrypt the applying state and the operator to handle the applying operations

CMK operations

We’ve described the method of making a brand new Managed Service for Apache Flink utility with CMK. Let’s now study different widespread operations you may carry out.

Modifications to the encryption key develop into efficient when the applying is restarted. If you happen to replace the configuration of a operating utility, this causes the applying to restart and the brand new key for use instantly. Conversely, if you happen to change the important thing of a READY (not operating) utility, the brand new key just isn’t really used till the applying is restarted.

Allow a CMK on an current utility

If in case you have an utility operating with an AWS owned key, the method is just like what we described for creating new purposes. On this case, you have already got a operating utility state and older snapshots which can be encrypted utilizing the AWS owned key.

Additionally, in case you have a operating utility, you in all probability have already got an operator position with an IAM coverage that you need to use to regulate the operator lifecycle.

The sequence of steps to allow a CMK on an current and operating utility is as follows:

  1. If you happen to don’t have already got one, create a key administrator IAM position or consumer with permissions to create and handle keys in AWS KMS. See Utilizing IAM insurance policies with AWS KMS for extra particulars concerning the permissions required to handle keys.
  2. The important thing administrator creates the CMK. The important thing coverage references the applying ARN, the operator’s ARN, and the important thing administrator’s position or consumer ARN.
  3. Create an extra IAM coverage that permits the usage of the CMK and connect this coverage to the operator. Alternatively, modify the operator’s current IAM coverage by including these permissions.
  4. Lastly, the operator can replace the applying and allow the CMK.The next diagram illustrates the method that happens while you execute an UpdateApplication motion on the operating utility to allow a CMK.

    Enabling CMK on an existing application

    The workflow consists of the next steps:

  5. While you replace the applying to arrange the CMK, the next occurs:
    1. The appliance operating state, in the intervening time it’s encrypted with the AWS owned key, is saved in a snapshot whereas the applying is stopped. This snapshot is encrypted with the default AWS owned key. The operating utility state storage is risky and destroyed when the applying is stopped.
    2. The appliance is redeployed, restoring the snapshot into the operating utility state.
    3. The operating utility state storage is now encrypted with the CMK.
  6. New snapshots created from this level on are encrypted utilizing the CMK.
  7. You’ll in all probability wish to delete all of the outdated snapshots, together with the one created mechanically by the UpdateApplication that enabled the CMK, as a result of they’re all encrypted utilizing the AWS owned key.

Rotate the encryption key

As with every cryptographic key, it’s a finest apply to rotate the important thing periodically for enhanced safety. Managed Service for Apache Flink doesn’t help AWS KMS automated key rotation, so you could have two main choices for rotating your CMK.

Possibility 1: Create a brand new CMK and replace the applying

The primary method entails creating a wholly new KMS key after which updating your utility configuration to make use of the brand new key. This methodology gives a clear separation between the outdated and new encryption keys, making it simpler to trace which information was encrypted with which key model.

Let’s assume you could have a operating utility utilizing CMK#1 (the present key) and wish to rotate to CMK#2 (the brand new key) for enhanced safety:

  • Stipulations and preparation – Earlier than initiating the important thing rotation course of, you will need to replace the operator’s IAM coverage to incorporate permissions for each CMK#1 and CMK#2. This dual-key entry helps uninterrupted operation in the course of the transition interval. After the applying configuration has been efficiently up to date and verified, you may safely take away all permissions to CMK#1.
  • Utility replace course of – The UpdateApplication operation used to configure CMK#2 mechanically triggers an utility restart. This restart mechanism makes positive each the applying’s operating state and any newly created snapshots are encrypted utilizing the brand new CMK#2, offering fast safety advantages from the up to date encryption key.
  • Essential safety issues – Current snapshots, together with the automated snapshot created in the course of the CMK replace course of, stay encrypted with the unique CMK#1. For full safety hygiene and to attenuate your cryptographic footprint, take into account deleting these older snapshots after verifying that your utility is functioning accurately with the brand new encryption key.

This method gives a clear separation between outdated and new encrypted information whereas sustaining utility availability all through the important thing rotation course of.

Possibility 2: Rotate the important thing materials of the prevailing CMK

The second possibility is to rotate the cryptographic materials inside your current KMS key. For a CMK used for Managed Service for Apache Flink, we advocate utilizing on-demand key materials rotation.

The advantage of this method is simplicity: no change is required to the applying configuration nor to the operator’s IAM permissions.

Essential safety issues

The brand new encryption key’s utilized by the Managed Service for Apache Flink utility solely after the following utility restart. To make the brand new key materials efficient, instantly after the rotation, that you must cease and begin utilizing snapshots to protect the applying state or execute an UpdateApplication, which additionally forces a stop-and-restart. After the restart, you need to take into account deleting the outdated snapshots, together with the one taken mechanically within the final stop-and-restart.

Change again to the AWS owned key

At any time, you may resolve to change again to utilizing an AWS owned key. The appliance state continues to be encrypted, however utilizing the AWS owned key as a substitute of your CMK.

If you’re utilizing the UpdateApplication API or AWS CLI command to change again to CMK, you will need to explicitly go ApplicationEncryptionConfigurationUpdate, setting the important thing sort to AWS_OWNED_KEY as proven within the following snippet:

{
  "ApplicationEncryptionConfigurationUpdate": {
    "KeyTypeUpdate": "AWS_OWNED_KEY"
  }
}

While you execute UpdateApplication to change off the CMK, the operator should nonetheless have permissions on the CMK. After the applying is efficiently operating utilizing the AWS owned key, you may safely take away any CMK-related permissions from the operator’s IAM coverage.

Take a look at the CMK in improvement environments

In a manufacturing atmosphere—or an atmosphere containing delicate information—you need to comply with the precept of least privilege and apply the restrictive permissions described to date.

Nonetheless, if you wish to experiment with CMKs in a improvement setting, comparable to utilizing the console, strictly following the manufacturing course of may develop into cumbersome. In these environments, the roles of key administrator and operator are sometimes crammed by the identical particular person.

For testing functions in improvement environments, you may wish to use a permissive key coverage like the next, so you may freely experiment with CMK encryption:

{
  "Model": "2012-10-17",
  "Id": "key-policy-permissive-for-dev-only",
  "Assertion": [
    {
      "Sid": "Allow any KMS action to Admin",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam:::role/Admin"
      },
      "Action": "kms:*",
      "Resource": "*"
    },
    {
      "Sid": "Allow any KMS action to Managed Flink",
      "Effect": "Allow",
      "Principal": { 
        "Service": [
          "kinesisanalytics.amazonaws.com",
          "infrastructure.kinesisanalytics.amazonaws.com"
        ]
      },
      "Motion": [
        "kms:DescribeKey",
        "kms:Decrypt",
        "kms:GenerateDataKey",
        "kms:GenerateDataKeyWithoutPlaintext",
        "kms:CreateGrant"
      ],
      "Useful resource": "*"
    }
  ]
}

This coverage must not ever be utilized in an atmosphere containing delicate information, and particularly not in manufacturing.

Widespread caveats and pitfalls

As mentioned earlier, this characteristic is designed to maximise safety and promote finest practices such because the precept of least privilege. Nonetheless, this focus can introduce some nook instances you need to be conscious of.

The CMK should be enabled for the service to encrypt and decrypt snapshots and operating state

With AWS KMS, you may disable one key at any time. If you happen to disable the CMK whereas the applying is operating, it’d trigger unpredictable failures. For instance, an utility will be unable to revive a snapshot if the CMK used to encrypt that snapshot has been disabled. For instance, if you happen to try and roll again an UpdateApplication that modified the CMK, and the earlier key has since been disabled, you won’t be capable to restore from an outdated snapshot. Equally, you won’t be capable to restart the applying from an older snapshot if the corresponding CMK is disabled.

If you happen to encounter these situations, the answer is to reenable the required key and retry the operation.

The operator requires permissions to all keys concerned

To carry out an motion on the applying (comparable to Begin, Cease, UpdateApplication, or CreateApplicationSnapshot), the operator should have permissions for all CMKs concerned in that operation. AWS owned keys don’t require express permission.

Some operations implicitly contain two CMKs—for instance, when switching from one CMK to a different, or when switching from a CMK to an AWS owned key by disabling the CMK. In these instances, the operator should have permissions for each keys for the operation to succeed.

The identical rule applies when rolling again an UpdateApplication motion that concerned a number of CMKs.

A brand new encryption key takes impact solely after restart

A brand new encryption key’s solely used after the applying is restarted. That is essential while you rotate the important thing materials for a CMK. Rotating the important thing materials in AWS KMS doesn’t require updating the Managed Flink utility’s configuration. Nonetheless, you will need to restart the applying as a separate step after rotating the important thing. If you happen to don’t restart the applying, it should proceed to make use of the outdated encryption key for its operating state and snapshots till the following restart.

For that reason, it’s endorsed to not allow automated key rotation for the CMK. When automated rotation is enabled, AWS KMS may rotate the important thing materials at any time, however your utility is not going to begin utilizing the brand new key till it’s subsequent restarted.

CMKs are solely supported with Flink runtime 1.20 or later

CMKs are solely supported if you find yourself utilizing the Flink runtime 1.20 or later. In case your utility is at present utilizing an older runtime, you need to improve to Flink 1.20 first. Managed Service for Apache Flink makes it simple to improve your current utility utilizing the in-place model improve.

Conclusion

Managed Service for Apache Flink gives strong safety by enabling encryption by default, defending each the operating state and persistently saved state of your purposes. For organizations that require full management over their encryption keys (usually resulting from regulatory or inner coverage wants), the flexibility to make use of a CMK built-in with AWS KMS provides a brand new degree of assurance.

By utilizing CMKs, you may tailor encryption controls to your particular compliance necessities. Nonetheless, this flexibility comes with the necessity for cautious planning: the CMK characteristic is deliberately designed to implement the precept of least privilege and powerful position separation, which might introduce complexity round permissions and operational processes.

On this put up, we reviewed the important thing steps for enabling CMKs on current purposes, creating new purposes with a CMK, and managing key rotation. Every of those processes provides you better management over your information safety but additionally requires consideration to entry administration and operational finest practices.

To get began with CMKs and for extra complete steering, consult with Key administration in Amazon Managed Service for Apache Flink.


In regards to the authors

Lorenzo Nicora

Lorenzo Nicora

Lorenzo works as Senior Streaming Resolution Architect at AWS, serving to clients throughout EMEA. He has been constructing cloud-centered, data-intensive techniques for over 25 years, working throughout industries each via consultancies and product firms. He has used open-source applied sciences extensively and contributed to a number of tasks, together with Apache Flink, and is the maintainer of the Flink Prometheus connector.

Sofia Zilberman

Sofia Zilberman

Sofia works as a Senior Streaming Options Architect at AWS, serving to clients design and optimize real-time information pipelines utilizing open-source applied sciences like Apache Flink, Kafka, and Apache Iceberg. With expertise in each streaming and batch information processing, she focuses on making information workflows environment friendly, observable, and high-performing.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay Connected

0FansLike
0FollowersFollow
0SubscribersSubscribe
- Advertisement -spot_img

Latest Articles