diff --git a/k8s_files/deployment.yaml b/k8s_files/deployment.yaml index e46316ac..5fb1cfd7 100644 --- a/k8s_files/deployment.yaml +++ b/k8s_files/deployment.yaml @@ -17,7 +17,7 @@ spec: spec: containers: - name: pandacloud-container - image: 309395755719.dkr.ecr.us-east-1.amazonaws.com/amazon-prime:latest + image: 476114139197.dkr.ecr.us-east-1.amazonaws.com/amazon-prime:latest ports: - containerPort: 3000 ... diff --git a/src/components/HomeTileData.js b/src/components/HomeTileData.js index a66da81b..a2ccb55c 100644 --- a/src/components/HomeTileData.js +++ b/src/components/HomeTileData.js @@ -1,7 +1,7 @@ const abc = [ { id: 0, - Title: "Avatar", + Title: "Avatarssssss", Year: "2009", rated: "PG-13", released: "18 Dec 2009", @@ -267,3 +267,4 @@ const abc = [ ]; export default abc; + diff --git a/src/components/Languages.js b/src/components/Languages.js index ab3be3e2..c3f3188c 100644 --- a/src/components/Languages.js +++ b/src/components/Languages.js @@ -8,7 +8,7 @@ const abc = [ { id: 6, name: "Marathi" }, { id: 7, name: "Punjabi" }, { id: 8, name: "Gujarati" }, - { id: 9, name: "Bengali" }, ]; export default abc; + diff --git a/terraform_code/ec2_server/daws-82s.pem b/terraform_code/ec2_server/daws-82s.pem new file mode 100644 index 00000000..904a4912 --- /dev/null +++ b/terraform_code/ec2_server/daws-82s.pem @@ -0,0 +1,7 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACDeYgM5pYsBsUtSW+qMpmwAj0WQbJOnUfeahDIHBdZMrgAAAKA6gF1tOoBd +bQAAAAtzc2gtZWQyNTUxOQAAACDeYgM5pYsBsUtSW+qMpmwAj0WQbJOnUfeahDIHBdZMrg +AAAED/+0YXnpzDUex5ZuzR9JoceYaJX9rqt6jbLZaeE/yOqd5iAzmliwGxS1Jb6oymbACP +RZBsk6dR95qEMgcF1kyuAAAAGkVBRCtza29kaXNoYWxhQFVTLVBGMlJWQ1pIAQID +-----END OPENSSH PRIVATE KEY----- diff --git a/terraform_code/ec2_server/main.tf b/terraform_code/ec2_server/main.tf index 014d54c2..472c713f 100644 --- a/terraform_code/ec2_server/main.tf +++ b/terraform_code/ec2_server/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "5.67.0" + version = "4.67.0" } } } @@ -153,7 +153,7 @@ resource "aws_instance" "my-ec2" { # ESTABLISHING SSH CONNECTION WITH EC2 connection { type = "ssh" - private_key = file("./key.pem") # replace with your key-name + private_key = file("./amazon.pem") # replace with your key-name user = "ubuntu" host = self.public_ip } diff --git a/terraform_code/ec2_server/terraform.tfvars b/terraform_code/ec2_server/terraform.tfvars index 0557fb93..219d7c80 100644 --- a/terraform_code/ec2_server/terraform.tfvars +++ b/terraform_code/ec2_server/terraform.tfvars @@ -1,9 +1,9 @@ # DEFINE ALL YOUR VARIABLES HERE -instance_type = "t2.medium" +instance_type = "t2.large" ami = "ami-0e86e20dae9224db8" # Ubuntu 24.04 -key_name = "key" # Replace with your key-name without .pem extension -volume_size = 30 +key_name = "amazon" # Replace with your key-name without .pem extension +volume_size = 25 region_name = "us-east-1" server_name = "JENKINS-SERVER" diff --git a/terraform_code/eks_code/eks.tf b/terraform_code/eks_code/eks.tf index f55fdb22..bfaa254a 100644 --- a/terraform_code/eks_code/eks.tf +++ b/terraform_code/eks_code/eks.tf @@ -1,20 +1,19 @@ module "eks" { source = "terraform-aws-modules/eks/aws" - version = "19.15.1" + version = "~> 20.0" - cluster_name = local.name - cluster_endpoint_public_access = true + cluster_name = local.name + cluster_version = "1.32" + create_node_security_group = false + create_cluster_security_group = false + cluster_addons = { - coredns = { - most_recent = true - } - kube-proxy = { - most_recent = true - } - vpc-cni = { - most_recent = true - } + coredns = {} + eks-pod-identity-agent = {} + kube-proxy = {} + vpc-cni = {} + metrics-server = {} } vpc_id = module.vpc.vpc_id diff --git a/terraform_code/eks_code/modules/eks/main.tf b/terraform_code/eks_code/modules/eks/main.tf new file mode 100644 index 00000000..a8ebebd0 --- /dev/null +++ b/terraform_code/eks_code/modules/eks/main.tf @@ -0,0 +1,81 @@ +resource "aws_iam_role" "cluster" { + name = "${var.cluster_name}-cluster-role" + + assume_role_policy = jsonencode({ + Version = "2012-10-17" + Statement = [{ + Action = "sts:AssumeRole" + Effect = "Allow" + Principal = { + Service = "eks.amazonaws.com" + } + }] + }) +} + +resource "aws_iam_role_policy_attachment" "cluster_policy" { + policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy" + role = aws_iam_role.cluster.name +} + +resource "aws_eks_cluster" "main" { + name = var.cluster_name + version = var.cluster_version + role_arn = aws_iam_role.cluster.arn + + vpc_config { + subnet_ids = var.subnet_ids + } + + depends_on = [ + aws_iam_role_policy_attachment.cluster_policy + ] +} + +resource "aws_iam_role" "node" { + name = "${var.cluster_name}-node-role" + + assume_role_policy = jsonencode({ + Version = "2012-10-17" + Statement = [{ + Action = "sts:AssumeRole" + Effect = "Allow" + Principal = { + Service = "ec2.amazonaws.com" + } + }] + }) +} + +resource "aws_iam_role_policy_attachment" "node_policy" { + for_each = toset([ + "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy", + "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy", + "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly" + ]) + + policy_arn = each.value + role = aws_iam_role.node.name +} + +resource "aws_eks_node_group" "main" { + for_each = var.node_groups + + cluster_name = aws_eks_cluster.main.name + node_group_name = each.key + node_role_arn = aws_iam_role.node.arn + subnet_ids = var.subnet_ids + + instance_types = each.value.instance_types + capacity_type = each.value.capacity_type + + scaling_config { + desired_size = each.value.scaling_config.desired_size + max_size = each.value.scaling_config.max_size + min_size = each.value.scaling_config.min_size + } + + depends_on = [ + aws_iam_role_policy_attachment.node_policy + ] +} diff --git a/terraform_code/eks_code/modules/eks/outputs.tf b/terraform_code/eks_code/modules/eks/outputs.tf new file mode 100644 index 00000000..dbf9d0e9 --- /dev/null +++ b/terraform_code/eks_code/modules/eks/outputs.tf @@ -0,0 +1,9 @@ +output "cluster_endpoint" { + description = "EKS cluster endpoint" + value = aws_eks_cluster.main.endpoint +} + +output "cluster_name" { + description = "EKS cluster name" + value = aws_eks_cluster.main.name +} diff --git a/terraform_code/eks_code/modules/eks/variables.tf b/terraform_code/eks_code/modules/eks/variables.tf new file mode 100644 index 00000000..cc7850da --- /dev/null +++ b/terraform_code/eks_code/modules/eks/variables.tf @@ -0,0 +1,32 @@ +variable "cluster_name" { + description = "Name of the EKS cluster" + type = string +} + +variable "cluster_version" { + description = "Kubernetes version" + type = string +} + +variable "vpc_id" { + description = "VPC ID" + type = string +} + +variable "subnet_ids" { + description = "Subnet IDs" + type = list(string) +} + +variable "node_groups" { + description = "EKS node group configuration" + type = map(object({ + instance_types = list(string) + capacity_type = string + scaling_config = object({ + desired_size = number + max_size = number + min_size = number + }) + })) +} diff --git a/terraform_code/eks_code/modules/main.tf b/terraform_code/eks_code/modules/main.tf new file mode 100644 index 00000000..793ffa4e --- /dev/null +++ b/terraform_code/eks_code/modules/main.tf @@ -0,0 +1,40 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.0" + } + } + + backend "s3" { + bucket = "terraform-eks-state-locks-sai123" + key = "terraform.tfstate" + region = "us-east-1" + dynamodb_table = "terraform-eks-state-locks-sai123" + encrypt = true + } +} + +provider "aws" { + region = var.region +} + +module "vpc" { + source = "./modules/vpc" + + vpc_cidr = var.vpc_cidr + availability_zones = var.availability_zones + private_subnet_cidrs = var.private_subnet_cidrs + public_subnet_cidrs = var.public_subnet_cidrs + cluster_name = var.cluster_name +} + +module "eks" { + source = "./modules/eks" + + cluster_name = var.cluster_name + cluster_version = var.cluster_version + vpc_id = module.vpc.vpc_id + subnet_ids = module.vpc.private_subnet_ids + node_groups = var.node_groups +} diff --git a/terraform_code/eks_code/modules/outputs.tf b/terraform_code/eks_code/modules/outputs.tf new file mode 100644 index 00000000..bc78d42d --- /dev/null +++ b/terraform_code/eks_code/modules/outputs.tf @@ -0,0 +1,14 @@ +output "cluster_endpoint" { + description = "EKS cluster endpoint" + value = module.eks.cluster_endpoint +} + +output "cluster_name" { + description = "EKS cluster name" + value = module.eks.cluster_name +} + +output "vpc_id" { + description = "VPC ID" + value = module.vpc.vpc_id +} diff --git a/terraform_code/eks_code/modules/variables.tf b/terraform_code/eks_code/modules/variables.tf new file mode 100644 index 00000000..8d8a56ee --- /dev/null +++ b/terraform_code/eks_code/modules/variables.tf @@ -0,0 +1,65 @@ +variable "region" { + description = "AWS region" + type = string + default = "us-east-1" +} + +variable "vpc_cidr" { + description = "CIDR block for VPC" + type = string + default = "10.0.0.0/16" +} + +variable "availability_zones" { + description = "Availability zones" + type = list(string) + default = ["us-east-1a", "us-east-1b", "us-east-1c"] +} + +variable "private_subnet_cidrs" { + description = "CIDR blocks for private subnets" + type = list(string) + default = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] +} + +variable "public_subnet_cidrs" { + description = "CIDR blocks for public subnets" + type = list(string) + default = ["10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24"] +} + +variable "cluster_name" { + description = "Name of the EKS cluster" + type = string + default = "my-eks-cluster" +} + +variable "cluster_version" { + description = "Kubernetes version" + type = string + default = "1.30" +} + +variable "node_groups" { + description = "EKS node group configuration" + type = map(object({ + instance_types = list(string) + capacity_type = string + scaling_config = object({ + desired_size = number + max_size = number + min_size = number + }) + })) + default = { + general = { + instance_types = ["t3.medium"] + capacity_type = "SPOT" + scaling_config = { + desired_size = 2 + max_size = 4 + min_size = 1 + } + } + } +} diff --git a/terraform_code/eks_code/modules/vpc/main.tf b/terraform_code/eks_code/modules/vpc/main.tf new file mode 100644 index 00000000..7e702620 --- /dev/null +++ b/terraform_code/eks_code/modules/vpc/main.tf @@ -0,0 +1,104 @@ +resource "aws_vpc" "main" { + cidr_block = var.vpc_cidr + enable_dns_hostnames = true + enable_dns_support = true + + tags = { + Name = "${var.cluster_name}-vpc" + "kubernetes.io/cluster/${var.cluster_name}" = "shared" + } +} + +resource "aws_subnet" "private" { + count = length(var.private_subnet_cidrs) + vpc_id = aws_vpc.main.id + cidr_block = var.private_subnet_cidrs[count.index] + availability_zone = var.availability_zones[count.index] + + tags = { + Name = "${var.cluster_name}-private-${count.index + 1}" + "kubernetes.io/cluster/${var.cluster_name}" = "shared" + "kubernetes.io/role/internal-elb" = "1" + } +} + +resource "aws_subnet" "public" { + count = length(var.public_subnet_cidrs) + vpc_id = aws_vpc.main.id + cidr_block = var.public_subnet_cidrs[count.index] + availability_zone = var.availability_zones[count.index] + + map_public_ip_on_launch = true + + tags = { + Name = "${var.cluster_name}-public-${count.index + 1}" + "kubernetes.io/cluster/${var.cluster_name}" = "shared" + "kubernetes.io/role/elb" = "1" + } +} + +resource "aws_internet_gateway" "main" { + vpc_id = aws_vpc.main.id + + tags = { + Name = "${var.cluster_name}-igw" + } +} + +resource "aws_eip" "nat" { + count = length(var.public_subnet_cidrs) + domain = "vpc" + + tags = { + Name = "${var.cluster_name}-nat-${count.index + 1}" + } +} + +resource "aws_nat_gateway" "main" { + count = length(var.public_subnet_cidrs) + allocation_id = aws_eip.nat[count.index].id + subnet_id = aws_subnet.public[count.index].id + + tags = { + Name = "${var.cluster_name}-nat-${count.index + 1}" + } +} + +resource "aws_route_table" "public" { + vpc_id = aws_vpc.main.id + + route { + cidr_block = "0.0.0.0/0" + gateway_id = aws_internet_gateway.main.id + } + + tags = { + Name = "${var.cluster_name}-public" + } +} + +resource "aws_route_table" "private" { + count = length(var.private_subnet_cidrs) + vpc_id = aws_vpc.main.id + + route { + cidr_block = "0.0.0.0/0" + nat_gateway_id = aws_nat_gateway.main[count.index].id + } + + tags = { + Name = "${var.cluster_name}-private-${count.index + 1}" + } +} + +resource "aws_route_table_association" "private" { + count = length(var.private_subnet_cidrs) + subnet_id = aws_subnet.private[count.index].id + route_table_id = aws_route_table.private[count.index].id +} + +resource "aws_route_table_association" "public" { + count = length(var.public_subnet_cidrs) + subnet_id = aws_subnet.public[count.index].id + route_table_id = aws_route_table.public.id +} diff --git a/terraform_code/eks_code/modules/vpc/outputs.tf b/terraform_code/eks_code/modules/vpc/outputs.tf new file mode 100644 index 00000000..300d57af --- /dev/null +++ b/terraform_code/eks_code/modules/vpc/outputs.tf @@ -0,0 +1,14 @@ +output "vpc_id" { + description = "VPC ID" + value = aws_vpc.main.id +} + +output "private_subnet_ids" { + description = "Private subnet IDs" + value = aws_subnet.private[*].id +} + +output "public_subnet_ids" { + description = "Public subnet IDs" + value = aws_subnet.public[*].id +} diff --git a/terraform_code/eks_code/modules/vpc/variables.tf b/terraform_code/eks_code/modules/vpc/variables.tf new file mode 100644 index 00000000..f5542326 --- /dev/null +++ b/terraform_code/eks_code/modules/vpc/variables.tf @@ -0,0 +1,24 @@ +variable "vpc_cidr" { + description = "CIDR block for VPC" + type = string +} + +variable "availability_zones" { + description = "Availability zones" + type = list(string) +} + +variable "private_subnet_cidrs" { + description = "CIDR blocks for private subnets" + type = list(string) +} + +variable "public_subnet_cidrs" { + description = "CIDR blocks for public subnets" + type = list(string) +} + +variable "cluster_name" { + description = "Name of the EKS cluster" + type = string +} diff --git a/terraform_code/eks_code/vpc.tf b/terraform_code/eks_code/vpc.tf index e3a0fe2e..c9c5ef3b 100644 --- a/terraform_code/eks_code/vpc.tf +++ b/terraform_code/eks_code/vpc.tf @@ -19,4 +19,4 @@ module "vpc" { private_subnet_tags = { "kubernetes.io/role/internal-elb" = 1 } -} \ No newline at end of file +}