From e39f0406f353d91bf22de989775bed01382604e6 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Thu, 29 Jun 2023 11:20:12 -0400 Subject: [PATCH] test(e2e): Update worker module to create recordings directory if defined (#3340) --- enos/modules/worker/main.tf | 18 ++++++----- enos/modules/worker/templates/worker_bsr.hcl | 33 ++++++++++++++++++++ enos/modules/worker/variables.tf | 7 +++++ 3 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 enos/modules/worker/templates/worker_bsr.hcl diff --git a/enos/modules/worker/main.tf b/enos/modules/worker/main.tf index 8cf9f57cee..27bed20cfd 100644 --- a/enos/modules/worker/main.tf +++ b/enos/modules/worker/main.tf @@ -174,12 +174,13 @@ resource "enos_file" "worker_config" { destination = "/etc/boundary/boundary.hcl" content = templatefile("${path.module}/${var.config_file_path}", { - id = random_pet.worker.id - kms_key_id = data.aws_kms_key.kms_key.id - public_addr = aws_instance.worker.public_ip - type = jsonencode(var.worker_type_tags) - region = data.aws_availability_zone.worker_az.region - controller_addresses = jsonencode(var.controller_addresses) + id = random_pet.worker.id + kms_key_id = data.aws_kms_key.kms_key.id + public_addr = aws_instance.worker.public_ip + type = jsonencode(var.worker_type_tags) + region = data.aws_availability_zone.worker_az.region + controller_addresses = jsonencode(var.controller_addresses) + recording_storage_path = var.recording_storage_path }) transport = { @@ -195,8 +196,9 @@ resource "enos_boundary_start" "worker_start" { aws_vpc_security_group_ingress_rule.worker_to_controller, ] - bin_path = "/opt/boundary/bin" - config_path = "/etc/boundary" + bin_path = "/opt/boundary/bin" + config_path = "/etc/boundary" + recording_storage_path = var.recording_storage_path != "" ? var.recording_storage_path : null transport = { ssh = { host = aws_instance.worker.public_ip diff --git a/enos/modules/worker/templates/worker_bsr.hcl b/enos/modules/worker/templates/worker_bsr.hcl new file mode 100644 index 0000000000..1ef20c32d5 --- /dev/null +++ b/enos/modules/worker/templates/worker_bsr.hcl @@ -0,0 +1,33 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +listener "tcp" { + purpose = "proxy" + tls_disable = true + address = "0.0.0.0" +} + +worker { + # Name attr must be unique across workers + name = "worker-${id}" + description = "Enos Boundary worker ${id}" + + # Workers must be able to reach controllers on :9201 + initial_upstreams = ${controller_addresses} + + public_addr = "${public_addr}" + + tags { + region = ["${region}"] + type = ${type} + } + + recording_storage_path = "${recording_storage_path}" +} + +# must be same key as used on controller config +kms "awskms" { + purpose = "worker-auth" + region = "${region}" + kms_key_id = "${kms_key_id}" +} diff --git a/enos/modules/worker/variables.tf b/enos/modules/worker/variables.tf index 1bd24fa509..f0d7cb111a 100644 --- a/enos/modules/worker/variables.tf +++ b/enos/modules/worker/variables.tf @@ -133,4 +133,11 @@ variable "controller_sg_id" { variable "config_file_path" { description = "Path to a config file (relative to module directory)" type = string + default = "templates/worker.hcl" +} + +variable "recording_storage_path" { + description = "Path on instance to store recordings" + type = string + default = "" }