Skip to content

Instantly share code, notes, and snippets.

View samof76's full-sized avatar
🐒
Swinging branches

Samuel Vijaykumar M samof76

🐒
Swinging branches
View GitHub Profile
@samof76
samof76 / update_cluster_configuration_17.tf
Last active August 7, 2020 05:51
10_update_cluster_configuration_17.tf
resource "null_resource" "update_cluster_configuration_1" {
provisioner "local-exec" {
command = "./update.sh"
environment = { CLUSTER_NAME = module.eks_cluster.eks_cluster_name
REGION = var.region
ARN = var.arn_name
TFE_CIDR = var.tfe_cidr
ECR_URL = var.utils_image_ecr_url
KEYMAKER_VERSION = var.keymaker_version
GATEKEEPER_VERSION = var.gatekeeper_version
@samof76
samof76 / 09_cluster_data_setup.tf
Created August 7, 2020 05:45
09_cluster_data_setup.tf
resource "null_resource" "cluster_data_setup" {
provisioner "local-exec" {
command = "./setup.sh"
environment = {
CLUSTER_NAME = module.eks_cluster.eks_cluster_name
REGION = var.region
ARN = var.arn_name
GATEKEEPER_VERSION = var.gatekeeper_version
}
}
@samof76
samof76 / 08_private_link.tf
Created August 7, 2020 03:53
08_private_link.tf
@samof76
samof76 / 07_eks_nodes.tf
Created August 7, 2020 03:53
07_eks_nodes.tf
module "eks_cluster_node" {
source = "git.url/repo?ref=en2.6"
cluster_name = var.cluster_name
cluster_version = module.eks_cluster.eks_cluster_version
environment = module.eks_cluster.eks_cluster_environment
vpc_id = module.eks_cluster.eks_cluster_vpc_id
vpc_zone_identifier = module.subnets_from_list.eks_subnet_ids
instance_type = var.instance_type
eks_master_sg_id = module.eks_cluster.eks_master_sg
eks_master_endpoint = module.eks_cluster.eks_cluster_endpoint
@samof76
samof76 / 06_autoscaling.tf
Created August 7, 2020 03:53
06_autoscaling.tf
resource "aws_autoscaling_group" "eks_nodes_asg" {
count = length(var.vpc_zone_identifier)
desired_capacity = var.nodes_desired_capacity
launch_configuration = aws_launch_configuration.eks_nodes_lc.id
max_size = var.nodes_max_size
min_size = var.nodes_min_size
name = "${var.cluster_name}-node-asg-${count.index}"
vpc_zone_identifier = [var.vpc_zone_identifier[count.index]]
termination_policies = var.termination_policies
tags = module.node_label.tags_as_list_of_maps
@samof76
samof76 / 05_eks_cluster.tf
Created August 7, 2020 03:52
05_eks_cluster.tf
module "eks_cluster" {
source = "git.url/repo?ref=em2.14"
cluster_name = var.cluster_name
cluster_version = var.cluster_version
cluster_log_types = var.cluster_log_types
environment = var.stage
subnet_ids = module.subnets_from_list.eks_subnet_ids
vpc_id = var.vpc_id
master_associated_policies = var.master_associated_policies
allowed_sgs_master = var.allowed_sgs_master
@samof76
samof76 / 04_subnets_from_list.tf
Created August 7, 2020 03:52
04_subnets_from_list.tf
module "subnets_from_list" {
source = "git.url/repo?ref=esl2.0"
cluster_name = var.cluster_name
vpc_id = var.vpc_id
subnets_list = var.subnets_list
route_table = var.route_table
tags = local.tags
}
@samof76
samof76 / 03_setup.sh
Created August 7, 2020 03:51
03_setup.sh
#!/bin/bash
# REQUIREMENTS
# Run this from the directory it resides
# Edit the and populate the required values of the terraform.tfvars
TFPWD=$(pwd)
function print_log()
{
echo -e "$(date +'[%F %T %Z]') $*"
}
function run_terraform()
@samof76
samof76 / 02_cluster_autoscaler_local.tf
Created August 7, 2020 03:51
02_cluster_autoscaler_local
resource "local_file" "cluster_autoscaler" {
filename = "cluster_autoscaler.yml"
content = "${data.template_file.cluster_autoscaler.rendered}"
}
@samof76
samof76 / 01_cluster_autoscaler.tf
Created August 7, 2020 03:50
01_cluster_autoscaler.tf
data "template_file" "cluster_autoscaler" {
template = "${file("cluster_autoscaler.yml.tpl")}"
vars = {
worker_node_min_size = "${var.nodes_min_size}"
worker_node_max_size = "${var.nodes_max_size}"
worker_node_asg_name = "${aws_autoscaling_group.fd_eks_nodes_asg.name}"
aws_region = "${var.region}"
}
}