From 87f7daed2b3d0c2c8f311f4133e689c28d6229d2 Mon Sep 17 00:00:00 2001 From: shockrah Date: Fri, 22 Apr 2022 22:31:28 -0700 Subject: [PATCH] * Moving all vars to an input-vars.tf module The idea with this is to centralize the variables so that they are easier to find and configure. The old way was scattered and lead to being unclear. There is also much more documentation added with this patch for clarity-sake --- infra/alpha.tf | 7 ---- infra/beta.tf | 6 ---- infra/input-vars.tf | 80 +++++++++++++++++++++++++++++++++++++++++++++ infra/provider.tf | 3 -- infra/subnet.tf | 3 -- infra/vpc.tf | 1 - 6 files changed, 80 insertions(+), 20 deletions(-) create mode 100644 infra/input-vars.tf diff --git a/infra/alpha.tf b/infra/alpha.tf index 71e5bc3..d2d02da 100644 --- a/infra/alpha.tf +++ b/infra/alpha.tf @@ -1,12 +1,5 @@ # Alpha is our primary server that we use for bots which basically # serve services that I personally run -variable "alpha_ssh_key_name" {} -variable "alpha_public_key_path" {} - - -variable "alpha_instance_type" {} - -variable "alpha_ami_id" {} resource "aws_key_pair" "alpha_ssh" { key_name = var.alpha_ssh_key_name diff --git a/infra/beta.tf b/infra/beta.tf index 04d4ee8..a8824e4 100644 --- a/infra/beta.tf +++ b/infra/beta.tf @@ -1,10 +1,4 @@ # This module defines the beta server instance which -variable "beta_ssh_key_name" {} -variable "beta_public_key_path" {} - -variable "beta_instance_type" {} - -variable "beta_ami_id" {} resource "aws_key_pair" "beta_ssh" { key_name = var.beta_public_key_path diff --git a/infra/input-vars.tf b/infra/input-vars.tf new file mode 100644 index 0000000..021cacf --- /dev/null +++ b/infra/input-vars.tf @@ -0,0 +1,80 @@ +# All variables that are used in various places go here + +######################### General provider specific values + +variable "aws_key" { + description = "Access Key for AWS operations" + type = string + sensitive = true +} + +variable "aws_secret" { + description = "Secret Key for AWS operations" + type = string + sensitive = true +} + +variable "aws_region" { + description = "Region where the VPC is located" + type = string + sensitive = true +} + +######################### Alpha variables + +variable "alpha_ssh_key_name" { + description = "Alpha ssh keyname" + type = string + sensitive = true +} +variable "alpha_public_key_path" { + description = "Alpha's path t key on local disk" + type = string + sensitive = true +} +variable "alpha_instance_type" { + description = "Alpha instance type(larger than beta due to docker requirement" + type = string + sensitive = true +} + +variable "alpha_ami_id" { + description = "AMI type for the docker host" + type = string +} + +######################### Beta variables +variable "beta_ssh_key_name" { + description = "SSH Key name for static web host" + type = string + sensitive = true +} +variable "beta_public_key_path" { + description = "Pub key path on disk" + type = string + sensitive = true +} +variable "beta_instance_type" { + description = "Host machine type" + type = string +} +variable "beta_ami_id" { + description = "AMI type for the static web host" + type = string +} + +######################### Subnet variables +variable "crete_cidr" { + description = "CIDR block for the servers themselves" + type = string +} +variable "athens_availability_zone" { + description = "Availability zone for Project Bucket" + type = string +} + +######################### VPC variables +variable "athens_cidr" { + description = "VPC Subnet CIDR block" + type = string +} diff --git a/infra/provider.tf b/infra/provider.tf index 302faae..ac07ecb 100644 --- a/infra/provider.tf +++ b/infra/provider.tf @@ -1,6 +1,3 @@ -variable "aws_key" {} -variable "aws_secret" {} -variable "aws_region" {} provider "aws" { access_key = var.aws_key diff --git a/infra/subnet.tf b/infra/subnet.tf index 6a57806..682a0d7 100644 --- a/infra/subnet.tf +++ b/infra/subnet.tf @@ -1,7 +1,4 @@ # This script represents the subnet structure for Crete(primary subnet) -variable "crete_cidr" {} -variable "athens_availability_zone" {} - # Crete will serve as the private subnet with internal services resource "aws_subnet" "crete_subnet" { diff --git a/infra/vpc.tf b/infra/vpc.tf index 710794a..2411f5e 100644 --- a/infra/vpc.tf +++ b/infra/vpc.tf @@ -1,4 +1,3 @@ -variable "athens_cidr" {} resource "aws_vpc" "athens_vpc" { cidr_block = var.athens_cidr