From f81ad1c8872ae73051e93996ed7c682530f4a4d3 Mon Sep 17 00:00:00 2001 From: Mike Holloway Date: Mon, 6 Jan 2025 01:52:23 -0500 Subject: [PATCH] Working tofu plan --- main.tf | 26 ++++++++++++-------------- modules/instance/main.tf | 3 +-- modules/instance/variables.tf | 10 ++++++---- modules/vpc-subnet/main.tf | 33 +++++++++------------------------ modules/vpc-subnet/variables.tf | 24 ++++++++++++++++++++++++ 5 files changed, 52 insertions(+), 44 deletions(-) create mode 100644 modules/vpc-subnet/variables.tf diff --git a/main.tf b/main.tf index 57ababa..da2d3d1 100644 --- a/main.tf +++ b/main.tf @@ -1,31 +1,29 @@ terraform { required_providers { - linode = { - source = "linode/linode" - # version = "..." + linode = { + source = "linode/linode" + # version = "..." } } } # Configure the Linode Provider provider "linode" { - token = var.token + token = var.token } -module "vps1" { - source = "./modules/instance" - label = "vps1" - root_pass = var.root_pass +module "main_vpc_subnet" { + source = "./modules/vpc-subnet" } -module "vps2" { +module "ci_cd" { source = "./modules/instance" - label = "vps2" - root_pass = var.root_pass + label = "ci-cd" + root_pass = var.root_pass } -module "vps3" { +module "observability" { source = "./modules/instance" - label = "vps3" - root_pass = var.root_pass + label = "observability" + root_pass = var.root_pass } diff --git a/modules/instance/main.tf b/modules/instance/main.tf index cc7093d..8d4a71d 100644 --- a/modules/instance/main.tf +++ b/modules/instance/main.tf @@ -1,9 +1,8 @@ -# Create a Linode resource "linode_instance" "eqit_instance" { image = var.image label = var.label region = var.region type = var.type authorized_keys = var.authorized_keys - root_pass = var.root_pass + root_pass = var.root_pass } diff --git a/modules/instance/variables.tf b/modules/instance/variables.tf index 69f392d..ab27249 100644 --- a/modules/instance/variables.tf +++ b/modules/instance/variables.tf @@ -1,3 +1,9 @@ +## Required Variables +variable "root_pass" { + description = "Your Linode's root user's password." +} + +## Optional Variables variable "image" { description = "Image to use for Linode instance" default = "linode/almalinux9" @@ -18,10 +24,6 @@ variable "type" { default = "g6-standard-1" } -variable "root_pass" { - description = "Your Linode's root user's password." -} - variable "authorized_keys" { description = "SSH Keys to use for the Linode." type = list diff --git a/modules/vpc-subnet/main.tf b/modules/vpc-subnet/main.tf index af17577..e3534c5 100644 --- a/modules/vpc-subnet/main.tf +++ b/modules/vpc-subnet/main.tf @@ -1,27 +1,12 @@ -terraform { - required_providers { - linode = { - source = "linode/linode" - # version = "..." - } - } +# Create a Linode VPC +resource "linode_vpc" "eqit_vpc" { + label = var.vpc_label + region = var.region } -# Configure the Linode Provider -provider "linode" { - token = var.token +# Create a Linode VPC +resource "linode_vpc_subnet" "eqit_vpc_subnet" { + vpc_id = linode_vpc.eqit_vpc.id + label = var.vpc_subnet_label + ipv4 = "10.0.10.0/16" } - -data linode_instances "eqit_instances" { - filter { - name = "tags" - values = ["tofu-manage"] - } -} - -# Create a Linode -#resource "linode_instance" "observability" { -# label = "observability" -# -# -#} diff --git a/modules/vpc-subnet/variables.tf b/modules/vpc-subnet/variables.tf new file mode 100644 index 0000000..00fa9fe --- /dev/null +++ b/modules/vpc-subnet/variables.tf @@ -0,0 +1,24 @@ +## Required Variables +#variable "root_pass" { +# description = "Your Linode's root user's password." +#} + +## Optional Variables +variable "vpc_label" { + description = "The VPC's label is for display purposes only, but must be unique." + default = "EQIT" +} + +variable "vpc_subnet_label" { + description = "The subnet's label is for display purposes only, but must be unique." + default = "lan" +} +variable "region" { + description = "The region where your VPC will be located." + default = "us-ord" +} + +variable "description" { + description = "EQIT VPC Default Description." + default = "EQIT VPC Default Description." +}