diff --git a/packer/elasticsearch7-node.packer.json b/packer/elasticsearch7-node.packer.json index 411c106..968083d 100644 --- a/packer/elasticsearch7-node.packer.json +++ b/packer/elasticsearch7-node.packer.json @@ -105,6 +105,17 @@ { "type": "shell", "script": "install-custom.sh" + }, + { + "type": "shell", + "environment_vars": [ "NR_LICENSE={{user `nr_license`}}" ], + "script": "install-newrelic.sh" + }, + { + "type": "shell", + "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-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..f9cf670 --- /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.accessid=$SUMO_ACCESS_ID -Vsumo.accesskey=$SUMO_ACCESS_KEY diff --git a/packer/variables.json b/packer/variables.json index 62e2d62..ec148dc 100644 --- a/packer/variables.json +++ b/packer/variables.json @@ -1,5 +1,8 @@ { "elasticsearch_version": "", + "nr_license": "", + "sumo_acccess_id": "", + "sumo_acccess_key": "", "aws_region": "us-east-1", "aws_az": "us-east-1d", 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/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..cb45680 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)) @@ -112,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 @@ -205,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 +}