Terraform: Add job name as VPC ID 73/33673/3
authorpmikus <pmikus@cisco.com>
Tue, 7 Sep 2021 09:27:29 +0000 (09:27 +0000)
committerPeter Mikus <pmikus@cisco.com>
Tue, 7 Sep 2021 09:29:42 +0000 (09:29 +0000)
Signed-off-by: pmikus <pmikus@cisco.com>
Change-Id: I82819c924012c966ba91fdf39ffba500ee0ce6b0

fdio.infra.terraform/2n_aws_c5n/main.tf
fdio.infra.terraform/2n_aws_c5n/variables.tf
fdio.infra.terraform/3n_aws_c5n/main.tf
fdio.infra.terraform/3n_aws_c5n/variables.tf
resources/libraries/bash/function/common.sh

index a39eff6..44ec177 100644 (file)
@@ -1,12 +1,13 @@
 module "deploy" {
   source = "./deploy"
 
-  # Parameters starting with var. can be set using "TF_VAR_*" environment variables
-  # or -var parameter when running "terraform apply", for default values see ./variables.tf
+  # Parameters starting with var. can be set using "TF_VAR_*" environment
+  # variables or -var parameter when running "terraform apply", for default
+  # values see ./variables.tf
   testbed_name          = var.testbed_name
-  topology_name         = "2n_aws_c5n"
-  environment_name      = "CSIT-AWS"
-  resources_name_prefix = "CSIT_2n_aws_c5n"
+  topology_name         = var.topology_name
+  environment_name      = var.environment_name
+  resources_name_prefix = var.resources_name_prefix
 
   # AWS general
   region        = var.region
index 88ebda6..c3d81bf 100644 (file)
@@ -33,3 +33,21 @@ variable "testbed_name" {
   type        = string
   default     = "testbed1"
 }
+
+variable "topology_name" {
+  description = "Topology name"
+  type        = string
+  default     = "2n_aws_c5n"
+}
+
+variable "environment_name" {
+  description = "Environment name"
+  type        = string
+  default     = "CSIT-AWS"
+}
+
+variable "resources_name_prefix" {
+  description = "Resources name prefix"
+  type        = string
+  default     = "CSIT_2n_aws_c5n"
+}
index ed87161..abb60ce 100644 (file)
@@ -1,12 +1,13 @@
 module "deploy" {
   source = "./deploy"
 
-  # Parameters starting with var. can be set using "TF_VAR_*" environment variables
-  # or -var parameter when running "terraform apply", for default values see ./variables.tf
+  # Parameters starting with var. can be set using "TF_VAR_*" environment
+  # variables or -var parameter when running "terraform apply", for default
+  # values see ./variables.tf
   testbed_name          = var.testbed_name
-  topology_name         = "3n_aws_c5n"
-  environment_name      = "CSIT-AWS"
-  resources_name_prefix = "CSIT_3n_aws_c5n"
+  topology_name         = var.topology_name
+  environment_name      = var.environment_name
+  resources_name_prefix = var.resources_name_prefix
 
   # AWS general
   region        = var.region
index c87b1c3..29a611a 100644 (file)
@@ -35,3 +35,21 @@ variable "testbed_name" {
   type        = string
   default     = "testbed1"
 }
+
+variable "topology_name" {
+  description = "Topology name"
+  type        = string
+  default     = "3n_aws_c5n"
+}
+
+variable "environment_name" {
+  description = "Environment name"
+  type        = string
+  default     = "CSIT-AWS"
+}
+
+variable "resources_name_prefix" {
+  description = "Resources name prefix"
+  type        = string
+  default     = "CSIT_3n_aws_c5n"
+}
index ff632a2..e56799e 100644 (file)
@@ -606,6 +606,7 @@ function prepare_topology () {
     # Prepare virtual testbed topology if needed based on flavor.
 
     # Variables read:
+    # - TEST_CODE - String affecting test selection, usually jenkins job name.
     # - NODENESS - Node multiplicity of testbed, either "2n" or "3n".
     # - FLAVOR - Node flavor string, e.g. "clx" or "skx".
     # Functions called:
@@ -618,10 +619,12 @@ function prepare_topology () {
     case_text="${NODENESS}_${FLAVOR}"
     case "${case_text}" in
         "2n_aws")
+            export TF_VAR_testbed_name="${TEST_CODE}"
             terraform_init || die "Failed to call terraform init."
             terraform_apply || die "Failed to call terraform apply."
             ;;
         "3n_aws")
+            export TF_VAR_testbed_name="${TEST_CODE}"
             terraform_init || die "Failed to call terraform init."
             terraform_apply || die "Failed to call terraform apply."
             ;;