terraform/modules/hgweb-mirror/main.tf
author Connor Sheehan <sheehan@mozilla.com>
Fri, 10 May 2019 13:17:38 -0400
changeset 7011 13f70d71ae3a90e43f3e1c481f2c68609e5bf226
parent 7003 6cd9df449844177b49addfef5bd854f3f3c06914
permissions -rw-r--r--
terraform: do not create new ec2 resource when `user_data` changes Changes to user data shouldn't create a new resource. Any user data changes will be manually applied to the extra mirrors as needed.

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

resource "aws_instance" "hgweb-mirror" {
  ami = "${var.mirror_ami}"
  instance_type = "${var.instance_type}"
  subnet_id = "${var.subnet_id}"
  vpc_security_group_ids = ["${var.security_group_ids}"]
  ebs_optimized = true

  user_data = "${var.user_data}"

  root_block_device {
    delete_on_termination = true
    volume_size = 150
    volume_type = "standard"
  }

  lifecycle {
    ignore_changes = ["user_data"]
  }

  tags {
    Name = "hgweb instance"
  }
}

resource "aws_lb_target_group_attachment" "mirror-attachment" {
  target_group_arn = "${var.elb_target_group_arn}"
  target_id = "${aws_instance.hgweb-mirror.id}"
  port = 80
}