From a0f7955543a8526144bc92a8be6b651a9fd34f5f Mon Sep 17 00:00:00 2001 From: Michael Li Date: Wed, 22 May 2024 18:23:17 +0000 Subject: [PATCH] backport of commit 3b3fa846f6a3faba285f5928a9d977cc44fa4007 --- enos/enos-scenario-e2e-aws-base-with-vault.hcl | 2 ++ enos/enos-scenario-e2e-aws-base.hcl | 2 ++ enos/enos-scenario-e2e-aws.hcl | 2 ++ enos/enos-scenario-e2e-database.hcl | 1 + enos/enos-scenario-e2e-ui-aws.hcl | 1 + enos/enos-variables.hcl | 1 + enos/enos.hcl | 2 +- testing/internal/e2e/boundary/host.go | 4 ++-- .../e2e/tests/aws/dynamichostcatalog_host_set_empty_test.go | 2 +- .../e2e/tests/aws/dynamichostcatalog_host_set_test.go | 4 ++-- testing/internal/e2e/tests/database/env_test.go | 1 + testing/internal/e2e/tests/database/migration_test.go | 2 +- 12 files changed, 17 insertions(+), 7 deletions(-) diff --git a/enos/enos-scenario-e2e-aws-base-with-vault.hcl b/enos/enos-scenario-e2e-aws-base-with-vault.hcl index cd92eb1d2f..073b60fe16 100644 --- a/enos/enos-scenario-e2e-aws-base-with-vault.hcl +++ b/enos/enos-scenario-e2e-aws-base-with-vault.hcl @@ -97,6 +97,7 @@ scenario "e2e_aws_base_with_vault" { vpc_tag_module = step.create_base_infra.vpc_tag_module worker_count = var.worker_count worker_instance_type = var.worker_instance_type + aws_region = var.aws_region } } @@ -159,6 +160,7 @@ scenario "e2e_aws_base_with_vault" { target_port = "22" vault_addr = step.create_vault_cluster.instance_public_ips[0] vault_root_token = step.create_vault_cluster.vault_root_token + aws_region = var.aws_region } } diff --git a/enos/enos-scenario-e2e-aws-base.hcl b/enos/enos-scenario-e2e-aws-base.hcl index ebfab3a60c..59909630c0 100644 --- a/enos/enos-scenario-e2e-aws-base.hcl +++ b/enos/enos-scenario-e2e-aws-base.hcl @@ -97,6 +97,7 @@ scenario "e2e_aws_base" { vpc_tag_module = step.create_base_infra.vpc_tag_module worker_count = var.worker_count worker_instance_type = var.worker_instance_type + aws_region = var.aws_region } } @@ -135,6 +136,7 @@ scenario "e2e_aws_base" { target_user = "ubuntu" target_port = "22" max_page_size = step.create_boundary_cluster.max_page_size + aws_region = var.aws_region } } diff --git a/enos/enos-scenario-e2e-aws.hcl b/enos/enos-scenario-e2e-aws.hcl index e7bfd502be..10e141b8a5 100644 --- a/enos/enos-scenario-e2e-aws.hcl +++ b/enos/enos-scenario-e2e-aws.hcl @@ -98,6 +98,7 @@ scenario "e2e_aws" { vpc_tag_module = step.create_base_infra.vpc_tag_module worker_count = var.worker_count worker_instance_type = var.worker_instance_type + aws_region = var.aws_region } } @@ -239,6 +240,7 @@ scenario "e2e_aws" { target_address = step.create_isolated_target.target_ips[0] worker_tag_egress = local.egress_tag max_page_size = step.create_boundary_cluster.max_page_size + aws_region = var.aws_region } } diff --git a/enos/enos-scenario-e2e-database.hcl b/enos/enos-scenario-e2e-database.hcl index d733230a70..e8a205c44c 100644 --- a/enos/enos-scenario-e2e-database.hcl +++ b/enos/enos-scenario-e2e-database.hcl @@ -128,6 +128,7 @@ scenario "e2e_database" { aws_secret_access_key = step.iam_setup.secret_access_key aws_host_set_filter1 = step.create_tag_inputs.tag_string max_page_size = 10 + aws_region = var.aws_region } } diff --git a/enos/enos-scenario-e2e-ui-aws.hcl b/enos/enos-scenario-e2e-ui-aws.hcl index 7817885b78..3107ef6ca2 100644 --- a/enos/enos-scenario-e2e-ui-aws.hcl +++ b/enos/enos-scenario-e2e-ui-aws.hcl @@ -103,6 +103,7 @@ scenario "e2e_ui_aws" { worker_count = var.worker_count worker_instance_type = var.worker_instance_type worker_type_tags = [local.egress_tag] + aws_region = var.aws_region } } diff --git a/enos/enos-variables.hcl b/enos/enos-variables.hcl index 2a5d46cb73..14832c8645 100644 --- a/enos/enos-variables.hcl +++ b/enos/enos-variables.hcl @@ -187,6 +187,7 @@ variable "go_test_timeout" { variable "aws_region" { description = "AWS region where the resources will be created" type = string + default = "us-east-1" } variable "go_version" { diff --git a/enos/enos.hcl b/enos/enos.hcl index f0e0cfc9db..3483a10ccc 100644 --- a/enos/enos.hcl +++ b/enos/enos.hcl @@ -24,7 +24,7 @@ terraform "default" { } provider "aws" "default" { - region = "us-east-1" + region = var.aws_region } provider "enos" "default" { diff --git a/testing/internal/e2e/boundary/host.go b/testing/internal/e2e/boundary/host.go index d5c7f13d1c..a98277874d 100644 --- a/testing/internal/e2e/boundary/host.go +++ b/testing/internal/e2e/boundary/host.go @@ -203,7 +203,7 @@ func AddHostToHostSetCli(t testing.TB, ctx context.Context, hostSetId string, ho // CreateAwsHostCatalogCli uses the cli to create a new AWS dynamic host catalog. // Returns the id of the new host catalog. -func CreateAwsHostCatalogCli(t testing.TB, ctx context.Context, projectId string, accessKeyId string, secretAccessKey string) (string, error) { +func CreateAwsHostCatalogCli(t testing.TB, ctx context.Context, projectId, accessKeyId, secretAccessKey, region string) (string, error) { name, err := base62.Random(16) if err != nil { return "", err @@ -215,7 +215,7 @@ func CreateAwsHostCatalogCli(t testing.TB, ctx context.Context, projectId string "-scope-id", projectId, "-plugin-name", "aws", "-attr", "disable_credential_rotation=true", - "-attr", "region=us-east-1", + "-attr", fmt.Sprintf("region=%s", region), "-secret", "access_key_id=env://E2E_AWS_ACCESS_KEY_ID", "-secret", "secret_access_key=env://E2E_AWS_SECRET_ACCESS_KEY", "-name", fmt.Sprintf("e2e Host Catalog %s", name), diff --git a/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_empty_test.go b/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_empty_test.go index 83f9c238ae..11a5f4dfe9 100644 --- a/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_empty_test.go +++ b/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_empty_test.go @@ -38,7 +38,7 @@ func TestCliCreateAwsDynamicHostCatalogWithEmptyHostSet(t *testing.T) { }) projectId, err := boundary.CreateProjectCli(t, ctx, orgId) require.NoError(t, err) - hostCatalogId, err := boundary.CreateAwsHostCatalogCli(t, ctx, projectId, c.AwsAccessKeyId, c.AwsSecretAccessKey) + hostCatalogId, err := boundary.CreateAwsHostCatalogCli(t, ctx, projectId, c.AwsAccessKeyId, c.AwsSecretAccessKey, c.AwsRegion) require.NoError(t, err) // Set up a host set diff --git a/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go b/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go index dad4a3bd8f..8d413b1c6f 100644 --- a/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go +++ b/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go @@ -43,7 +43,7 @@ func TestCliCreateAwsDynamicHostCatalogWithHostSet(t *testing.T) { }) projectId, err := boundary.CreateProjectCli(t, ctx, orgId) require.NoError(t, err) - hostCatalogId, err := boundary.CreateAwsHostCatalogCli(t, ctx, projectId, c.AwsAccessKeyId, c.AwsSecretAccessKey) + hostCatalogId, err := boundary.CreateAwsHostCatalogCli(t, ctx, projectId, c.AwsAccessKeyId, c.AwsSecretAccessKey, c.AwsRegion) require.NoError(t, err) // Set up a host set @@ -178,7 +178,7 @@ func TestApiCreateAwsDynamicHostCatalog(t *testing.T) { hostcatalogs.WithPluginName("aws"), hostcatalogs.WithAttributes(map[string]any{ "disable_credential_rotation": true, - "region": "us-east-1", + "region": c.AwsRegion, }), hostcatalogs.WithSecrets(map[string]any{ "access_key_id": c.AwsAccessKeyId, diff --git a/testing/internal/e2e/tests/database/env_test.go b/testing/internal/e2e/tests/database/env_test.go index a4dc744979..eb308ccac9 100644 --- a/testing/internal/e2e/tests/database/env_test.go +++ b/testing/internal/e2e/tests/database/env_test.go @@ -13,6 +13,7 @@ type config struct { AwsAccessKeyId string `envconfig:"E2E_AWS_ACCESS_KEY_ID" required:"true"` AwsSecretAccessKey string `envconfig:"E2E_AWS_SECRET_ACCESS_KEY" required:"true"` AwsHostSetFilter string `envconfig:"E2E_AWS_HOST_SET_FILTER" required:"true"` // e.g. "tag:testtag=true" + AwsRegion string `envconfig:"E2E_AWS_REGION" required:"true"` // e.g. "us-east-1" } func loadTestConfig() (*config, error) { diff --git a/testing/internal/e2e/tests/database/migration_test.go b/testing/internal/e2e/tests/database/migration_test.go index abcbb52280..2912536628 100644 --- a/testing/internal/e2e/tests/database/migration_test.go +++ b/testing/internal/e2e/tests/database/migration_test.go @@ -240,7 +240,7 @@ func populateBoundaryDatabase(t testing.TB, ctx context.Context, c *config, te T require.NoError(t, err) // Create AWS dynamic host catalog - awsHostCatalogId, err := boundary.CreateAwsHostCatalogCli(t, ctx, projectId, c.AwsAccessKeyId, c.AwsSecretAccessKey) + awsHostCatalogId, err := boundary.CreateAwsHostCatalogCli(t, ctx, projectId, c.AwsAccessKeyId, c.AwsSecretAccessKey, c.AwsRegion) require.NoError(t, err) awsHostSetId, err := boundary.CreateAwsHostSetCli(t, ctx, awsHostCatalogId, c.AwsHostSetFilter) require.NoError(t, err)