<commit_before>#ws_launch_configuration Configure the AWS Provider
provider "aws" {
  region  = "${var.aws_region}"
}

data "atlas_artifact" "nubis-consul" {
  count = "${var.enabled}"

  name = "nubisproject/nubis-consul"
  type = "amazon.image"

  metadata {
    project_version = "${var.nubis_version}"
  }
}

resource "aws_launch_configuration" "consul" {
  count = "${var.enabled * length(split(",", var.environments))}"

  depends_on = [
    "null_resource.secrets",
    "null_resource.secrets-public",
  ]

  lifecycle {
    create_before_destroy = true
  }

  name_prefix = "${var.project}-${element(split(",",var.environments), count.index)}-${var.aws_region}-"
  image_id = "${data.atlas_artifact.nubis-consul.metadata_full["region-${var.aws_region}"]}"

  instance_type        = "t2.nano"
  key_name             = "${var.key_name}"
  iam_instance_profile = "${element(aws_iam_instance_profile.consul.*.name, count.index)}"

  security_groups = [
    "${element(aws_security_group.consul.*.id, count.index)}",
    "${element(split(",",var.internet_access_security_groups), count.index)}",
    "${element(split(",",var.shared_services_security_groups), count.index)}",
  ]

  user_data = <<EOF
NUBIS_PROJECT=${var.project}
NUBIS_ENVIRONMENT=${element(split(",",var.environments), count.index)}
NUBIS_ACCOUNT=${var.service_name}
NUBIS_DOMAIN=${var.domain}
CONSUL_ACL_DEFAULT_POLICY=${var.acl_default_policy}
CONSUL_ACL_DOWN_POLICY=${var.acl_down_policy}
CONSUL_BOOTSTRAP_EXPECT=${var.servers}
NUBIS_BUMP=${md5("${var.datadog_api_key}${element(data.template_file.mig.*.rendered,count.index)}")}
NUBIS_SUDO_GROUPS="${var.nubis_sudo_groups}"
NUBIS_USER_GROUPS="${var.nubis_user_groups}"
EOF
}

resource "aws_autoscaling_group" "consul" {
  count = "${var.enabled * length(split(",", var.environments))}"

  lifecycle {
    create_before_destroy = true
  }

  #XXX: Fugly, assumes 3 subnets per environments, bad assumption, but valid ATM<commit_msg>Disable EC2 detailled monitoring<commit_after>#ws_launch_configuration Configure the AWS Provider
provider "aws" {
  region  = "${var.aws_region}"
}

data "atlas_artifact" "nubis-consul" {
  count = "${var.enabled}"

  name = "nubisproject/nubis-consul"
  type = "amazon.image"

  metadata {
    project_version = "${var.nubis_version}"
  }
}

resource "aws_launch_configuration" "consul" {
  count = "${var.enabled * length(split(",", var.environments))}"

  depends_on = [
    "null_resource.secrets",
    "null_resource.secrets-public",
  ]

  lifecycle {
    create_before_destroy = true
  }

  name_prefix = "${var.project}-${element(split(",",var.environments), count.index)}-${var.aws_region}-"
  image_id = "${data.atlas_artifact.nubis-consul.metadata_full["region-${var.aws_region}"]}"

  instance_type        = "t2.nano"
  key_name             = "${var.key_name}"
  iam_instance_profile = "${element(aws_iam_instance_profile.consul.*.name, count.index)}"
  enable_monitoring    = false

  security_groups = [
    "${element(aws_security_group.consul.*.id, count.index)}",
    "${element(split(",",var.internet_access_security_groups), count.index)}",
    "${element(split(",",var.shared_services_security_groups), count.index)}",
  ]

  user_data = <<EOF
NUBIS_PROJECT=${var.project}
NUBIS_ENVIRONMENT=${element(split(",",var.environments), count.index)}
NUBIS_ACCOUNT=${var.service_name}
NUBIS_DOMAIN=${var.domain}
CONSUL_ACL_DEFAULT_POLICY=${var.acl_default_policy}
CONSUL_ACL_DOWN_POLICY=${var.acl_down_policy}
CONSUL_BOOTSTRAP_EXPECT=${var.servers}
NUBIS_BUMP=${md5("${var.datadog_api_key}${element(data.template_file.mig.*.rendered,count.index)}")}
NUBIS_SUDO_GROUPS="${var.nubis_sudo_groups}"
NUBIS_USER_GROUPS="${var.nubis_user_groups}"
EOF
}

resource "aws_autoscaling_group" "consul" {
  count = "${var.enabled * length(split(",", var.environments))}"

  lifecycle {
    create_before_destroy = true
  }

  #XXX: Fugly, assumes 3 subnets per environments, bad assumption, but valid ATM
{'fraction_non_alphanumeric': 0.16397170288024254, 'fraction_numerical': 0.0017685699848408287, 'mean_word_length': 5.64261744966443, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4201773', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1447, 'n_words': 182}