diff --git a/terraform/linode/.terraform.lock.hcl b/terraform/linode/.terraform.lock.hcl new file mode 100644 index 0000000..c718117 --- /dev/null +++ b/terraform/linode/.terraform.lock.hcl @@ -0,0 +1,24 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/linode/linode" { + version = "1.26.1" + constraints = "1.26.1" + hashes = [ + "h1:VmElcG8265XBqKK/bqqY6FuknULiTt1qzmJzRhJHxEY=", + "zh:06e676a5934f37fc4639bb06ffe44444035041ab2518044b0f2d993d8d503dca", + "zh:0de1589e3d1bcc5ba50b3638275c87b49c8a68dbd750efc0f288adde649dd6d6", + "zh:54b648e049a53edefa0479fb28af5148d82bce9871a31e02571f93b2fae1bb85", + "zh:7e5c05530100908f1f9634dc997568934d9dde9e67049ad4598ea6e41dd1dde7", + "zh:88ea1d1f80d0dbc03ed74968f197d9b09edaabd57373b9606e9f3df6b10dcf98", + "zh:92fdfd496972cba77ed2c1ba60bd1f7ff5bbc6ea017a67ce702d817ea766bace", + "zh:a9f256b49fd2a34c822bba60d23d29a547d4f326488ef116c30aae5a085b5831", + "zh:cab86347062f374819a45539e61e286215fedc98471693474630924edc0d8296", + "zh:d0361b36eaa1f3aea8be03cae641d6ce4bc4b313abb718857aa3d125aae74349", + "zh:d049e8e7cb51e39119ff5e7a795d5444787149b6ac814421673260135b73820f", + "zh:d424fb536efd07fcfabae402a90392f05e98af2c4681c843ef702e2624d101bb", + "zh:de9661c4ef29f5cc38702b5cca092f087b4ad202775164c7d5ad41f618f8cbd8", + "zh:e3adc13f3d6d243eec42e2589b195910443966cdd0664b03cfb6dfdf15cc30bf", + "zh:ecd7eafeb35b226b03c03b7044b9a8914ffad4e6307a922e193eb7e0d4d52f9b", + ] +} diff --git a/terraform/linode/output.tf b/terraform/linode/output.tf new file mode 100644 index 0000000..a6258d3 --- /dev/null +++ b/terraform/linode/output.tf @@ -0,0 +1,7 @@ +output "ip" { + value = linode_instance.server.ip_address +} + +output "status" { + value = linode_instance.server.status +} diff --git a/terraform/linode/provider.tf b/terraform/linode/provider.tf new file mode 100644 index 0000000..6389f24 --- /dev/null +++ b/terraform/linode/provider.tf @@ -0,0 +1,13 @@ +terraform { + required_providers { + linode = { + source = "linode/linode" + version = "1.26.1" + } + } +} + +# Configure the Linode API token +provider "linode" { + token = var.linode_token +} diff --git a/terraform/linode/server.tf b/terraform/linode/server.tf new file mode 100644 index 0000000..25dc0a6 --- /dev/null +++ b/terraform/linode/server.tf @@ -0,0 +1,11 @@ +resource "linode_instance" "server" { + label = "${local.name}-${var.server_type}-${var.region}" + image = var.image + region = var.region + type = var.server_type + authorized_keys = var.authorized_keys + root_pass = var.root_pass + + group = "University" + tags = ["major_project", "university"] +} diff --git a/terraform/linode/vars.tf b/terraform/linode/vars.tf new file mode 100644 index 0000000..25b88b7 --- /dev/null +++ b/terraform/linode/vars.tf @@ -0,0 +1,43 @@ +# Token variable definition +variable "linode_token" {} + +# Root password variable defintion +variable "root_pass" {} + +# SSH Public key variable definition +variable "authorized_keys" { + type = list(string) +} + +# Name variable definition +variable "name" { + default = "ml" +} + +# Environment variable definition +variable "env" { + default = "dev" +} + +# Defining a variable source OS image for an instance +variable "image" { + default = "linode/debian11" +} + +# Definition of an instance type variable depending on the choice of tariff +variable "server_type" { + # default = "g1-gpu-rtx6000-1" + default = "g6-dedicated-32" +} + +# Definition of the region in which the instance will be created +variable "region" { + default = "eu-central" +} + +# LOCALS + +# Server name +locals { + name = "${var.name}-${var.env}" +}