Jump to content

Recommended Posts

Posted

someone help me with good reference terraform code to build a eks cluster with mongodb and s3 and route 53…

i have existing code which creates only eks cluster…need to extend this…

btw this is personal work…not office related…so i can share the existing code…

Posted

existing..

// CLUSTER.tf

module "eks" {
  source          = "terraform-aws-modules/eks/aws"
  version         = "19.5.1"
  cluster_name    = local.cluster_name
  cluster_version = "1.24"
  subnets         = module.vpc.private_subnets

  vpc_id = module.vpc.vpc_id

  workers_group_defaults = {
    root_volume_type = "gp2"
  }

  worker_groups = [
    {
      name                          = "worker-group-1"
      instance_type                 = "t2.small"
      additional_userdata           = "echo foo bar"
      additional_security_group_ids = [aws_security_group.worker_group_mgmt_one.id]
      asg_desired_capacity          = 2
    },
    {
      name                          = "worker-group-2"
      instance_type                 = "t2.medium"
      additional_userdata           = "echo foo bar"
      additional_security_group_ids = [aws_security_group.worker_group_mgmt_two.id]
      asg_desired_capacity          = 1
    },
  ]
}

data "aws_eks_cluster" "cluster" {
  name = module.eks.cluster_id
}

data "aws_eks_cluster_auth" "cluster" {
  name = module.eks.cluster_id
}
// SECURITY_GROUPS.TF

resource "aws_security_group" "worker_group_mgmt_one" {
  name_prefix = "worker_group_mgmt_one"
  vpc_id      = module.vpc.vpc_id

  ingress {
    from_port = 22
    to_port   = 22
    protocol  = "tcp"

    cidr_blocks = [
      "10.0.0.0/8",
    ]
  }
}

resource "aws_security_group" "worker_group_mgmt_two" {
  name_prefix = "worker_group_mgmt_two"
  vpc_id      = module.vpc.vpc_id

  ingress {
    from_port = 22
    to_port   = 22
    protocol  = "tcp"

    cidr_blocks = [
      "192.168.0.0/16",
    ]
  }
}

resource "aws_security_group" "all_worker_mgmt" {
  name_prefix = "all_worker_management"
  vpc_id      = module.vpc.vpc_id

  ingress {
    from_port = 22
    to_port   = 22
    protocol  = "tcp"

    cidr_blocks = [
      "10.0.0.0/8",
      "172.16.0.0/12",
      "192.168.0.0/16",
    ]
  }
}
// VPC.TF
variable "region" {
  default     = "us-east-1"
  description = "AWS region"
}

provider "aws" {
  region = var.region
}

data "aws_availability_zones" "available" {}

locals {
  cluster_name = "education-eks-${random_string.suffix.result}"
}

resource "random_string" "suffix" {
  length  = 8
  special = false
}

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "3.2.0"

  name                 = "education-vpc"
  cidr                 = "10.0.0.0/16"
  azs                  = data.aws_availability_zones.available.names
  private_subnets      = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  public_subnets       = ["10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24"]
  enable_nat_gateway   = true
  single_nat_gateway   = true
  enable_dns_hostnames = true

  tags = {
    "kubernetes.io/cluster/${local.cluster_name}" = "shared"
  }

  public_subnet_tags = {
    "kubernetes.io/cluster/${local.cluster_name}" = "shared"
    "kubernetes.io/role/elb"                      = "1"
  }

  private_subnet_tags = {
    "kubernetes.io/cluster/${local.cluster_name}" = "shared"
    "kubernetes.io/role/internal-elb"             = "1"
  }
}

 

Posted
3 minutes ago, dasari4kntr said:

someone help me with good reference terraform code to build a eks cluster with mongodb and s3 and route 53…

i have existing code which creates only eks cluster…need to extend this…

btw this is personal work…not office related…so i can share the existing code…

