Description
When EncryptionInfo is omitted, MSK encrypts stored data with an AWS managed key. By default, clients must use TLS and brokers encrypt traffic between them.
Potential impact
PLAINTEXT or TLS_PLAINTEXT permits plaintext client connections. InCluster: false exposes messages between brokers to interception or modification. Losing access to the storage key can also interrupt the cluster.
Remediation
- Configure producers and consumers for TLS. Set
ClientBroker: TLSandInCluster: true. Test the connections and check client authentication, topic permissions and network access. - Choose a storage key that meets your policy and retain the required permissions. Changing
InClusteror the storage key requires replacement. To migrate while the old cluster serves clients, define a separate cluster resource with a new name. Check the change set, migrate the data and switch clients before retiring the old cluster.
Examples
For the three brokers shown here, supply subnets in three different Availability Zones, a supported Kafka version and the intended security groups.
Default encryption settings
Parameters:
KafkaVersion:
Type: String
BrokerSubnets:
Type: List<AWS::EC2::Subnet::Id>
BrokerSecurityGroups:
Type: List<AWS::EC2::SecurityGroup::Id>
Resources:
TestCluster:
Type: AWS::MSK::Cluster
Properties:
ClusterName: ClusterWithAllProperties
KafkaVersion: !Ref KafkaVersion
NumberOfBrokerNodes: 3
BrokerNodeGroupInfo:
InstanceType: kafka.m5.large
ClientSubnets: !Ref BrokerSubnets
SecurityGroups: !Ref BrokerSecurityGroups
The first template accepts the default storage key and transport settings.
Explicit encryption settings and key
Parameters:
KafkaVersion:
Type: String
BrokerSubnets:
Type: List<AWS::EC2::Subnet::Id>
BrokerSecurityGroups:
Type: List<AWS::EC2::SecurityGroup::Id>
DataKeyArn:
Type: String
Resources:
TestCluster:
Type: AWS::MSK::Cluster
Properties:
ClusterName: ClusterWithAllProperties
KafkaVersion: !Ref KafkaVersion
NumberOfBrokerNodes: 3
EncryptionInfo:
EncryptionAtRest:
DataVolumeKMSKeyId: !Ref DataKeyArn
EncryptionInTransit:
ClientBroker: TLS
InCluster: true
BrokerNodeGroupInfo:
InstanceType: kafka.m5.large
ClientSubnets: !Ref BrokerSubnets
SecurityGroups: !Ref BrokerSecurityGroups
The second template explicitly requires TLS, encrypts broker traffic and uses the KMS key ARN supplied in DataKeyArn.