From 9398248c3258d434a16364db6968e2a20667c173 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Mon, 7 Oct 2024 14:12:00 -0400 Subject: [PATCH] test(e2e): Add user name to AWS resources (#5149) This change makes it easier to identify who generated these resources when looking at the AWS console --- enos/modules/aws_boundary/boundary-instances.tf | 6 ++++-- enos/modules/aws_target/main.tf | 4 +++- enos/modules/aws_vault/vault-instances.tf | 2 +- enos/modules/aws_vpc/main.tf | 4 +++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/enos/modules/aws_boundary/boundary-instances.tf b/enos/modules/aws_boundary/boundary-instances.tf index 6a72b0ebf..9005f5082 100644 --- a/enos/modules/aws_boundary/boundary-instances.tf +++ b/enos/modules/aws_boundary/boundary-instances.tf @@ -1,6 +1,8 @@ # Copyright (c) HashiCorp, Inc. # SPDX-License-Identifier: BUSL-1.1 +data "aws_caller_identity" "current" {} + resource "aws_instance" "controller" { count = var.controller_count ami = var.ubuntu_ami_id @@ -24,7 +26,7 @@ resource "aws_instance" "controller" { tags = merge(local.common_tags, { - Name = "${local.name_prefix}-boundary-controller-${count.index}" + Name = "${local.name_prefix}-boundary-controller-${count.index}-${split(":", data.aws_caller_identity.current.user_id)[1]}" Type = local.boundary_cluster_tag, }, ) @@ -50,7 +52,7 @@ resource "aws_instance" "worker" { tags = merge(local.common_tags, { - Name = "${local.name_prefix}-boundary-worker-${count.index}", + Name = "${local.name_prefix}-boundary-worker-${count.index}-${split(":", data.aws_caller_identity.current.user_id)[1]}", Type = local.boundary_cluster_tag, }, ) diff --git a/enos/modules/aws_target/main.tf b/enos/modules/aws_target/main.tf index c51e9a96c..70ddf4191 100644 --- a/enos/modules/aws_target/main.tf +++ b/enos/modules/aws_target/main.tf @@ -28,6 +28,8 @@ variable "ingress_cidr" { data "enos_environment" "current" {} +data "aws_caller_identity" "current" {} + resource "aws_security_group" "boundary_target" { name_prefix = "boundary-target-sg" description = "SSH and boundary Traffic" @@ -70,7 +72,7 @@ resource "aws_instance" "target" { key_name = var.aws_ssh_keypair_name tags = merge(var.additional_tags, { - "Name" : "boundary-target-${count.index}", + "Name" : "boundary-target-${count.index}-${split(":", data.aws_caller_identity.current.user_id)[1]}", "Type" : "target", "Project" : "Enos", "Project Name" : "qti-enos-boundary", diff --git a/enos/modules/aws_vault/vault-instances.tf b/enos/modules/aws_vault/vault-instances.tf index 864ebf93c..3007d99a3 100644 --- a/enos/modules/aws_vault/vault-instances.tf +++ b/enos/modules/aws_vault/vault-instances.tf @@ -12,7 +12,7 @@ resource "aws_instance" "vault_instance" { tags = merge( var.common_tags, { - Name = "${local.name_suffix}-vault-${var.vault_node_prefix}-${each.key}" + Name = "${local.name_suffix}-vault-${var.vault_node_prefix}-${each.key}-${split(":", data.aws_caller_identity.current.user_id)[1]}" Type = local.vault_cluster_tag }, ) diff --git a/enos/modules/aws_vpc/main.tf b/enos/modules/aws_vpc/main.tf index f5632731c..f3fa8ff9e 100644 --- a/enos/modules/aws_vpc/main.tf +++ b/enos/modules/aws_vpc/main.tf @@ -55,6 +55,8 @@ locals { ) } +data "aws_caller_identity" "current" {} + data "aws_availability_zones" "available" { state = "available" @@ -137,7 +139,7 @@ resource "aws_vpc" "vpc" { tags = merge( local.common_tags, { - "Name" = var.name + "Name" = "${var.name}-${split(":", data.aws_caller_identity.current.user_id)[1]}" }, ) }