From 6e384f1108ebcbe8930345059767cdbe6c67bc73 Mon Sep 17 00:00:00 2001 From: ronenbdbq <123952033+ronenbdbq@users.noreply.github.com> Date: Tue, 31 Jan 2023 22:16:07 +1100 Subject: [PATCH 1/5] Adding Sumo logic and New Relic setup --- packer/elasticsearch7-node.packer.json | 10 ++++++++++ packer/install-newrelic.sh | 9 +++++++++ packer/install-sumo.sh | 6 ++++++ packer/variables.json | 2 ++ 4 files changed, 27 insertions(+) create mode 100644 packer/install-newrelic.sh create mode 100644 packer/install-sumo.sh diff --git a/packer/elasticsearch7-node.packer.json b/packer/elasticsearch7-node.packer.json index 411c106..7519bd0 100644 --- a/packer/elasticsearch7-node.packer.json +++ b/packer/elasticsearch7-node.packer.json @@ -105,6 +105,16 @@ { "type": "shell", "script": "install-custom.sh" + }, + { + "type": "shell", + "environment_vars": [ "NR_LICENSE={{user `nr_license`}}" ], + "script": "install-newrelic.sh" + }, + { + "type": "shell", + "environment_vars": [ "SUMO_TOKEN={{user `sumo_token`}}" ], + "script": "install-sumo.sh" } ] } diff --git a/packer/install-newrelic.sh b/packer/install-newrelic.sh new file mode 100644 index 0000000..8e0286f --- /dev/null +++ b/packer/install-newrelic.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +curl -fsSL https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/newrelic-infra.gpg +echo "deb https://download.newrelic.com/infrastructure_agent/linux/apt focal main" | sudo tee -a /etc/apt/sources.list.d/newrelic-infra.list +sudo apt update +sudo apt-get install newrelic-infra -y +echo $NR_LICENSE | sudo tee -a /etc/newrelic-infra.yml + diff --git a/packer/install-sumo.sh b/packer/install-sumo.sh new file mode 100644 index 0000000..148400c --- /dev/null +++ b/packer/install-sumo.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +curl -o /tmp/SumoCollector.sh https://collectors.us2.sumologic.com/rest/download/linux/64 +chmod +x /tmp/SumoCollector.sh +sudo /tmp/SumoCollector.sh -q -Vsumo.token_and_url=foobar diff --git a/packer/variables.json b/packer/variables.json index 62e2d62..9bef2ba 100644 --- a/packer/variables.json +++ b/packer/variables.json @@ -1,5 +1,7 @@ { "elasticsearch_version": "", + "nr_license": "", + "sumo_token": "", "aws_region": "us-east-1", "aws_az": "us-east-1d", From fd09bc135e3f3b683a0402c039cfa88a6f4bf803 Mon Sep 17 00:00:00 2001 From: ronenbdbq <123952033+ronenbdbq@users.noreply.github.com> Date: Thu, 2 Feb 2023 22:03:18 +1100 Subject: [PATCH 2/5] adding sumo environment variable --- packer/install-sumo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer/install-sumo.sh b/packer/install-sumo.sh index 148400c..3d4e662 100644 --- a/packer/install-sumo.sh +++ b/packer/install-sumo.sh @@ -3,4 +3,4 @@ set -e curl -o /tmp/SumoCollector.sh https://collectors.us2.sumologic.com/rest/download/linux/64 chmod +x /tmp/SumoCollector.sh -sudo /tmp/SumoCollector.sh -q -Vsumo.token_and_url=foobar +sudo /tmp/SumoCollector.sh -q -Vsumo.token_and_url=$SUMO_TOKEN From b3bbd5d4a5264913a170631c9eba9b0950e3c7fd Mon Sep 17 00:00:00 2001 From: ronenbdbq <123952033+ronenbdbq@users.noreply.github.com> Date: Thu, 2 Feb 2023 23:02:54 +1100 Subject: [PATCH 3/5] adding propagated global tag support --- terraform-aws/main.tf | 3 +++ terraform-aws/variables.tf | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/terraform-aws/main.tf b/terraform-aws/main.tf index e71eec9..d3a3883 100644 --- a/terraform-aws/main.tf +++ b/terraform-aws/main.tf @@ -1,5 +1,8 @@ provider "aws" { region = var.aws_region + default_tags { + tags = var.global_tags + } } resource "random_string" "vm-login-password" { diff --git a/terraform-aws/variables.tf b/terraform-aws/variables.tf index d7e1c16..30b1327 100644 --- a/terraform-aws/variables.tf +++ b/terraform-aws/variables.tf @@ -12,6 +12,12 @@ variable "vpc_id" { type = string } +variable "global_tags" { + description = "Tags which are propgated to all resources that support tags excluding auto scalling groups" + type = map(string) + default = {} +} + variable "clients_subnet_ids" { description = "Subnets to run client nodes in, defined as avalabilityZone -> subnets mapping. Will autofill to all available subnets in AZ when left empty." type = map(list(string)) From 174afd0132254cb8f8d0c64053967d152c796c4b Mon Sep 17 00:00:00 2001 From: ronenbdbq <123952033+ronenbdbq@users.noreply.github.com> Date: Thu, 9 Feb 2023 21:21:58 +1100 Subject: [PATCH 4/5] using sumo access key --- packer/elasticsearch7-node.packer.json | 3 ++- packer/install-sumo.sh | 2 +- packer/variables.json | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packer/elasticsearch7-node.packer.json b/packer/elasticsearch7-node.packer.json index 7519bd0..968083d 100644 --- a/packer/elasticsearch7-node.packer.json +++ b/packer/elasticsearch7-node.packer.json @@ -113,7 +113,8 @@ }, { "type": "shell", - "environment_vars": [ "SUMO_TOKEN={{user `sumo_token`}}" ], + "environment_vars": [ "SUMO_ACCESS_ID={{user `sumo_acccess_id`}}", + "SUMO_ACCESS_KEY={{user `sumo_acccess_key`}}" ], "script": "install-sumo.sh" } ] diff --git a/packer/install-sumo.sh b/packer/install-sumo.sh index 3d4e662..f9cf670 100644 --- a/packer/install-sumo.sh +++ b/packer/install-sumo.sh @@ -3,4 +3,4 @@ set -e curl -o /tmp/SumoCollector.sh https://collectors.us2.sumologic.com/rest/download/linux/64 chmod +x /tmp/SumoCollector.sh -sudo /tmp/SumoCollector.sh -q -Vsumo.token_and_url=$SUMO_TOKEN +sudo /tmp/SumoCollector.sh -q -Vsumo.accessid=$SUMO_ACCESS_ID -Vsumo.accesskey=$SUMO_ACCESS_KEY diff --git a/packer/variables.json b/packer/variables.json index 9bef2ba..ec148dc 100644 --- a/packer/variables.json +++ b/packer/variables.json @@ -1,7 +1,8 @@ { "elasticsearch_version": "", "nr_license": "", - "sumo_token": "", + "sumo_acccess_id": "", + "sumo_acccess_key": "", "aws_region": "us-east-1", "aws_az": "us-east-1d", From 90abc833c859462b1edc579600d79286a903933a Mon Sep 17 00:00:00 2001 From: ronenbdbq <123952033+ronenbdbq@users.noreply.github.com> Date: Sat, 11 Feb 2023 17:39:16 +1100 Subject: [PATCH 5/5] Enabling scale in data protection for data nodes --- terraform-aws/datas.tf | 1 + terraform-aws/variables.tf | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/terraform-aws/datas.tf b/terraform-aws/datas.tf index bf80f8f..9f5164d 100644 --- a/terraform-aws/datas.tf +++ b/terraform-aws/datas.tf @@ -42,6 +42,7 @@ resource "aws_autoscaling_group" "data_nodes" { desired_capacity = var.datas_count[keys(var.datas_count)[count.index]] default_cooldown = 30 force_delete = true + protect_from_scale_in = var.protect_data_from_scale_in vpc_zone_identifier = local.cluster_subnet_ids[keys(var.datas_count)[count.index]] diff --git a/terraform-aws/variables.tf b/terraform-aws/variables.tf index 30b1327..cb45680 100644 --- a/terraform-aws/variables.tf +++ b/terraform-aws/variables.tf @@ -118,7 +118,7 @@ variable "client_user" { variable "public_facing" { description = "Whether or not the created cluster should be accessible from the public internet" type = bool - default = true + default = false } # the ability to add additional existing security groups. In our case @@ -211,4 +211,10 @@ variable "log_size" { variable "log_level" { description = "log4j log level" default = "WARN" -} \ No newline at end of file +} + +variable "protect_data_from_scale_in" { + description = "Protect data instances from scale in events" + type = bool + default = true +}