Skip to content

Commit

Permalink
Build Terraform custom example
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf13 committed Oct 15, 2023
1 parent 66f1c64 commit 6dab2de
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 80 deletions.
62 changes: 3 additions & 59 deletions examples/installation/sonar_single_account_deployment/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
provider "aws" {
profile = var.aws_profile
region = var.aws_region
}

module "globals" {
Expand Down Expand Up @@ -61,10 +59,6 @@ data "aws_subnet" "main_hub" {
id = var.subnet_hub_main
}

data "aws_subnet" "dr_hub" {
id = var.subnet_hub_dr
}

data "aws_subnet" "subnet_gw" {
id = var.subnet_gw
}
Expand All @@ -89,39 +83,6 @@ module "hub_main" {
ssh_public_key_name = local.hub_public_key_name
}
allowed_web_console_and_api_cidrs = var.web_console_cidr
allowed_hub_cidrs = [data.aws_subnet.dr_hub.cidr_block]
allowed_agentless_gw_cidrs = [data.aws_subnet.subnet_gw.cidr_block]
allowed_all_cidrs = local.workstation_cidr

skip_instance_health_verification = var.hub_skip_instance_health_verification
terraform_script_path_folder = var.terraform_script_path_folder
sonarw_private_key_secret_name = var.sonarw_hub_private_key_secret_name
sonarw_public_key_content = try(trimspace(file(var.sonarw_hub_public_key_file_path)), null)
instance_profile_name = var.hub_instance_profile_name
tags = local.tags
}

module "hub_dr" {
source = "imperva/dsf-hub/aws"
version = "1.5.6" # latest release tag
friendly_name = join("-", [local.deployment_name_salted, "hub", "DR"])
subnet_id = var.subnet_hub_dr
security_group_ids = var.security_group_ids_hub
binaries_location = local.tarball_location
password = local.password
password_secret_name = var.password_secret_name
instance_type = var.hub_instance_type
ebs = var.hub_ebs_details
ami = var.ami
hadr_dr_node = true
main_node_sonarw_public_key = module.hub_main.sonarw_public_key
main_node_sonarw_private_key = module.hub_main.sonarw_private_key
ssh_key_pair = {
ssh_private_key_file_path = local.hub_private_key_file_path
ssh_public_key_name = local.hub_public_key_name
}
allowed_web_console_and_api_cidrs = var.web_console_cidr
allowed_hub_cidrs = [data.aws_subnet.main_hub.cidr_block]
allowed_agentless_gw_cidrs = [data.aws_subnet.subnet_gw.cidr_block]
allowed_all_cidrs = local.workstation_cidr

Expand Down Expand Up @@ -151,7 +112,7 @@ module "agentless_gw" {
ssh_private_key_file_path = local.gw_private_key_file_path
ssh_public_key_name = local.gw_public_key_name
}
allowed_hub_cidrs = [data.aws_subnet.main_hub.cidr_block, data.aws_subnet.dr_hub.cidr_block]
allowed_hub_cidrs = [data.aws_subnet.main_hub.cidr_block]
allowed_all_cidrs = local.workstation_cidr
ingress_communication_via_proxy = var.use_hub_as_proxy ? {
proxy_address = module.hub_main.private_ip
Expand All @@ -166,26 +127,9 @@ module "agentless_gw" {
tags = local.tags
}

module "hub_hadr" {
source = "imperva/dsf-hadr/null"
version = "1.5.6" # latest release tag
sonar_version = module.globals.tarball_location.version
dsf_main_ip = module.hub_main.private_ip
dsf_main_private_ip = module.hub_main.private_ip
dsf_dr_ip = module.hub_dr.private_ip
dsf_dr_private_ip = module.hub_dr.private_ip
ssh_key_path = local.hub_private_key_file_path
ssh_user = module.hub_main.ssh_user
terraform_script_path_folder = var.terraform_script_path_folder
depends_on = [
module.hub_main,
module.hub_dr
]
}

locals {
hub_gw_combinations = setproduct(
[module.hub_main, module.hub_dr],
[module.hub_main],
concat(
[for idx, val in module.agentless_gw : val]
)
Expand Down Expand Up @@ -213,7 +157,7 @@ module "federation" {
proxy_ssh_user = module.hub_main.ssh_user
} : null
depends_on = [
module.hub_hadr,
module.hub_main,
module.agentless_gw
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ output "dsf_hubs" {
display_name = try(module.hub_main.display_name, null)
ssh_command = try("ssh -i ${local.hub_private_key_file_path} ${module.hub_main.ssh_user}@${module.hub_main.private_ip}", null)
}
dr = {
private_ip = try(module.hub_dr.private_ip, null)
jsonar_uid = try(module.hub_dr.jsonar_uid, null)
display_name = try(module.hub_dr.display_name, null)
ssh_command = try("ssh -i ${local.hub_private_key_file_path} ${module.hub_dr.ssh_user}@${module.hub_dr.private_ip}", null)
}
}
}

Expand Down
15 changes: 0 additions & 15 deletions examples/installation/sonar_single_account_deployment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ variable "deployment_name" {
description = "Deployment name for some of the created resources. Please note that when running the deployment with a custom 'deployment_name' variable, you should ensure that the corresponding condition in the AWS permissions of the user who runs the deployment reflects the new custom variable."
}

variable "aws_profile" {
type = string
description = "AWS profile name for the deployed resources"
}

variable "aws_region" {
type = string
description = "AWS region for the deployed resources (e.g us-east-2)"
}

variable "sonar_version" {
type = string
default = "4.12"
Expand Down Expand Up @@ -51,11 +41,6 @@ variable "subnet_hub_main" {
description = "AWS subnet id for the main DSF Hub (e.g subnet-xxxxxxxxxxxxxxxxx)"
}

variable "subnet_hub_dr" {
type = string
description = "AWS subnet id for the DR DSF Hub (e.g subnet-xxxxxxxxxxxxxxxxx)"
}

variable "subnet_gw" {
type = string
description = "AWS subnet id for the main Agentless Gateway (e.g subnet-xxxxxxxxxxxxxxxxx)"
Expand Down

0 comments on commit 6dab2de

Please sign in to comment.