This file contains hidden or 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 "google_compute_region_backend_service" "elastic-internal-lb-i" { | |
name = "elastic-internal-lb-i" | |
load_balancing_scheme = "INTERNAL" | |
health_checks = [google_compute_health_check.my-tcp-health-check.self_link] | |
region = var.region | |
backend { | |
group = google_compute_instance_group.eu-elastic-ig-zone-d.self_link | |
} | |
backend { | |
group = google_compute_instance_group.eu-elastic-ig-zone-c.self_link |
This file contains hidden or 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 "google_compute_network" "my-elastic-network" { | |
name = "${var.project_name}-elastic-vpc" | |
auto_create_subnetworks = false | |
} | |
resource "google_compute_subnetwork" "my-elastic-subnet" { | |
name = "my-elastic-subnet" | |
ip_cidr_range = "select a range in your region" | |
network = google_compute_network.my-elastic-network.self_link | |
region = var.region |
This file contains hidden or 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 "google_compute_router_nat" "elastic-nat" { | |
name = "elastic-router-nat" | |
router = google_compute_router.elastic-router.name | |
region = var.region | |
nat_ip_allocate_option = "AUTO_ONLY" | |
source_subnetwork_ip_ranges_to_nat = "LIST_OF_SUBNETWORKS" | |
subnetwork { | |
name = google_compute_subnetwork.my-elastic-subnet.namesource_ip_ranges_to_nat = ["ALL_IP_RANGES"] | |
} | |
log_config { |
This file contains hidden or 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 "google_vpc_access_connector" "elastic-connector" { | |
name = "vpc-elastic-connector" | |
provider = "google-beta" | |
region = var.region | |
ip_cidr_range = "10.8.0.0/28" | |
network = "${var.project_name}-elastic-vpc" | |
min_throughput = "200" | |
max_throughput = "800" | |
} |
This file contains hidden or 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 "google_compute_instance_group" "eu-elastic-ig-zone-d" { | |
name = "eu-elastic-ig-zone-d" | |
network = google_compute_network.my-elastic-network.self_link | |
instances = [ | |
google_compute_instance.my-elastic-instance-1.self_link, | |
google_compute_instance.my-elastic-instance-2.self_link,] | |
zone = var.region_zone_d | |
} | |
resource "google_compute_instance_group" "eu-elastic-ig-zone-c" { |
This file contains hidden or 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 "google_compute_firewall" "allow-all-internal" { | |
name = "allow-all-internal" | |
network = google_compute_network.my-elastic-network.name | |
allow { | |
protocol = "tcp" | |
} | |
allow { | |
protocol = "udp" | |
} | |
allow { |
This file contains hidden or 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
#! /bin/bash | |
FILE=/usr/share/elasticsearch/credentials.json | |
if [ -f "$FILE" ]; then | |
echo "$FILE exist" | |
exit 0 | |
fi |
This file contains hidden or 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
################### INSTALL PREREQUISITIES ##################### | |
sudo apt update | |
sudo apt -y install default-jre curl jq | |
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - | |
sudo apt -y install apt-transport-https | |
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list | |
sudo apt -y install elasticsearch |
This file contains hidden or 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
####### APPEND TO ELASTICSEARCH CONFIGURATION FILE ######## | |
echo "node.name: ${node_name}" >> /etc/elasticsearch/elasticsearch.yml | |
echo "network.host : 0.0.0.0" >> /etc/elasticsearch/elasticsearch.yml | |
echo "discovery.seed_hosts:" >> /etc/elasticsearch/elasticsearch.yml | |
echo " - ${elastic_host_1}" >> /etc/elasticsearch/elasticsearch.yml | |
echo " - ${elastic_host_2}" >> /etc/elasticsearch/elasticsearch.yml | |
echo " - ${elastic_host_3}" >> /etc/elasticsearch/elasticsearch.yml | |
echo "cluster.name: elasticsearch" >> /etc/elasticsearch/elasticsearch.yml | |
echo "cluster.initial_master_nodes:" >> /etc/elasticsearch/elasticsearch.yml | |
echo " - ${master_node}" >> /etc/elasticsearch/elasticsearch.yml |
This file contains hidden or 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 "google_project_iam_custom_role" "elastic-backup" { | |
role_id = "Custom-elastic-role" | |
title = "Elastic role" | |
description = "Role for serviceaccounts used by elastic-vms" | |
permissions = ["iam.serviceAccountKeys.get","storage.objects.get","storage.buckets.get","storage.buckets.create","storage.objects.create","storage.objects.list","storage.objects.delete"] | |
} | |
resource "google_project_iam_member" "elastic-backup" { | |
role = "projects/${var.project_name}/roles/Custom-elastic-role" | |
member = "serviceAccount:elastic-backup@${var.project_name}.iam.gserviceaccount.com" |