<commit_before>resource "aws_security_group" "default" {
    name = "weave"
    description = "SSH access from anywhere"

    ingress {
        from_port = 22
        to_port = 22
        protocol = "tcp"
        cidr_blocks = ["0.0.0.0/0"]
    }
}

resource "aws_instance" "weave" {
    count = 3
    instance_type = "${var.aws_instance_type}"

    ami = "${var.aws_coreos_ami}"

    key_name = "${var.aws_key_name}"

    user_data = "${file("cloud-config.yaml")}"

    security_groups = ["${aws_security_group.default.name}"]

    provisioner "file" {
        source = "genenv.sh"
        destination = "/tmp/genenv.sh"
        connection {
            user = "core"
            key_file = "${var.aws_key_path}"
        }
    }

    provisioner "file" {
        source = "units"
        destination = "/tmp/"
        connection {
            user = "core"
            key_file = "${var.aws_key_path}"
        }
    }

    provisioner "remote-exec" {
        inline = [
            "sudo mv /tmp/units/*.service /etc/systemd/system/",
            "sudo sh /tmp/genenv.sh aws ${count.index} '${var.weave_launch_password}' ${join(" ", google_compute_instance.weave.*.network.0.external_address)}",
            "sudo systemctl start weave",
        ]
        connection {
            user = "core"
            key_file = "${var.aws_key_path}"
        }
    }
}

resource "google_compute_instance" "weave" {
    count = 3
    machine_type = "${var.gce_machine_type}"
    zone = "${var.gce_zone}"

    name = "weave-gce-${count.index}"

    disk {
        image = "${var.gce_coreos_disk_image}"
    }

    network {
        source = "${google_compute_network.weave.name}"
    }

    metadata {
        user-data = "${file("cloud-config.yaml")}"
    }

    provisioner "file" {
        source = "genenv.sh"
        destination = "/tmp/genenv.sh"
        connection {
            user = "core"
            key_file = "${var.gce_key_path}"
        }
    }

    provisioner "file" {
        source = "units"
        destination = "/tmp/"
        connection {
            user = "core"
            key_file = "${var.gce_key_path}"
        }
    }

    provisioner "remote-exec" {
        inline = [
            "sudo mv /tmp/units/*.service /etc/systemd/system/",
            "sudo sh /tmp/genenv.sh gce ${count.index} '${var.weave_launch_password}'",
            "sudo systemctl start weave",
        ]
        connection {
            user = "core"
            key_file = "${var.gce_key_path}"
        }
    }
}

resource "google_compute_network" "weave" {
    name = "default"
    ipv4_range = "10.240.0.0/16"
}

resource "google_compute_firewall" "weave" {
    name = "ports"
    network = "${google_compute_network.weave.name}"

    allow {
        protocol = "icmp"
    }

    allow {
        protocol = "tcp"
        ports = ["22", "6783"]
    }

    allow {
        protocol = "udp"
        ports = ["22", "6783"]
    }

    source_ranges = ["0.0.0.0/0"]
}<commit_msg>Sort resources in logical order<commit_after>resource "google_compute_instance" "weave" {
    count = 3
    machine_type = "${var.gce_machine_type}"
    zone = "${var.gce_zone}"

    name = "weave-gce-${count.index}"

    disk {
        image = "${var.gce_coreos_disk_image}"
    }

    network {
        source = "${google_compute_network.weave.name}"
    }

    metadata {
        user-data = "${file("cloud-config.yaml")}"
    }

    provisioner "file" {
        source = "genenv.sh"
        destination = "/tmp/genenv.sh"
        connection {
            user = "core"
            key_file = "${var.gce_key_path}"
        }
    }

    provisioner "file" {
        source = "units"
        destination = "/tmp/"
        connection {
            user = "core"
            key_file = "${var.gce_key_path}"
        }
    }

    provisioner "remote-exec" {
        inline = [
            "sudo mv /tmp/units/*.service /etc/systemd/system/",
            "sudo sh /tmp/genenv.sh gce ${count.index} '${var.weave_launch_password}'",
            "sudo systemctl start weave",
        ]
        connection {
            user = "core"
            key_file = "${var.gce_key_path}"
        }
    }
}

resource "google_compute_network" "weave" {
    name = "default"
    ipv4_range = "10.240.0.0/16"
}

resource "google_compute_firewall" "weave" {
    name = "ports"
    network = "${google_compute_network.weave.name}"

    allow {
        protocol = "icmp"
    }

    allow {
        protocol = "tcp"
        ports = ["22", "6783"]
    }

    allow {
        protocol = "udp"
        ports = ["22", "6783"]
    }

    source_ranges = ["0.0.0.0/0"]
}

resource "aws_instance" "weave" {
    count = 3
    instance_type = "${var.aws_instance_type}"

    ami = "${var.aws_coreos_ami}"

    key_name = "${var.aws_key_name}"

    user_data = "${file("cloud-config.yaml")}"

    security_groups = ["${aws_security_group.default.name}"]

    provisioner "file" {
        source = "genenv.sh"
        destination = "/tmp/genenv.sh"
        connection {
            user = "core"
            key_file = "${var.aws_key_path}"
        }
    }

    provisioner "file" {
        source = "units"
        destination = "/tmp/"
        connection {
            user = "core"
            key_file = "${var.aws_key_path}"
        }
    }

    provisioner "remote-exec" {
        inline = [
            "sudo mv /tmp/units/*.service /etc/systemd/system/",
            "sudo sh /tmp/genenv.sh aws ${count.index} '${var.weave_launch_password}' ${join(" ", google_compute_instance.weave.*.network.0.external_address)}",
            "sudo systemctl start weave",
        ]
        connection {
            user = "core"
            key_file = "${var.aws_key_path}"
        }
    }
}

resource "aws_security_group" "default" {
    name = "weave"
    description = "SSH access from anywhere"

    ingress {
        from_port = 22
        to_port = 22
        protocol = "tcp"
        cidr_blocks = ["0.0.0.0/0"]
    }
}
{'fraction_non_alphanumeric': 0.14583333333333334, 'fraction_numerical': 0.01310483870967742, 'mean_word_length': 1.8014117647058823, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '103155', 'n_tokens_mistral': 2041, 'n_tokens_neox': 1965, 'n_words': 354}