diff --git a/basic-infra/main.tf b/basic-infra/main.tf new file mode 100644 index 0000000..5e8ea00 --- /dev/null +++ b/basic-infra/main.tf @@ -0,0 +1,173 @@ +data "aws_availability_zones" "eu-west-3a" { + state = "available" + + filter { + name = "eu-west-3a" + } +} + +data "aws_availability_zones" "eu-west-3b" { + state = "available" + + filter { + name = "eu-west-3b" + } +} + +data "aws_availability_zones" "eu-west-3c" { + state = "available" + + filter { + name = "eu-west-3c" + } +} + +resource "aws_vpc" "main_vpc" { + cidr_block = "10.0.0.0/16" +} + +resource "aws_subnet" "frontend_subnet_az1" { + vpc_id = aws_vpc.main_vpc + cidr_block = "10.0.0.0/24" + availability_zone = "eu-west-3a" + + tags { + Name = "frontend_subnet_az1" + } +} + +resource "aws_subnet" "frontend_subnet_az2" { + vpc_id = aws_vpc.main_vpc + cidr_block = "10.0.1.0/24" + availability_zone = "eu-west-3b" + + tags { + Name = "frontend_subnet_az2" + } +} + +resource "aws_subnet" "frontend_subnet_az3" { + vpc_id = aws_vpc.main_vpc + cidr_block = "10.0.2.0/24" + availability_zone = "eu-west-3c" + + tags { + Name = "frontend_subnet_az3" + } +} + +data "aws_ami" "ubuntu" { + most_recent = true + + filter { + name = "name" + values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] + } + + filter { + name = "virtualization-type" + values = ["hvm"] + } + + owners = ["099720109477"] +} + +resource "aws_security_group" "frontend_secgroup_ssh" { + name = "frontend_secgroup_ssh" + description = "SSH Rules for the Front-End servers" + vpc_id = aws_vpc.main_vpc + + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + } +} + +resource "aws_security_group" "lb_secgroup_https" { + name = "lb_secgroup_https" + description = "HTTPS Rules for the LoadBalancer" + vpc_id = aws_vpc.main_vpc + + ingress { + from_port = 443 + to_port = 443 + protocol = "tcp" + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + } +} + +resource "aws_security_group" "lb_secgroup_http" { + name = "lb_secgroup_http" + description = "HTTP Rules for the LoadBalancer" + vpc_id = aws_vpc.main_vpc + + + ingress { + from_port = 80 + to_port = 80 + protocol = "tcp" + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + } +} + +resource "aws_lb" "frontend_lb" { + name = "frontend-lb" + load_balancer_type = "application" + security_groups = [ + aws_security_group.lb_secgroup_https.id, + aws_security_group.lb_secgroup_http.id + ] + + subnets = [ + aws_subnet.frontend_subnet_az1.id, + aws_subnet.frontend_subnet_az2.id, + aws_subnet.frontend_subnet_az3.id + ] +} + +resource "aws_lb_listener" "https_lb_listener" { + load_balancer_arn = [aws_lb.frontend_lb.id] + port = "443" + protocol = "HTTPS" + + default_action { + type = "forward" + target_group_arn = ["lb_target"] + } +} + +resource "aws_lb_listener" "http_lb_listener" { + load_balancer_arn = [aws_lb.frontend_lb.id] + port = "80" + protocol = "HTTP" + + default_action { + type = "forward" + target_group_arn = ["lb_target"] + } +} + +resource "aws_lb_target_group" "lb_target" { + name = "lbtarget" + target_type = "instance" + port = 8000 + protocol = "HTTP" + vpc_id = [aws_vpc.main_vpc.id] +} diff --git a/leto-modelizer.config.json b/leto-modelizer.config.json new file mode 100644 index 0000000..abb107a --- /dev/null +++ b/leto-modelizer.config.json @@ -0,0 +1,226 @@ +{ + "app-frontend": { + "kubernator-plugin": { + "dev-cm-js": { + "x": 170, + "y": 434, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "dev-cm-nginx": { + "x": 168, + "y": 294, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "cm-nginx": { + "x": 12, + "y": 12, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "cm-js": { + "x": 12, + "y": 142, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "frontend-dev-cn": { + "x": 12, + "y": 12, + "width": 152, + "height": 332, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "Pod_1": { + "x": 12, + "y": 12, + "width": 194, + "height": 454, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "frontend-dev-deployment": { + "x": 332, + "y": 12, + "width": 236, + "height": 576, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "dev-ingress": { + "x": 609.0000152587891, + "y": 386, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "dev-svc": { + "x": 618, + "y": 260, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + } + } + }, + "basic-infra": { + "terrator-plugin": { + "eu-west-3a": { + "x": 993, + "y": 126, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "eu-west-3b": { + "x": 994, + "y": 222, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "eu-west-3c": { + "x": 994, + "y": 318, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "main_vpc": { + "x": 490, + "y": 197, + "width": 476, + "height": 481, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": true + }, + "frontend_subnet_az1": { + "x": 323.99998474121094, + "y": 38, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "frontend_subnet_az2": { + "x": 162, + "y": 126, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "frontend_subnet_az3": { + "x": 30, + "y": 250, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "ubuntu": { + "x": 993, + "y": 32, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "frontend_secgroup_ssh": { + "x": 522, + "y": 809, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "lb_secgroup_https": { + "x": 378, + "y": 745, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "lb_secgroup_http": { + "x": 331, + "y": 8, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "frontend_lb": { + "x": 47, + "y": 307, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "https_lb_listener": { + "x": 190, + "y": 695, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "http_lb_listener": { + "x": 14, + "y": 730, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + }, + "lb_target": { + "x": 828, + "y": 797, + "width": 110, + "height": 80, + "needsResizing": false, + "needsPositioning": false, + "manuallyResized": false + } + } + } +} \ No newline at end of file