Skip to content

Commit

Permalink
keyring: infrastructure for E2E testing of external KMS
Browse files Browse the repository at this point in the history
In #23580 we're implementing support for encrypting Nomad's key material with
external KMS providers or Vault Transit. This changeset breaks out the E2E
infrastructure and testing from that PR to keep the review manageable.

Ref: https://hashicorp.atlassian.net/browse/NET-10334
Ref: #14852
Ref: #23580
  • Loading branch information
tgross committed Jul 17, 2024
1 parent 0f2ca08 commit c178ddd
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
10 changes: 10 additions & 0 deletions e2e/terraform/etc/nomad.d/server-linux.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ server {
enabled = true
bootstrap_expect = 3
}

keyring "awskms" {
active = true
region = "${aws_region}"
kms_key_id = "${aws_kms_key_id}"
}

keyring "aead" {
active = false
}
4 changes: 4 additions & 0 deletions e2e/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ module "keys" {
source = "mitchellh/dynamic-keys/aws"
version = "v2.0.0"
}

data "aws_kms_alias" "e2e" {
name = "alias/${var.aws_kms_alias}"
}
3 changes: 3 additions & 0 deletions e2e/terraform/nomad.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module "nomad_server" {
tls_ca_key = tls_private_key.ca.private_key_pem
tls_ca_cert = tls_self_signed_cert.ca.cert_pem

aws_region = var.region
aws_kms_key_id = data.aws_kms_alias.e2e.target_key_id

connection = {
type = "ssh"
user = "ubuntu"
Expand Down
5 changes: 4 additions & 1 deletion e2e/terraform/provision-nomad/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ resource "local_sensitive_file" "nomad_base_config" {
}

resource "local_sensitive_file" "nomad_role_config" {
content = templatefile("etc/nomad.d/${var.role}-${var.platform}.hcl", {})
content = templatefile("etc/nomad.d/${var.role}-${var.platform}.hcl", {
aws_region = var.aws_region
aws_kms_key_id = var.aws_kms_key_id
})
filename = "${local.upload_dir}/nomad.d/${var.role}.hcl"
file_permission = "0600"
}
Expand Down
11 changes: 11 additions & 0 deletions e2e/terraform/provision-nomad/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,14 @@ variable "connection" {
})
description = "ssh connection information for remote target"
}

variable "aws_region" {
type = string
default = "us-east-1"
}

variable "aws_kms_key_id" {
type = string
description = "AWS KMS key ID for encrypting and decrypting the Nomad keyring"
default = ""
}
6 changes: 6 additions & 0 deletions e2e/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ variable "hcp_vault_namespace" {
default = "admin"
}

variable "aws_kms_alias" {
description = "The alias for the AWS KMS key ID"
type = string
default = "kms-nomad-keyring"
}

# ----------------------------------------
# If you want to deploy multiple versions you can use these variables to
# provide a list of builds to override the values of nomad_sha, nomad_version,
Expand Down

0 comments on commit c178ddd

Please sign in to comment.