Skip to content

Commit

Permalink
eks & var condition fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ujstor committed Jun 15, 2024
1 parent d19041c commit 371fe33
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 64 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ aws eks update-kubeconfig --region <REGION> --name <EKS_CLUSTER_NAME>
│ ├── [ 930] main.tf
│ ├── [ 259] outputs.tf
│ ├── [ 374] terraform.tf
│ ├── [ 0] terraform.tfstate
│ ├── [6.7K] terraform.tfstate.backup
│ └── [ 330] variables.tf
├── [4.0K] modules/
│ ├── [4.0K] examples/
Expand Down
4 changes: 4 additions & 0 deletions global/ghAction/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ terraform {
source = "hashicorp/aws"
version = "5.50.0"
}
tls = {
source = "hashicorp/tls"
version = "4.0.5"
}
}
}
2 changes: 1 addition & 1 deletion global/ghAction/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ variable "allowed_repos_branches" {
default = [
{
org = "ujstor"
repo = "aws-asg-tf"
repo = "aws-terrafrom"
branch = "master"
}
]
Expand Down
15 changes: 15 additions & 0 deletions modules/modules/cluster/asg-rolling-deploy/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,31 @@ variable "image_id" {
variable "instance_type" {
description = "The type of instance to start"
type = string

validation {
condition = contains(["t2.micro", "t3.micro"], var.instance_type)
error_message = "Only free tier instances are supported | t2.micro, t3.micro"
}
}

variable "min_size" {
description = "The minimum size of the Auto Scaling group"
type = number

validation {
condition = var.min_size > 0
error_message = "ASG can be empty or we'll have an outage!"
}
}

variable "max_size" {
description = "The maximum size of the Auto Scaling group"
type = number

validation {
condition = var.max_size <= 10
error_message = "ASG must have 10 or less instances to keep costs down"
}
}

variable "custom_tags" {
Expand Down
14 changes: 0 additions & 14 deletions modules/modules/eks-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ variable "min_size" {
description = "Minimum number of nodes to have in the EKS cluster"
type = number

validation {
condition = var.min_size > 0
error_message = "ASG can be empty or we'll have an outage!"
}

validation {
condition = var.max_size <= 10
error_message = "ASG must have 10 or less instances to keep costs down"
}
}

variable "max_size" {
Expand All @@ -31,9 +22,4 @@ variable "desired_size" {
variable "instance_types" {
description = "The types of EC2 instances to run in the node group"
type = list(string)

validation {
condition = contains(["t2.micro", "t3.micro"], var.instance_types)
error_message = "Only free tier instances are supported | t2.micro, t3.micro"
}
}
3 changes: 2 additions & 1 deletion prod/data-stores/mysql/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module "mysql_primary" {
source = "../../../modules/modules/data-stores/mysql/"
source = "github.com/ujstor/aws-terraform//modules/modules/data-stores/mysql?ref=v0.1.3"
# source = "../../../modules/modules/data-stores/mysql/"

providers = {
aws = aws.primary
Expand Down
34 changes: 17 additions & 17 deletions prod/services/eks-cluster/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions prod/services/eks-cluster/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module "eks_cluster" {
source = "../../../modules/modules/eks-cluster/"
source = "github.com/ujstor/aws-terraform//modules/modules/eks-cluster?ref=v0.1.3"
# source = "../../../modules/modules/eks-cluster/"
name = "example-eks-cluster"
min_size = 3
max_size = 6
Expand All @@ -9,7 +10,8 @@ module "eks_cluster" {
}

module "simple_webapp" {
source = "../../../modules/services/k8s"
source = "github.com/ujstor/aws-terraform//modules/modules/k8s?ref=v0.1.3"
# source = "../../../modules/modules/k8s"

name = "portfolio-webapp"
image = "ujstor/portfolio-web-go:1.2.0"
Expand Down
34 changes: 17 additions & 17 deletions prod/services/hello-world-app/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions prod/services/hello-world-app/main.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
module "webserver_cluster" {
source = "../../../modules/modules/services/hello-world-app"
source = "github.com/ujstor/aws-terraform//modules/modules/services/hello-world-app?ref=v0.1.3"
# source = "../../../modules/modules/services/hello-world-app"

environment = "prod"
image_id = data.aws_ami.ubuntu.id
db_remote_state_bucket = "tf-state-ujstor"
db_remote_state_key = "prod/data-stores/mysql/terraform.tfstate"

server_text = "New server text from prod"

instance_type = "t3.micro"
min_size = 2
max_size = 10
max_size = 11

custom_tags = {
Owner = "team-foo"
Expand Down
3 changes: 2 additions & 1 deletion stage/data-stores/mysql/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module "mysql_db_stage" {
source = "../../../modules/modules/data-stores/mysql"
source = "github.com/ujstor/aws-terraform//modules/modules/data-stores/mysql?ref=v0.1.3"
# source = "../../../modules/modules/data-stores/mysql"

providers = {
aws = aws.stage
Expand Down
8 changes: 4 additions & 4 deletions stage/services/hello-world-app/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module "hello-world-app" {
source = "github.com/ujstor/aws-terraform//modules/modules/services/hello-world-app?ref=v0.1.0"
source = "github.com/ujstor/aws-terraform//modules/modules/services/hello-world-app?ref=v0.1.3"
# source = "../../../modules/modules/services/hello-world-app/"

providers = {
aws = aws.stage
Expand All @@ -12,9 +13,8 @@ module "hello-world-app" {
db_remote_state_bucket = "tf-state-ujstor"
db_remote_state_key = "stage/data-stores/mysql/terraform.tfstate"

server_text = "New server text from stage"
min_size = 2
max_size = 5
min_size = 2
max_size = 5

custom_tags = {
Owner = "team-foo"
Expand Down
23 changes: 23 additions & 0 deletions stage/services/k8s/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion stage/services/k8s/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module "simple_webapp" {
source = "../../../modules/modules/k8s/"
source = "github.com/ujstor/aws-terraform//modules/modules/k8s?ref=v0.1.3"
# source = "../../../modules/modules/k8s/"

name = "portfolio-webapp"
image = "ujstor/portfolio-web-go:1.2.0"
Expand Down

0 comments on commit 371fe33

Please sign in to comment.