<commit_before>data "aws_acm_certificate" "nginx" {
  domain = "*.${var.domain}"
  statuses = ["ISSUED"]
}

resource "aws_elb" "nginx" {
  name = "${var.name}"

  subnets = ["${var.subnet_ids}"]
  security_groups = [
    "${aws_security_group.nginx_elb.id}"
  ]

  connection_draining = true
  connection_draining_timeout = 300

  listener {
    lb_port = 443
    lb_protocol = "https"
    ssl_certificate_id = "${data.aws_acm_certificate.nginx.arn}"
    instance_port = 80
    instance_protocol = "http"
  }

  health_check {
    target = "HTTP:80/_status"
    timeout = 5
    interval = 30
    healthy_threshold = 3
    unhealthy_threshold = 5
  }

  cross_zone_load_balancing = true
}

resource "aws_security_group" "nginx_elb" {
  name = "${var.name}-elb"
  vpc_id = "${var.vpc_id}"

  # HTTPS access
  ingress {
    from_port = 443
    to_port = 443
    protocol = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  tags = {
    Name = "${var.name}-elb"
  }
}

resource "aws_security_group_rule" "allow_http_from_elb" {
  security_group_id = "${aws_security_group.nginx_elb.id}"
  type = "egress"
  from_port = 80
  to_port = 80
  protocol = "tcp"
  source_security_group_id = "${aws_security_group.nginx_instance.id}"
}
<commit_msg>Enable sticky sessions for nginx elb<commit_after>data "aws_acm_certificate" "nginx" {
  domain = "*.${var.domain}"
  statuses = ["ISSUED"]
}

resource "aws_elb" "nginx" {
  name = "${var.name}"

  subnets = ["${var.subnet_ids}"]
  security_groups = [
    "${aws_security_group.nginx_elb.id}"
  ]

  connection_draining = true
  connection_draining_timeout = 300

  listener {
    lb_port = 443
    lb_protocol = "https"
    ssl_certificate_id = "${data.aws_acm_certificate.nginx.arn}"
    instance_port = 80
    instance_protocol = "http"
  }

  health_check {
    target = "HTTP:80/_status"
    timeout = 5
    interval = 30
    healthy_threshold = 3
    unhealthy_threshold = 5
  }

  cross_zone_load_balancing = true
}

resource "aws_lb_cookie_stickiness_policy" "nginx_elb_sticky_sessions" {
  name = "${var.name}-elb-sticky-sessions"
  load_balancer = "${aws_elb.nginx.id}"
  lb_port = 443
}

resource "aws_security_group" "nginx_elb" {
  name = "${var.name}-elb"
  vpc_id = "${var.vpc_id}"

  # HTTPS access
  ingress {
    from_port = 443
    to_port = 443
    protocol = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  tags = {
    Name = "${var.name}-elb"
  }
}

resource "aws_security_group_rule" "allow_http_from_elb" {
  security_group_id = "${aws_security_group.nginx_elb.id}"
  type = "egress"
  from_port = 80
  to_port = 80
  protocol = "tcp"
  source_security_group_id = "${aws_security_group.nginx_instance.id}"
}

{'fraction_non_alphanumeric': 0.1348610067618332, 'fraction_numerical': 0.0236664162283997, 'mean_word_length': 3.490725126475548, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2951479', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1029, 'n_words': 174}