Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Variable Value / Owner #252

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2e1f21e
Change for Variables Instance types.
dnemtsanov Jan 16, 2025
0cbad4b
Error Handling in Terraform
dnemtsanov Jan 16, 2025
f4ec1de
Error Fixing from Blog to Web
dnemtsanov Jan 16, 2025
863f246
Retesting Instance renaming
dnemtsanov Jan 16, 2025
72363f9
Retesting Instance renaming
dnemtsanov Jan 16, 2025
2873f1b
Update outputs.tf
dnemtsanov Jan 16, 2025
fe4907e
Update outputs.tf
dnemtsanov Jan 16, 2025
618f83a
Create Security Group
dnemtsanov Jan 17, 2025
810bd06
Create VPC group fix
dnemtsanov Jan 17, 2025
2d3e532
Use module for security group
dnemtsanov Jan 19, 2025
5746ece
Removed old Security Groups
dnemtsanov Jan 19, 2025
f86e08b
Create new DEV VPC
dnemtsanov Jan 19, 2025
36300c3
Fixing VPC in AWS
dnemtsanov Jan 19, 2025
14b9ebf
Load Balancer AWS
dnemtsanov Jan 19, 2025
1df0f22
Load Balancer AWS 2
dnemtsanov Jan 19, 2025
735ab78
AutoScaling
dnemtsanov Jan 20, 2025
3df213d
AutoScaling 2
dnemtsanov Jan 20, 2025
c16245f
AutoScaling 3
dnemtsanov Jan 20, 2025
421f8aa
Removed ALB Target
dnemtsanov Jan 20, 2025
6a7e0ff
Fixing Target_ID
dnemtsanov Jan 20, 2025
634be56
Remove ALB Target 2
dnemtsanov Jan 20, 2025
c2a39ff
Removed Target_ID
dnemtsanov Jan 20, 2025
7c607b1
Added missing bracket to blog_alb module
dnemtsanov Jan 20, 2025
443d09f
Removed Listeners and Target Group
dnemtsanov Jan 20, 2025
2991de7
Revised Sqare Brackets in ALB
dnemtsanov Jan 20, 2025
67d19bd
Resolving Extra Bracket in ALB module
dnemtsanov Jan 20, 2025
62e91da
Added aws_instance to target_groups
dnemtsanov Jan 20, 2025
2f1a139
New Main.tf file
dnemtsanov Jan 20, 2025
80d103d
variables
dnemtsanov Jan 21, 2025
94f4742
Fix Variable Value / Owner
dnemtsanov Jan 30, 2025
4baa110
Refactor Variable
dnemtsanov Jan 30, 2025
4ef9ddc
Refacter Variables file
dnemtsanov Jan 30, 2025
b75100f
Refacter Var again
dnemtsanov Jan 30, 2025
8311ba8
Modularized
dnemtsanov Jan 31, 2025
127df4e
Define DEV environment
dnemtsanov Jan 31, 2025
1fdb34b
define qa env
dnemtsanov Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"githubPullRequests.ignoredPullRequestBranches": [
"main"
]
}
3 changes: 3 additions & 0 deletions dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module "dev" {
source = "../modules/blog"
}
File renamed without changes.
24 changes: 0 additions & 24 deletions main.tf

This file was deleted.

94 changes: 94 additions & 0 deletions modules/blog/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
data "aws_ami" "app_ami" {
most_recent = true

filter {
name = "name"
values = [var.ami_filter.name]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}

owners = [var.ami_filter.owner] # Bitnami
}


module "blog_vpc" {
source = "terraform-aws-modules/vpc/aws"

name = var.environment.name
cidr = "${var.environment.network_prefix}.0.0/16"

azs = ["us-west-2a","us-west-2b","us-west-2c"]
public_subnets = ["${var.environment.network_prefix}.101.0/24", "${var.environment.network_prefix}.102.0/24", "${var.environment.network_prefix}.103.0/24"]


tags = {
Terraform = "true"
Environment = var.environment.name
}
}


module "blog_autoscaling" {
source = "terraform-aws-modules/autoscaling/aws"
version = "6.5.2"

name = "blog"

min_size = var.asg_min
max_size = var.asg_max
vpc_zone_identifier = module.blog_vpc.public_subnets
target_group_arns = module.blog_alb.target_group_arns
security_groups = [module.blog_sg.security_group_id]
instance_type = var.instance_type
image_id = data.aws_ami.app_ami.id
}

module "blog_alb" {
source = "terraform-aws-modules/alb/aws"
version = "~> 6.0"

name = "${var.environment.name}-blog-alb"

load_balancer_type = "application"

vpc_id = module.blog_vpc.vpc_id
subnets = module.blog_vpc.public_subnets
security_groups = [module.blog_sg.security_group_id]

target_groups = [
{
name_prefix = "${var.environment.name}-"
backend_protocol = "HTTP"
backend_port = 80
target_type = "instance"
}
]

http_tcp_listeners = [
{
port = 80
protocol = "HTTP"
target_group_index = 0
}
]

tags = {
Environment = "${var.environment.name}"
}
}

module "blog_sg" {
source = "terraform-aws-modules/security-group/aws"
version = "4.13.0"

vpc_id = module.blog_vpc.vpc_id
name = "${var.environment.name}-blog"
ingress_rules = ["https-443-tcp","http-80-tcp"]
ingress_cidr_blocks = ["0.0.0.0/0"]
egress_rules = ["all-all"]
egress_cidr_blocks = ["0.0.0.0/0"]
}
3 changes: 3 additions & 0 deletions modules/blog/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "environment_url"{
value = module.blog_alb.lb_dns_name
}
41 changes: 41 additions & 0 deletions modules/blog/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
variable "instance_type" {
description = "Type of EC2 instance to provision"
default = "t3.nano"
}

variable "ami_filter" {
description = "Name filter and owner for AMI"

type = object ({
name = string
owner = string
})

default = {
name = "bitnami-tomcat-*-x86_64-hvm-ebs-nami"
owner = "979382823631" # Bitnami
}
}

variable "environment" {
description = "Deployment environment"

type = object ({
name = string
network_prefix = string
})
default = {
name = "dev"
network_prefix = "10.0"
}
}

variable "asg_min" {
description = "Minimum instance count for the ASG"
default = 1
}

variable "asg_max" {
description = "Maximum instance count for the ASG"
default = 2
}
7 changes: 0 additions & 7 deletions outputs.tf

This file was deleted.

11 changes: 11 additions & 0 deletions qa/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module "qa" {
source = "../modules/blog"

environment = {
name = "qa"
network_prefix = "10.1"
}

asg_min_size = 1
asg_max_size = 1
}
3 changes: 3 additions & 0 deletions qa/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "environment_url"{
value = module.qa.lb_dns_name
}
11 changes: 11 additions & 0 deletions qa/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}

provider "aws" {
region = "us-west-2"
}
4 changes: 0 additions & 4 deletions variables.tf

This file was deleted.