Cdk vaadi cft generate cheseyi anna unless you want it be little cloud provider neutral for ur prototype,  cdk is super easy 

 

Posted
1 minute ago, csrcsr said:

Cdk vaadi cft generate cheseyi anna unless you want it be little cloud provider neutral for ur prototype,  cdk is super easy 

 

idi eppudu try cheyyala...will look look into it...

https://aws.amazon.com/cdk/

 

here is the requirement...right now..my blog is in godaddy wordpress hosting...

planning to move it aws...with my custom website (i am coding that seperately...its not difficult...)

but infra setup..lo konchem workout cheyyali...

Posted

i can try on Monday 

busy over the weekend if thats ok

  • Like 1
  • Thanks 1
Posted
Just now, dasari4kntr said:

idi eppudu try cheyyala...will look look into it...

https://aws.amazon.com/cdk/

 

here is the requirement...right now..my blog is in godaddy wordpress hosting...

planning to move it aws...with my custom website (i am coding that seperately...its not difficult...)

but infra setup..lo konchem workout cheyyali...

Then aws specific airhe cft cloud formation template best , use cdk to generate cft easy , immediate ga move cheyali ante u don't need iaac , u can have ec2 with any container and get it up kada bro u don't eks, ecs  cluster for your blog ,ec2 not sure in Mongo db stuff

Posted
3 minutes ago, Spartan said:

i can try on Monday 

busy over the weekend if thats ok

sure..thank you..

Posted
1 minute ago, csrcsr said:

Then aws specific airhe cft cloud formation template best , use cdk to generate cft easy , immediate ga move cheyali ante u don't need iaac , u can have ec2 with any container and get it up kada bro u don't eks, ecs  cluster for your blog ,ec2 not sure in Mongo db stuff

yup...we can do ec2 also...if i stick to wordpress..there are plenty of options are there too...

but planning for learning something new as well as website....

Posted (edited)
4 minutes ago, dasari4kntr said:

yup...we can do ec2 also...if i stick to wordpress..there are plenty of options are there too...

but planning for learning something new as well as website....

Cool we use ecs with fargate,  k8 mida cheyale epudu for u one task will be enough I guess , bill mida kuda kannu esi unchu anno oka sari paid 250 for no reason 

Edited by csrcsr
Posted
Just now, csrcsr said:

Cool we use ecs with fargate,  k8 mida cheyale epudu for u one task will be enough I guess , bill mida kuda kannu esi unchu anno oka sari paid 250

sure...

godaddy vaadu..charging...almost 250 per year (hosting and SSL)...and its managed...they dont give server access except admin portal...if you want to customize...

Posted
8 hours ago, dasari4kntr said:

someone help me with good reference terraform code to build a eks cluster with mongodb and s3 and route 53…

i have existing code which creates only eks cluster…need to extend this…

btw this is personal work…not office related…so i can share the existing code…

Create a diff module for each one, and have a common tf file for all.. 

  • Upvote 1
Posted
1 hour ago, maverick19 said:

google search cheste terraform modules for eks dorukutayi unless you are doing this to learn terraform itself. 

 

https://github.com/terraform-aws-modules/terraform-aws-eks

eks cluster i did already…i have implemented this module…i posted code above…

but i am looking for ..configuring the cluster with s3 access , mongodb access and route 53 configuration …

 

Posted
4 hours ago, LadiesTailor said:

Create a diff module for each one, and have a common tf file for all.. 

for each onne means different terraform project and different plan and apply in terrform cloud…?

Posted
2 hours ago, dasari4kntr said:

eks cluster i did already…i have implemented this module…i posted code above…

but i am looking for ..configuring the cluster with s3 access , mongodb access and route 53 configuration …

 

go back one step and search there are modules for others to be. frankly eks requires more coding than s3 and route53. 

 

https://github.com/terraform-aws-modules/terraform-aws-route53

https://github.com/terraform-aws-modules/terraform-aws-s3-bucket

  • Thanks 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...