Description
Session Manager encrypts session traffic with TLS by default. To add an organization-controlled key for commands and responses in a supported session type, set kmsKeyId on the session document.
Potential impact
Missing key permissions can prevent a session from starting. Limit who may connect to managed nodes and run commands separately.
Remediation
Set inputs.kmsKeyId to a symmetric KMS key in the Session document users will select. Allow the user starting the session to call kms:GenerateDataKey and the managed node role to call kms:Decrypt. Use a supported SSM Agent and test a new session with that document.
Examples
Both excerpts define a custom Standard_Stream document named test_document. The second adds var.kms_key_id, which applies to sessions using that document. To store session logs, also specify a destination in addition to the log-encryption flags.
Default TLS protection
resource "aws_ssm_document" "example" {
name = "test_document"
document_type = "Session"
content = <<DOC
{
"schemaVersion": "1.0",
"description": "Session preferences",
"sessionType": "Standard_Stream",
"inputs": {
"s3EncryptionEnabled": true,
"cloudWatchEncryptionEnabled": true,
"cloudWatchStreamingEnabled": true,
"runAsEnabled": false
}
}
DOC
}
Additional KMS encryption
resource "aws_ssm_document" "example" {
name = "test_document"
document_type = "Session"
content = <<DOC
{
"schemaVersion": "1.0",
"description": "Session preferences",
"sessionType": "Standard_Stream",
"inputs": {
"s3EncryptionEnabled": true,
"cloudWatchEncryptionEnabled": true,
"cloudWatchStreamingEnabled": true,
"runAsEnabled": false,
"kmsKeyId": "${var.kms_key_id}"
}
}
DOC
}