Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populating additional tags #437

Merged
merged 4 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ locals {
deployment_name_salted = join("-", [var.deployment_name, module.globals.salt])
password = var.password != null ? var.password : module.globals.random_password
workstation_cidr = var.workstation_cidr != null ? var.workstation_cidr : local.workstation_cidr_24
additional_tags = var.additional_tags != null ? { for item in var.additional_tags : split("=", item)[0] => split("=", item)[1] } : {}
tags = merge(module.globals.tags, { "deployment_name" = local.deployment_name_salted }, local.additional_tags)
tags = merge(module.globals.tags, var.additional_tags, { "deployment_name" = local.deployment_name_salted })

hub_main_private_key_file_path = var.hub_main_key_pair != null ? var.hub_main_key_pair.private_key_file_path : module.key_pair_hub_main[0].private_key_file_path
hub_main_public_key_name = var.hub_main_key_pair != null ? var.hub_main_key_pair.public_key_name : module.key_pair_hub_main[0].key_pair.key_pair_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
variable "additional_tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}

variable "deployment_name" {
type = string
default = "imperva-dsf"
Expand All @@ -19,18 +25,6 @@ variable "aws_region_2" {
description = "The second AWS region for the deployed resources (e.g us-east-2)"
}

variable "additional_tags" {
type = list(string)
default = []
description = "Additional tags to add to the DSFKit resources. Put tags in the following format - Key: Name. For example - [\"Key1=Name1\", \"Key2=Name2\"]"
validation {
condition = alltrue([
for tag_pair in var.additional_tags : can(regex("^([a-zA-Z0-9+\\-_.:/@]+)=([a-zA-Z0-9+\\-_.:/]+)$", tag_pair))
])
error_message = "Invalid tag format. All values must be in the format of 'key=value', where 'key' is a valid AWS tag name and 'value' is a valid AWS tag value. Note that the '=' character is not allowed in either the key or the value."
}
}

variable "enable_sonar" {
type = bool
default = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ locals {
password = var.password != null ? var.password : module.globals.random_password
workstation_cidr = var.workstation_cidr != null ? var.workstation_cidr : local.workstation_cidr_24
tarball_location = var.tarball_location != null ? var.tarball_location : module.globals.tarball_location
additional_tags = var.additional_tags != null ? { for item in var.additional_tags : split("=", item)[0] => split("=", item)[1] } : {}
tags = merge(module.globals.tags, { "deployment_name" = local.deployment_name_salted }, local.additional_tags)
tags = merge(module.globals.tags, var.additional_tags, { "deployment_name" = local.deployment_name_salted })
should_create_hub_main_key_pair = var.hub_main_key_pair == null ? true : false
should_create_hub_dr_key_pair = var.hub_dr_key_pair == null ? true : false
should_create_gw_main_key_pair = var.gw_main_key_pair == null ? true : false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
variable "additional_tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}

variable "deployment_name" {
type = string
default = "imperva-dsf"
Expand Down Expand Up @@ -44,18 +50,6 @@ variable "aws_region_gw_dr" {
description = "AWS region for the DR Agentless gateway (e.g us-east-1)"
}

variable "additional_tags" {
type = list(string)
default = []
description = "Additional tags to add to the DSFKit resources. Put tags in the following format - Key: Name. For example - [\"Key1=Name1\", \"Key2=Name2\"]"
validation {
condition = alltrue([
for tag_pair in var.additional_tags : can(regex("^([a-zA-Z0-9+\\-_.:/@]+)=([a-zA-Z0-9+\\-_.:/]+)$", tag_pair))
])
error_message = "Invalid tag format. All values must be in the format of 'key=value', where 'key' is a valid AWS tag name and 'value' is a valid AWS tag value. Note that the '=' character is not allowed in either the key or the value."
}
}

variable "subnet_hub_main" {
type = string
description = "AWS subnet id for the main DSF Hub (e.g subnet-xxxxxxxxxxxxxxxxx)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ locals {
password = var.password != null ? var.password : module.globals.random_password
workstation_cidr = var.workstation_cidr != null ? var.workstation_cidr : local.workstation_cidr_24
tarball_location = var.tarball_location != null ? var.tarball_location : module.globals.tarball_location
additional_tags = var.additional_tags != null ? { for item in var.additional_tags : split("=", item)[0] => split("=", item)[1] } : {}
tags = merge(module.globals.tags, { "deployment_name" = local.deployment_name_salted }, local.additional_tags)
tags = merge(module.globals.tags, var.additional_tags, { "deployment_name" = local.deployment_name_salted })
should_create_hub_key_pair = var.hub_key_pair == null ? true : false
should_create_gw_key_pair = var.gw_key_pair == null ? true : false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
variable "additional_tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}

variable "deployment_name" {
type = string
default = "imperva-dsf"
Expand All @@ -24,18 +30,6 @@ variable "sonar_version" {
}
}

variable "additional_tags" {
type = list(string)
default = []
description = "Additional tags to add to the DSFKit resources. Put tags in the following format - Key: Name. For example - [\"Key1=Name1\", \"Key2=Name2\"]"
validation {
condition = alltrue([
for tag_pair in var.additional_tags : can(regex("^([a-zA-Z0-9+\\-_.:/@]+)=([a-zA-Z0-9+\\-_.:/]+)$", tag_pair))
])
error_message = "Invalid tag format. All values must be in the format of 'key=value', where 'key' is a valid AWS tag name and 'value' is a valid AWS tag value. Note that the '=' character is not allowed in either the key or the value."
}
}

variable "tarball_location" {
type = object({
s3_bucket = string
Expand Down
2 changes: 1 addition & 1 deletion examples/aws/poc/dsf_deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ locals {
deployment_name_salted = join("-", [var.deployment_name, module.globals.salt])
password = var.password != null ? var.password : module.globals.random_password
workstation_cidr = var.workstation_cidr != null ? var.workstation_cidr : local.workstation_cidr_24
tags = merge(module.globals.tags, var.tags, { "deployment_name" = local.deployment_name_salted })
tags = merge(module.globals.tags, var.additional_tags, { "deployment_name" = local.deployment_name_salted })
private_key_file_path = module.key_pair.private_key_file_path
}
2 changes: 1 addition & 1 deletion examples/aws/poc/dsf_deployment/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable "tags" {
variable "additional_tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
Expand Down
2 changes: 1 addition & 1 deletion examples/aws/poc/sonar_basic_deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ locals {
password = var.password != null ? var.password : module.globals.random_password
workstation_cidr = var.workstation_cidr != null ? var.workstation_cidr : local.workstation_cidr_24
tarball_location = module.globals.tarball_location
tags = merge(module.globals.tags, { "deployment_name" = local.deployment_name_salted })
tags = merge(module.globals.tags, var.additional_tags,{ "deployment_name" = local.deployment_name_salted })
hub_subnet_id = var.subnet_ids != null ? var.subnet_ids.hub_subnet_id : module.vpc[0].public_subnets[0]
gw_subnet_id = var.subnet_ids != null ? var.subnet_ids.gw_subnet_id : module.vpc[0].private_subnets[0]
db_subnet_ids = var.subnet_ids != null ? var.subnet_ids.db_subnet_ids : module.vpc[0].public_subnets
Expand Down
6 changes: 6 additions & 0 deletions examples/aws/poc/sonar_basic_deployment/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
variable "additional_tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}

variable "deployment_name" {
type = string
default = "imperva-dsf"
Expand Down
2 changes: 1 addition & 1 deletion examples/aws/poc/sonar_hadr_deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ locals {
password = var.password != null ? var.password : module.globals.random_password
workstation_cidr = var.workstation_cidr != null ? var.workstation_cidr : local.workstation_cidr_24
tarball_location = var.tarball_location != null ? var.tarball_location : module.globals.tarball_location
tags = merge(module.globals.tags, { "deployment_name" = local.deployment_name_salted })
tags = merge(module.globals.tags, var.additional_tags, { "deployment_name" = local.deployment_name_salted })
main_hub_subnet_id = var.subnet_ids != null ? var.subnet_ids.main_hub_subnet_id : module.vpc[0].public_subnets[0]
dr_hub_subnet_id = var.subnet_ids != null ? var.subnet_ids.dr_hub_subnet_id : module.vpc[0].public_subnets[1]
main_gws_subnet_id = var.subnet_ids != null ? var.subnet_ids.main_gws_subnet_id : module.vpc[0].private_subnets[0]
Expand Down
6 changes: 6 additions & 0 deletions examples/aws/poc/sonar_hadr_deployment/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
variable "additional_tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}

variable "deployment_name" {
type = string
default = "imperva-dsf"
Expand Down
Loading