From 4791bf9b6dee32542858bb9d1a4c2531b6bab582 Mon Sep 17 00:00:00 2001 From: Curtis Wilson Date: Fri, 12 Nov 2021 21:58:22 -0500 Subject: [PATCH] Forgot to add aws-nodes files. - Moved network_config.cfg to libvirt-nodes. --- .gitignore | 8 +++++ modules/aws-nodes/main.tf | 14 ++++++++ modules/aws-nodes/outputs.tf | 3 ++ modules/aws-nodes/variables.tf | 36 +++++++++++++++++++ .../libvirt-nodes/network_config.cfg | 0 5 files changed, 61 insertions(+) create mode 100644 modules/aws-nodes/main.tf create mode 100644 modules/aws-nodes/outputs.tf create mode 100644 modules/aws-nodes/variables.tf rename network_config.cfg => modules/libvirt-nodes/network_config.cfg (100%) diff --git a/.gitignore b/.gitignore index 02fd6f3..b47f542 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,11 @@ override.tf.json # Ignore CLI configuration files .terraformrc terraform.rc + +################################################################################ +# end Pulled from github/gitignore 2021-11-10 commit 1a84870 +################################################################################ + +k8s-key* +STARTHERE + diff --git a/modules/aws-nodes/main.tf b/modules/aws-nodes/main.tf new file mode 100644 index 0000000..039fb20 --- /dev/null +++ b/modules/aws-nodes/main.tf @@ -0,0 +1,14 @@ +resource "aws_instance" "nodes" { + ami = var.ami + instance_type = var.ec2-instance-type + # key_name = aws_key_pair.debug1.key_name + associate_public_ip_address = true + subnet_id = var.subnet-id + vpc_security_group_ids = var.security-group-ids + user_data = element(var.user-datas.*.rendered, count.index) + count = var.num-nodes + + tags = { + Name = "${var.name-prefix}-${count.index}" + } +} diff --git a/modules/aws-nodes/outputs.tf b/modules/aws-nodes/outputs.tf new file mode 100644 index 0000000..d6faaf0 --- /dev/null +++ b/modules/aws-nodes/outputs.tf @@ -0,0 +1,3 @@ +output "ips" { + value = aws_instance.nodes.*.public_ip +} diff --git a/modules/aws-nodes/variables.tf b/modules/aws-nodes/variables.tf new file mode 100644 index 0000000..4968522 --- /dev/null +++ b/modules/aws-nodes/variables.tf @@ -0,0 +1,36 @@ +variable "ami" { + description = "The AWS AMI to be used for all the nodes" + type = string +} + +variable "ec2-instance-type" { + default = "t2.micro" + description = "The AWS instance type to use for all nodes." + type = string +} + +variable "name-prefix" { + default = "tf-node" + description = "This prefix will be applied to all names created by this module." + type = string +} + +variable "num-nodes" { + default = 1 + description = "The number of nodes to create from the given input parameters." + type = number +} + +variable "user-datas" { + description = "A list of cloud-init configs that get applied to their corresponding node." +} + +variable "subnet-id" { + description = "The ID of the subnet that all the nodes will be added to." + type = string +} + +variable "security-group-ids" { + description = "A list of security group IDs to be applied to all the nodes." + type = list(string) +} diff --git a/network_config.cfg b/modules/libvirt-nodes/network_config.cfg similarity index 100% rename from network_config.cfg rename to modules/libvirt-nodes/network_config.cfg