Move constant variables to their own modules.

new-vpc
Curtis Wilson 4 years ago
parent 0c87d694af
commit 9701408bec

@ -25,29 +25,29 @@ locals {
# ansible role that assigns roles based on wether or not 'master' is in the
# name.
"k8s-master" = {
base-image = var.ubuntu-ami
aws-ec2-type = var.t2-medium-4gib-2vcpu
base-image = module.aws-ami-constants.ubuntu-ami
aws-ec2-type = module.ec2-types.t2-medium-4gib-2vcpu
subnet-ids = local.k8s-subnets-ids
num = 1
},
"k8s-wrkr" = {
base-image = var.ubuntu-ami
aws-ec2-type = var.c5a-xlarge-amd-8gib-4vcpu
base-image = module.aws-ami-constants.ubuntu-ami
aws-ec2-type = module.ec2-types.c5a-xlarge-amd-8gib-4vcpu
subnet-ids = local.k8s-subnets-ids
disk-size = 32
num = 2
},
"dev" = {
base-image = var.ubuntu-ami
aws-ec2-type = var.c5a-xlarge-amd-8gib-4vcpu
base-image = module.aws-ami-constants.ubuntu-ami
aws-ec2-type = module.ec2-types.c5a-xlarge-amd-8gib-4vcpu
# subnet-ids = [module.aws-network-from-scratch.subnet.id]
subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_4"].id]
disk-size = 32
num = 1
},
"nfs" = {
base-image = var.ubuntu-ami
aws-ec2-type = var.t3a-medium-amd-4gib-2vcpu
base-image = module.aws-ami-constants.ubuntu-ami
aws-ec2-type = module.ec2-types.t3a-medium-amd-4gib-2vcpu
# subnet-ids = [module.aws-network-from-scratch.subnet.id]
subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_4"].id]
num = 1
@ -57,8 +57,8 @@ locals {
zfs-disk-size = 10
},
"proxy" = {
base-image = var.ubuntu-ami
aws-ec2-type = var.t2-micro-1gib-1vcpu
base-image = module.aws-ami-constants.ubuntu-ami
aws-ec2-type = module.ec2-types.t2-micro-1gib-1vcpu
# subnet-ids = [module.aws-network-from-scratch.subnet.id]
subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_4"].id]
private-ips = [var.aws-proxy-private-ip]
@ -93,6 +93,7 @@ locals {
},
]
# This is only needed for libvirt.
install-qemu-agent = false
}
@ -117,6 +118,16 @@ module "cloud-init-config" {
# libvirt modules/resources.
################################################################################
# This module sets the ec2-types constants.
module "ec2-types" {
source = "./modules/ec2-types"
}
# This module sets the AWS AMI constants.
module "aws-ami-constants" {
source = "./modules/aws-ami-constants"
}
# This module will grab the latest ami for a variety of distros. Uncomment to
# get a list of the latest AMIs for our supported distros.
# module "aws-amis" {
@ -218,8 +229,8 @@ module "nodes" {
# TODO an attempt to create a windows machine.
# module "nodes-win" {
# source = "./modules/aws-nodes"
# ec2-instance-type = var.t2-small-2gib-1vcpu
# ami = var.win-srv-2019-ami
# ec2-instance-type = module.ec2-types.t2-small-2gib-1vcpu
# ami = module.aws-ami-constants.win-srv-2019-ami
# subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_2"].id]
# private-ips = []
# security-group-ids = [local.aws-security-group-id]
@ -243,6 +254,10 @@ module "nodes" {
# uri = var.libvirt-connection-url
# }
#
# module "libvirt-images" {
# source = "./modules/libvirt-images"
# }
#
# module "nodes" {
# for_each = local.nodes-config
# source = "./modules/libvirt-nodes"

@ -0,0 +1,58 @@
################################################################################
# AWS AMI vars
# These outputs are really more like constants. Using outputs improves
# readability. The values are manually updated. Use the aws-amis module to get
# the latest for each distro. Keep in mind that AMIs are region specific this is
# why you may see values and other regions commented out.
################################################################################
output "amzn2-ami" {
# us-east-2
# default = "ami-0dd0ccab7e2801812"
# us-gov-west-1
value = "ami-02ab588324a95cf31"
description = "The AMI to use for Amazon Linux 2."
}
output "ubuntu-ami" {
# us-east-2
# value = "ami-06c7d6c0987eaa46c"
# us-gov-west-1
value = "ami-066189aeb91baa0ab"
description = "The AMI to use for Ubuntu."
}
output "centos7-ami" {
# us-east-2
value = "ami-00f8e2c955f7ffa9b"
description = "The AMI to use for CentOS 7."
}
output "centos8-ami" {
# us-east-2
value = "ami-057cacbfbbb471bb3"
description = "The AMI to use for CentOS 8."
}
output "arch-ami" {
# us-east-2
value = "ami-02653f06de985e3ba"
description = "The AMI to use for Arch Linux."
}
output "rhel7-ami" {
# us-east-2
# value = "ami-0a509b3c2a4d05b3f"
# us-gov-west-1
value = "ami-04ccdf5793086ea95"
description = "The AMI to use for RHEL 7."
}
output "rhel8-ami" {
# us-east-2
# value = "ami-0d871ca8a77af2948"
# us-gov-west-1
value = "ami-0b1f10cd1cd107dd2"
description = "The AMI to use for RHEL 8."
}
output "win-srv-2019-ami" {
# us-east-2
# value = ???
# us-gov-west-1
value = "ami-0f838c3c35ab60fc4"
description = "The AMI to use for Windows Server 2019."
}

@ -0,0 +1,45 @@
################################################################################
# AWS EC2 types.
# Thesee are only here to help readability. Using these outputs allows the user
# to be able to see the resources of each type without having to look them up.
################################################################################
output "t2-micro-1gib-1vcpu" {
description = "t2.micro EC2 instance with 1 GiB mem and 1 vCPU."
value = "t2.micro"
}
output "t2-small-2gib-1vcpu" {
description = "t2.small EC2 instance with 2 GiB mem and 1 vCPUs."
value = "t2.small"
}
output "t2-medium-4gib-2vcpu" {
description = "t2.medium EC2 instance with 4 GiB mem and 2 vCPUs."
value = "t2.medium"
}
output "t2-large-8gib-2vcpu" {
description = "t2.large EC2 instance with 8 GiB mem and 2 vCPUs."
value = "t2.large"
}
output "t2-xlarge-16gib-4vcpu" {
description = "t2.xlarge EC2 instance with 16 GiB mem and 4 vCPUs."
value = "t2.xlarge"
}
output "t3a-medium-amd-4gib-2vcpu" {
description = "t3a.medium EC2 instance on AMD with GiB mem and 2 vCPUs."
value = "t3a.medium"
}
output "t3a-large-amd-8gib-2vcpu" {
description = "t3a.large EC2 instance on AMD with 8 GiB mem and 2 vCPUs."
value = "t3a.large"
}
output "c5a-xlarge-amd-8gib-4vcpu" {
description = "c5a.xlarge EC2 instance on AMD with 8 GiB mem and 4 vCPUs."
value = "c5a.xlarge"
}

@ -0,0 +1,22 @@
################################################################################
# Libvirt Images
# These outputs are really more like constants. Using outputs improves
# readability. The values are manually updated.
################################################################################
output "ubuntu-img" {
value = "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img"
description = "The libvirt image to use for Ubuntu."
}
output "centos7-img" {
# Latest as of 2021-12-06.
value = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2111.qcow2"
description = "The libvirt image to use for CentOS 7."
}
output "centos8-img" {
value = "https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.4.2105-20210603.0.x86_64.qcow2"
description = "The libvirt image to use for CentOS 8."
}

@ -1,6 +1,6 @@
variable "admin-ips" {
default = ["0.0.0.0/0"]
description = "A list of ips or cidr blocks that are allowed to connect to the nodes."
description = "A list of ips or cidr blocks that are allowed to connect to the nodes. This variable is only used when using the aws-network-from-scratch module."
type = list(string)
}
@ -90,18 +90,6 @@ variable "root-admin-pub-key" {
description = "The public key to be added to authorized_keys for the root and admin accounts."
}
variable "master-nodes" {
default = 1
description = "The number of master nodes to create."
type = number
}
variable "worker-nodes" {
default = 2
description = "The number of worker nodes to create."
type = number
}
variable "base-image" {
default = "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img"
}
@ -110,129 +98,3 @@ variable "vm-name-prefix" {
default = "k8s-tf"
description = "This prefix will appear before all VM names and hostnames, ie. k8s-tf-master-0."
}
################################################################################
# AWS AMI vars
# These variables are really more like constants. Using variables improves
# readability. The defaults are manually updated. Use the aws-amis module to get
# the latest for each distro.
################################################################################
variable "amzn2-ami" {
# us-east-2
# default = "ami-0dd0ccab7e2801812"
# us-gov-west-1
default = "ami-02ab588324a95cf31"
description = "The AMI to use for Amazon Linux 2."
}
variable "ubuntu-ami" {
# us-east-2
# default = "ami-06c7d6c0987eaa46c"
# us-gov-west-1
default = "ami-066189aeb91baa0ab"
description = "The AMI to use for Ubuntu."
}
variable "centos7-ami" {
# us-east-2
default = "ami-00f8e2c955f7ffa9b"
description = "The AMI to use for CentOS 7."
}
variable "centos8-ami" {
# us-east-2
default = "ami-057cacbfbbb471bb3"
description = "The AMI to use for CentOS 8."
}
variable "arch-ami" {
# us-east-2
default = "ami-02653f06de985e3ba"
description = "The AMI to use for Arch Linux."
}
variable "rhel7-ami" {
# us-east-2
# default = "ami-0a509b3c2a4d05b3f"
# us-gov-west-1
default = "ami-04ccdf5793086ea95"
description = "The AMI to use for RHEL 7."
}
variable "rhel8-ami" {
# us-east-2
# default = "ami-0d871ca8a77af2948"
# us-gov-west-1
default = "ami-0b1f10cd1cd107dd2"
description = "The AMI to use for RHEL 8."
}
variable "win-srv-2019-ami" {
# us-east-2
# default = ???
# us-gov-west-1
default = "ami-0f838c3c35ab60fc4"
description = "The AMI to use for Windows Server 2019."
}
################################################################################
# AWS EC2 types.
# These variables are really more like constants. Using variables improves
# readability.
################################################################################
variable "t2-micro-1gib-1vcpu" {
description = "t2.micro EC2 instance with 1 GiB mem and 1 vCPU."
default = "t2.micro"
}
variable "t2-small-2gib-1vcpu" {
description = "t2.small EC2 instance with 2 GiB mem and 1 vCPUs."
default = "t2.small"
}
variable "t2-medium-4gib-2vcpu" {
description = "t2.medium EC2 instance with 4 GiB mem and 2 vCPUs."
default = "t2.medium"
}
variable "t2-large-8gib-2vcpu" {
description = "t2.large EC2 instance with 8 GiB mem and 2 vCPUs."
default = "t2.large"
}
variable "t2-xlarge-16gib-4vcpu" {
description = "t2.xlarge EC2 instance with 16 GiB mem and 4 vCPUs."
default = "t2.xlarge"
}
variable "t3a-medium-amd-4gib-2vcpu" {
description = "t3a.medium EC2 instance on AMD with GiB mem and 2 vCPUs."
default = "t3a.medium"
}
variable "t3a-large-amd-8gib-2vcpu" {
description = "t3a.large EC2 instance on AMD with 8 GiB mem and 2 vCPUs."
default = "t3a.large"
}
variable "c5a-xlarge-amd-8gib-4vcpu" {
description = "c5a.xlarge EC2 instance on AMD with 8 GiB mem and 4 vCPUs."
default = "c5a.xlarge"
}
################################################################################
# Libvirt Images
# These variables are really more like constants. Using variables improves
# readability. The defaults are manually updated.
################################################################################
variable "ubuntu-img" {
default = "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img"
description = "The libvirt image to use for Ubuntu."
}
variable "centos7-img" {
# Latest as of 2021-12-06.
default = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2111.qcow2"
description = "The libvirt image to use for CentOS 7."
}
variable "centos8-img" {
default = "https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.4.2105-20210603.0.x86_64.qcow2"
description = "The libvirt image to use for CentOS 8."
}

Loading…
Cancel
Save