16375: add code to test arvados in multi-node
[arvados-dev.git] / jenkins / test-arvados-multinode / terraform / main.tf
diff --git a/jenkins/test-arvados-multinode/terraform/main.tf b/jenkins/test-arvados-multinode/terraform/main.tf
new file mode 100644 (file)
index 0000000..e764929
--- /dev/null
@@ -0,0 +1,66 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+data "aws_ami" "debian" {
+  most_recent = true
+
+  filter {
+    name   = "name"
+    values = ["debian-11-amd64-*"]
+  }
+
+  filter {
+    name   = "architecture"
+    values = ["x86_64"]
+  }
+
+  # Debian's
+  owners = ["136693071363"]
+}
+
+resource "random_password" "cluster_name" {
+  length  = 5
+  upper   = false
+  special = false
+}
+
+module "ec2_cluster" {
+  source  = "terraform-aws-modules/ec2-instance/aws"
+  version = "~> 3.5"
+
+  count = var.instances_count
+
+  name = "${var.instance_name_prefix}-${count.index}"
+
+  ami                         = data.aws_ami.debian.id
+  instance_type               = "t3.medium"
+  associate_public_ip_address = true
+  ebs_optimized               = true
+
+  root_block_device = [{
+    encrypted             = true,
+    volume_size           = 50,
+    delete_on_termination = true,
+  }]
+
+  key_name   = var.user_key
+  monitoring = false
+  # These are tordo's SGs
+  vpc_security_group_ids = [
+    "sg-07a8d44b8d75ab8de",
+    "sg-0b36cbad0a62e6154",
+    "sg-0fdce93c95877be0b",
+    "sg-0e8fdd7632926eac6"
+  ]
+  subnet_id = "subnet-05b635657ce13d74e"
+
+  tags = {
+    Name        = "${var.instance_name_prefix}-${count.index}"
+    Terraform   = "true"
+    Environment = "dev"
+    Owner       = "jenkins"
+    Ticket      = var.jenkins_build_tag
+    Cluster     = random_password.cluster_name.result
+  }
+}