2023-02-02 17:15:17 -08:00
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
2022-08-31 12:08:46 -04:00
terraform {
required_providers {
enos = {
2024-06-10 11:13:09 -04:00
source = "registry.terraform.io/hashicorp-forge/enos"
2022-08-31 12:08:46 -04:00
}
}
}
2023-03-02 12:37:12 -05:00
variable "debug_no_run" {
description = "If set, this module will not execute the tests so that you can still access environment variables"
type = bool
default = false
}
2022-08-31 12:08:46 -04:00
variable "test_package" {
description = "Name of Go test package to run"
type = string
}
variable "alb_boundary_api_addr" {
description = "URL of the Boundary instance"
type = string
2022-12-13 17:00:50 -05:00
default = ""
2022-08-31 12:08:46 -04:00
}
variable "auth_method_id" {
description = "Id of Auth Method used to login to Boundary instance"
type = string
2022-12-06 15:59:17 -05:00
default = ""
2022-08-31 12:08:46 -04:00
}
variable "auth_login_name" {
description = "Name of admin user"
type = string
2022-12-13 17:00:50 -05:00
default = ""
2022-08-31 12:08:46 -04:00
}
variable "auth_password" {
description = "Password of admin user"
type = string
2022-12-13 17:00:50 -05:00
default = ""
2022-08-31 12:08:46 -04:00
}
2024-02-02 09:21:21 -08:00
variable "max_page_size" {
description = "Max allowed page size for pagination requests"
type = number
}
2022-08-31 12:08:46 -04:00
variable "local_boundary_dir" {
description = "Local Path to boundary executable"
type = string
}
2022-09-16 11:45:55 -04:00
variable "target_user" {
description = "SSH username for target"
type = string
2022-12-13 17:00:50 -05:00
default = ""
2022-09-16 11:45:55 -04:00
}
2022-08-31 12:08:46 -04:00
variable "aws_ssh_private_key_path" {
description = "Local Path to key used to SSH onto created hosts"
type = string
2022-12-13 17:00:50 -05:00
default = ""
2022-08-31 12:08:46 -04:00
}
2023-09-06 17:29:35 -04:00
variable "target_address" {
description = "Address of target"
2022-10-05 14:59:55 -04:00
type = string
default = ""
2022-08-31 12:08:46 -04:00
}
2023-02-23 12:05:06 -05:00
variable "target_port" {
description = "Port of target"
type = string
default = ""
}
2025-02-20 10:27:43 -05:00
variable "vault_addr_public" {
description = "Public address to a vault instance"
2023-02-23 12:05:06 -05:00
type = string
default = ""
}
2025-02-20 10:27:43 -05:00
variable "vault_addr_private" {
description = "Private address to a vault instance"
2022-09-16 11:45:55 -04:00
type = string
default = ""
}
variable "vault_root_token" {
description = "Root token for vault instance"
type = string
default = ""
}
2022-09-23 14:21:00 -04:00
variable "aws_access_key_id" {
description = "Access Key Id for AWS IAM user used in dynamic host catalogs"
type = string
default = ""
}
variable "aws_secret_access_key" {
description = "Secret Access Key for AWS IAM user used in dynamic host catalogs"
type = string
default = ""
}
variable "aws_host_set_filter1" {
description = "Filter tag for host set used in dynamic host catalogs"
type = string
default = ""
}
variable "aws_host_set_count1" {
description = "Number of hosts in aws_host_set_filter1"
type = number
default = 0
}
variable "aws_host_set_ips1" {
description = "List of IP addresses in aws_host_set_filter1"
type = list ( string )
default = [ "" ]
}
variable "aws_host_set_filter2" {
description = "Filter tag for host set used in dynamic host catalogs"
type = string
default = ""
}
2022-10-10 14:10:41 -04:00
variable "aws_host_set_ips2" {
description = "List of IP addresses in aws_host_set_filter2"
type = list ( string )
default = [ "" ]
2022-09-23 14:21:00 -04:00
}
2023-06-21 15:45:22 -04:00
variable "aws_region" {
description = "AWS region where the resources will be created"
type = string
default = ""
}
variable "aws_bucket_name" {
description = "AWS S3 bucket name"
type = string
default = ""
}
2024-06-07 12:05:11 -04:00
variable "aws_role_arn" {
description = "AWS Role ARN that has access to bucket"
type = string
default = ""
}
2023-09-11 14:25:32 -04:00
variable "worker_tag_ingress" {
type = string
default = ""
}
2025-01-21 10:37:04 -05:00
variable "worker_tag_isolated" {
type = string
default = ""
}
variable "worker_tag_collocated" {
2023-09-11 14:25:32 -04:00
type = string
default = ""
2023-04-24 16:58:39 -04:00
}
2023-12-14 13:48:29 -05:00
variable "worker_address" {
type = string
default = ""
}
2023-05-09 14:55:19 -04:00
variable "test_timeout" {
type = string
2024-01-17 09:45:34 -08:00
default = "20m"
2023-05-09 14:55:19 -04:00
}
2023-08-09 14:43:41 -04:00
variable "boundary_license" {
type = string
default = ""
}
2022-08-31 12:08:46 -04:00
2025-01-21 10:37:04 -05:00
variable "ip_version" {
description = "ip version used to setup boundary instance, should be 4, 6, or dual"
type = string
default = "4"
validation {
condition = contains ([ "4" , "6" , "dual" ], var . ip_version )
error_message = "ip_version must be one of: [4, 6, dual]"
}
}
2022-08-31 12:08:46 -04:00
locals {
aws_ssh_private_key_path = abspath ( var . aws_ssh_private_key_path )
2022-09-23 14:21:00 -04:00
aws_host_set_ips1 = jsonencode ( var . aws_host_set_ips1 )
2022-10-10 14:10:41 -04:00
aws_host_set_ips2 = jsonencode ( var . aws_host_set_ips2 )
2023-01-31 17:28:54 -05:00
package_name = reverse ( split ( "/" , var . test_package ))[ 0 ]
2022-08-31 12:08:46 -04:00
}
resource "enos_local_exec" "run_e2e_test" {
environment = {
2023-09-11 14:25:32 -04:00
E2E_TESTS = "true"
BOUNDARY_ADDR = var . alb_boundary_api_addr
BOUNDARY_LICENSE = var . boundary_license
E2E_PASSWORD_AUTH_METHOD_ID = var . auth_method_id
E2E_PASSWORD_ADMIN_LOGIN_NAME = var . auth_login_name
E2E_PASSWORD_ADMIN_PASSWORD = var . auth_password
E2E_TARGET_ADDRESS = var . target_address
E2E_TARGET_PORT = var . target_port
E2E_SSH_USER = var . target_user
E2E_SSH_KEY_PATH = local . aws_ssh_private_key_path
E2E_SSH_CA_KEY = ""
2025-02-20 10:27:43 -05:00
VAULT_ADDR = var . vault_addr_public
2023-09-11 14:25:32 -04:00
VAULT_TOKEN = var . vault_root_token
2025-02-20 10:27:43 -05:00
E2E_VAULT_ADDR_PUBLIC = var . vault_addr_public
E2E_VAULT_ADDR_PRIVATE = var . vault_addr_private
2023-09-11 14:25:32 -04:00
E2E_AWS_ACCESS_KEY_ID = var . aws_access_key_id
E2E_AWS_SECRET_ACCESS_KEY = var . aws_secret_access_key
E2E_AWS_HOST_SET_FILTER = var . aws_host_set_filter1
E2E_AWS_HOST_SET_IPS = local . aws_host_set_ips1
E2E_AWS_HOST_SET_FILTER2 = var . aws_host_set_filter2
E2E_AWS_HOST_SET_IPS2 = local . aws_host_set_ips2
E2E_AWS_REGION = var . aws_region
E2E_AWS_BUCKET_NAME = var . aws_bucket_name
2024-06-07 12:05:11 -04:00
E2E_AWS_ROLE_ARN = var . aws_role_arn
2023-09-11 14:25:32 -04:00
E2E_WORKER_TAG_INGRESS = var . worker_tag_ingress
2025-01-21 10:37:04 -05:00
E2E_WORKER_TAG_ISOLATED = var . worker_tag_isolated
E2E_WORKER_TAG_COLLOCATED = var . worker_tag_collocated
2023-12-14 13:48:29 -05:00
E2E_WORKER_ADDRESS = var . worker_address
2024-02-02 09:21:21 -08:00
E2E_MAX_PAGE_SIZE = var . max_page_size
2025-01-21 10:37:04 -05:00
E2E_IP_VERSION = var . ip_version
2022-08-31 12:08:46 -04:00
}
2023-06-21 15:45:22 -04:00
inline = var . debug_no_run ? [ "" ] : [
2024-05-23 09:54:27 -04:00
"set -o pipefail; PATH= \ " $ { var . local_boundary_dir } : $ PATH \ " go test -v ${ var . test_package } -count=1 -timeout ${ var . test_timeout } | tee ${ path . module } /../../test-e2e- ${ local . package_name } .log"
2023-06-21 15:45:22 -04:00
]
2022-08-31 12:08:46 -04:00
}
output "test_results" {
value = enos_local_exec . run_e2e_test . stdout
}