92 lines
2.0 KiB
HCL
92 lines
2.0 KiB
HCL
resource "aws_instance" "solr_ec2" {
|
|
ami = data.aws_ami.amazon_linux_2023.id
|
|
instance_type = "m7g.large"
|
|
key_name = "http-proxy"
|
|
|
|
vpc_security_group_ids = [ "sg-004e5855310c453a3", "sg-02d167406b1082698", "sg-08cd873bd29a2b3c9"]
|
|
subnet_id = "subnet-89bab8d4"
|
|
|
|
root_block_device {
|
|
volume_size = 30 # The size of the EBS volume in GB.
|
|
}
|
|
|
|
tags = {
|
|
Name = "solr_ec2_${var.stage}"
|
|
}
|
|
}
|
|
|
|
data "aws_ami" "amazon_linux_2023" {
|
|
most_recent = true
|
|
|
|
filter {
|
|
name = "name"
|
|
values = ["al2023-ami-*"]
|
|
}
|
|
|
|
filter {
|
|
name = "virtualization-type"
|
|
values = ["hvm"]
|
|
}
|
|
filter {
|
|
name="architecture"
|
|
values=["arm64"]
|
|
}
|
|
}
|
|
|
|
resource "aws_ebs_volume" "solr_ec2_storage" {
|
|
availability_zone = aws_instance.solr_ec2.availability_zone
|
|
size = 30 # Size of the EBS volume in GB.
|
|
|
|
tags = {
|
|
Name = "solr_storage_${var.stage}"
|
|
}
|
|
}
|
|
|
|
resource "aws_volume_attachment" "attach_solr_storage" {
|
|
device_name = "/dev/xvdf" # Choose a suitable device name based on your needs.
|
|
instance_id = aws_instance.solr_ec2.id
|
|
volume_id = aws_ebs_volume.solr_ec2_storage.id
|
|
|
|
#wait_for detachment_timeout = "30m"
|
|
}
|
|
|
|
# You may need to add additional resources such as IAM roles, security groups configuration, etc.,
|
|
# depending on what services or actions your Solr needs access to.
|
|
|
|
output "ec2_public_ip" {
|
|
value = aws_instance.solr_ec2.public_ip
|
|
}
|
|
|
|
|
|
resource "aws_service_discovery_service" "solr_ec2" {
|
|
name = "solr-ec2-${var.stage}"
|
|
|
|
dns_config {
|
|
namespace_id = var.local_namespace
|
|
dns_records {
|
|
ttl = 60
|
|
type = "A"
|
|
}
|
|
|
|
routing_policy = "MULTIVALUE"
|
|
}
|
|
|
|
health_check_custom_config {
|
|
failure_threshold = 1
|
|
}
|
|
}
|
|
|
|
resource "aws_service_discovery_instance" "solr_instance" {
|
|
service_id = aws_service_discovery_service.solr_ec2.id
|
|
instance_id = "solr-ec2"
|
|
|
|
attributes = {
|
|
"AWS_INSTANCE_IPV4" = aws_instance.solr_ec2.private_ip
|
|
}
|
|
|
|
depends_on = [
|
|
aws_service_discovery_service.solr_ec2,
|
|
aws_instance.solr_ec2,
|
|
]
|
|
}
|