From f545c65ac079857e1fd65ab26d90711962c312af Mon Sep 17 00:00:00 2001 From: musa-asad Date: Wed, 27 Nov 2024 09:00:38 -0500 Subject: [PATCH] Update variables. --- terraform/{e2e/eks => eks/e2e}/main.tf | 29 +++++++++++++++------ terraform/{e2e/eks => eks/e2e}/providers.tf | 0 terraform/{e2e/eks => eks/e2e}/variables.tf | 4 +-- 3 files changed, 23 insertions(+), 10 deletions(-) rename terraform/{e2e/eks => eks/e2e}/main.tf (83%) rename terraform/{e2e/eks => eks/e2e}/providers.tf (100%) rename terraform/{e2e/eks => eks/e2e}/variables.tf (94%) diff --git a/terraform/e2e/eks/main.tf b/terraform/eks/e2e/main.tf similarity index 83% rename from terraform/e2e/eks/main.tf rename to terraform/eks/e2e/main.tf index dcbe56430..268f79cfd 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/eks/e2e/main.tf @@ -10,7 +10,6 @@ module "basic_components" { } locals { - aws_eks = "aws eks" cluster_name = var.cluster_name != "" ? var.cluster_name : "cwagent-monitoring-config-e2e-eks" } @@ -23,8 +22,8 @@ resource "aws_eks_cluster" "this" { role_arn = module.basic_components.role_arn version = var.k8s_version vpc_config { - subnet_ids = module.basic_components.public_subnet_ids - security_group_ids = [module.basic_components.security_group] + subnet_ids = module.basic_components.public_subnet_ids + security_group_ids = [module.basic_components.security_group] } } @@ -92,12 +91,27 @@ resource "aws_iam_role_policy_attachment" "node_CloudWatchAgentServerPolicy" { role = aws_iam_role.node_role.name } +resource "null_resource" "helm_charts" { + provisioner "local-exec" { + command = <<-EOT + git clone https://github.com/aws-observability/helm-charts.git helm-charts + cd helm-charts + git checkout ${var.helm_charts_branch} + EOT + } + + provisioner "local-exec" { + when = destroy + command = "rm -rf ${path.module}/helm-charts" + } +} + resource "null_resource" "test" { - depends_on = [aws_eks_cluster.this, aws_eks_node_group.this] + depends_on = [aws_eks_cluster.this, aws_eks_node_group.this, null_resource.helm_charts] provisioner "local-exec" { command = <<-EOT - go test -v ${var.validate_test} \ + go test -v ${var.test_dir} \ -region=${var.region} \ -k8s_version=${var.k8s_version} \ -cluster_name=${aws_eks_cluster.this.name} \ @@ -111,8 +125,7 @@ resource "null_resource" "test" { -agent_config=${var.agent_config} \ -otel_config=${var.otel_config} \ -prometheus_config=${var.prometheus_config} \ - -sample_app=${var.sample_app} \ - -sample_app_name=${var.sample_app_name} + -sample_app=${var.sample_app} EOT } -} +} \ No newline at end of file diff --git a/terraform/e2e/eks/providers.tf b/terraform/eks/e2e/providers.tf similarity index 100% rename from terraform/e2e/eks/providers.tf rename to terraform/eks/e2e/providers.tf diff --git a/terraform/e2e/eks/variables.tf b/terraform/eks/e2e/variables.tf similarity index 94% rename from terraform/e2e/eks/variables.tf rename to terraform/eks/e2e/variables.tf index 6ea30bd23..1959df2ef 100644 --- a/terraform/e2e/eks/variables.tf +++ b/terraform/eks/e2e/variables.tf @@ -13,7 +13,7 @@ variable "k8s_version" { variable "cluster_name" { type = string - default = "cwagent-otel-config-e2e-eks" + default = "cwagent-monitoring-config-e2e-eks" } variable "helm_charts_branch" { @@ -51,7 +51,7 @@ variable "cloudwatch_agent_operator_repository_url" { default = "public.ecr.aws/cloudwatch-agent" } -variable "validate_test" { +variable "test_dir" { type = string default = "" }