Last active
August 31, 2023 19:07
-
-
Save ImDevinC/5e8cf53908d6ac943074f5cd5ced22e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_elasticsearch_domain" "temp_replication_testing" { | |
count = var.deploy_config.environment == "jupiterone-prod-eu" ? 1 : 0 | |
domain_name = "temp-replication-testing" # domain names have to be unique | |
elasticsearch_version = var.es_version | |
cluster_config { | |
instance_type = var.es_instance_type | |
instance_count = var.es_instance_count | |
dedicated_master_enabled = var.es_dedicated_master_enabled | |
dedicated_master_count = var.es_dedicated_master_count | |
dedicated_master_type = var.es_dedicated_master_type | |
zone_awareness_enabled = false | |
} | |
encrypt_at_rest { | |
enabled = true | |
} | |
node_to_node_encryption { | |
enabled = true | |
} | |
ebs_options { | |
ebs_enabled = true | |
volume_size = var.es_ebs_volume_size | |
volume_type = "gp3" | |
throughput = var.es_ebs_volume_throughput | |
iops = var.es_ebs_volume_iops | |
} | |
vpc_options { | |
security_group_ids = [aws_security_group.temp_replication_testing[0].id] | |
subnet_ids = [ | |
var.provision_environment_private_subnets[0] | |
] | |
} | |
tags = { | |
Name = "temp-replication-testing" | |
Project = var.deploy_config.project | |
Classification = "Critical" | |
Resource = "aws_elasticsearch_domain:${var.deploy_config.project}:temp-replication-testing" | |
Temporary = "${var.deploy_config.project}:temp-replication-testing" | |
} | |
} | |
resource "aws_elasticsearch_domain_policy" "temp_replication_testing_domain_policy" { | |
count = var.deploy_config.environment == "jupiterone-prod-eu" ? 1 : 0 | |
domain_name = aws_elasticsearch_domain.temp_replication_testing[0].domain_name | |
access_policies = jsonencode({ | |
"Version" : "2012-10-17", | |
"Statement" : [ | |
{ | |
"Effect" : "Allow", | |
"Principal" : { | |
"AWS" : "*" | |
}, | |
"Action" : [ | |
"es:*" | |
], | |
"Resource" : "${aws_elasticsearch_domain.temp_replication_testing[0].arn}/*" | |
} | |
] | |
}) | |
} | |
resource "aws_security_group" "temp_replication_testing" { | |
count = var.deploy_config.environment == "jupiterone-prod-eu" ? 1 : 0 | |
name = "${var.deploy_config.project}-temp-replication-testing" | |
description = "Security group associated with temp replication cluster" | |
vpc_id = var.provision_environment_aws_vpc_default_id | |
egress { | |
from_port = 443 | |
to_port = 443 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
description = "Allow connections to HTTPS services" | |
} | |
ingress { | |
from_port = 443 | |
to_port = 443 | |
protocol = "tcp" | |
cidr_blocks = [ | |
var.provision_environment_aws_vpc_default_cidr_block | |
] | |
} | |
tags = { | |
Environment = var.target_name | |
Project = var.deploy_config.project | |
Name = "temp-replication-testing" | |
} | |
} | |
locals { | |
replication_temp_elasticsearch_domain_endpoint = var.deploy_config.environment == "jupiterone-prod-eu" ? "https://${aws_elasticsearch_domain.temp_replication_testing[0].endpoint}" : "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment