From bfc3babd204d5c2db27a1a8af708c00409a2dcb1 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Thu, 22 Jun 2023 16:12:00 -0400 Subject: [PATCH] chore(e2e): Change port used by vault docker container (#3355) * chore: Update scenario reference name * chore: Use different port for vault This avoids any conflicts with other uses of vault --- .github/workflows/enos-run.yml | 2 +- enos/enos-scenario-e2e-docker-base-with-vault.hcl | 1 + enos/modules/docker_vault/main.tf | 15 ++++++++++++--- enos/modules/test_e2e/main.tf | 7 ++++++- enos/modules/test_e2e_ui/main.tf | 7 ++++++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/enos-run.yml b/.github/workflows/enos-run.yml index 757b2e9159..8272ec4edb 100644 --- a/.github/workflows/enos-run.yml +++ b/.github/workflows/enos-run.yml @@ -181,7 +181,7 @@ jobs: run: | wget https://releases.hashicorp.com/vault/1.12.2/vault_1.12.2_linux_amd64.zip -O /tmp/test-deps/vault.zip - name: Install Vault CLI - if: matrix.filter == 'e2e_base_with_vault builder:crt' || matrix.filter == 'e2e_database' || matrix.filter == 'e2e_ui builder:crt' || matrix.filter == 'e2e_docker_base_with_vault builder:crt' + if: matrix.filter == 'e2e_aws_base_with_vault builder:crt' || matrix.filter == 'e2e_database' || matrix.filter == 'e2e_ui builder:crt' || matrix.filter == 'e2e_docker_base_with_vault builder:crt' run: | unzip /tmp/test-deps/vault.zip -d /usr/local/bin - name: Add hosts to /etc/hosts diff --git a/enos/enos-scenario-e2e-docker-base-with-vault.hcl b/enos/enos-scenario-e2e-docker-base-with-vault.hcl index d8cc1406a9..765ac52787 100644 --- a/enos/enos-scenario-e2e-docker-base-with-vault.hcl +++ b/enos/enos-scenario-e2e-docker-base-with-vault.hcl @@ -122,6 +122,7 @@ scenario "e2e_docker_base_with_vault" { vault_addr = step.create_vault.address vault_addr_internal = step.create_vault.address_internal vault_root_token = step.create_vault.token + vault_port = step.create_vault.port } } diff --git a/enos/modules/docker_vault/main.tf b/enos/modules/docker_vault/main.tf index b5635da3b4..d128388734 100644 --- a/enos/modules/docker_vault/main.tf +++ b/enos/modules/docker_vault/main.tf @@ -37,6 +37,11 @@ variable "vault_token" { type = string default = "boundarytok" } +variable "vault_port" { + description = "External Port to use" + type = string + default = "8300" +} resource "docker_image" "vault" { name = var.image_name @@ -51,7 +56,7 @@ resource "docker_container" "vault" { ] ports { internal = 8200 - external = 8200 + external = var.vault_port } capabilities { add = ["IPC_LOCK"] @@ -66,7 +71,7 @@ resource "enos_local_exec" "check_address" { docker_container.vault ] - inline = ["timeout 10s bash -c 'until curl http://0.0.0.0:8200; do sleep 2; done'"] + inline = ["timeout 10s bash -c 'until curl http://0.0.0.0:${var.vault_port}; do sleep 2; done'"] } resource "enos_local_exec" "check_health" { @@ -75,7 +80,7 @@ resource "enos_local_exec" "check_health" { ] environment = { - VAULT_ADDR = "http://0.0.0.0:8200" + VAULT_ADDR = "http://0.0.0.0:${var.vault_port}" VAULT_TOKEN = var.vault_token } @@ -93,3 +98,7 @@ output "address_internal" { output "token" { value = var.vault_token } + +output "port" { + value = var.vault_port +} diff --git a/enos/modules/test_e2e/main.tf b/enos/modules/test_e2e/main.tf index 3188d35e43..b3c34e8e49 100644 --- a/enos/modules/test_e2e/main.tf +++ b/enos/modules/test_e2e/main.tf @@ -77,6 +77,11 @@ variable "vault_root_token" { type = string default = "" } +variable "vault_port" { + description = "External Port that vault instance is attached to (outside of docker network)" + type = string + default = "8200" +} variable "aws_access_key_id" { description = "Access Key Id for AWS IAM user used in dynamic host catalogs" type = string @@ -133,7 +138,7 @@ variable "test_timeout" { locals { aws_ssh_private_key_path = abspath(var.aws_ssh_private_key_path) - vault_addr = var.vault_addr != "" ? "http://${var.vault_addr}:8200" : "" + vault_addr = var.vault_addr != "" ? "http://${var.vault_addr}:${var.vault_port}" : "" vault_addr_internal = var.vault_addr_internal != "" ? "http://${var.vault_addr_internal}:8200" : local.vault_addr aws_host_set_ips1 = jsonencode(var.aws_host_set_ips1) aws_host_set_ips2 = jsonencode(var.aws_host_set_ips2) diff --git a/enos/modules/test_e2e_ui/main.tf b/enos/modules/test_e2e_ui/main.tf index e05e47542c..4dcb40d93a 100644 --- a/enos/modules/test_e2e_ui/main.tf +++ b/enos/modules/test_e2e_ui/main.tf @@ -77,6 +77,11 @@ variable "vault_root_token" { type = string default = "" } +variable "vault_port" { + description = "External Port that vault instance is attached to (outside of docker network)" + type = string + default = "8200" +} variable "aws_access_key_id" { description = "Access Key Id for AWS IAM user used in dynamic host catalogs" type = string @@ -115,7 +120,7 @@ variable "aws_host_set_ips2" { locals { aws_ssh_private_key_path = abspath(var.aws_ssh_private_key_path) - vault_addr = var.vault_addr != "" ? "http://${var.vault_addr}:8200" : "" + vault_addr = var.vault_addr != "" ? "http://${var.vault_addr}:${var.vault_port}" : "" vault_addr_internal = var.vault_addr_internal != "" ? "http://${var.vault_addr_internal}:8200" : local.vault_addr aws_host_set_ips1 = jsonencode(var.aws_host_set_ips1) aws_host_set_ips2 = jsonencode(var.aws_host_set_ips2)