Skip to content

Commit d552516

Browse files
committed
Welcome to StackSimplify by Kalyan Reddy Daida
1 parent 266caac commit d552516

File tree

2,593 files changed

+87903
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,593 files changed

+87903
-17
lines changed

14-EBS-CSI-Install-Kubernetes-Storage/01-ekscluster-terraform-manifests/c1-versions.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Terraform Settings Block
22
terraform {
3-
required_version = ">= 1.0.0"
3+
required_version = ">= 1.6.0"
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
#version = "~> 3.70"
8-
version = ">= 4.65"
7+
#version = ">= 4.65"
8+
version = ">= 5.31"
99
}
1010
}
1111
# Adding Backend as S3 for Remote State Storage

14-EBS-CSI-Install-Kubernetes-Storage/01-ekscluster-terraform-manifests/c3-02-vpc-module.tf

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ data "aws_availability_zones" "available" {
55
# Create VPC Terraform Module
66
module "vpc" {
77
source = "terraform-aws-modules/vpc/aws"
8-
#version = "3.11.0"
9-
#version = "~> 3.11"
10-
version = "4.0.1"
11-
8+
#version = "4.0.1"
9+
version = "5.4.0"
10+
1211
# VPC Basic Details
1312
name = local.eks_cluster_name
1413
cidr = var.vpc_cidr_block

14-EBS-CSI-Install-Kubernetes-Storage/01-ekscluster-terraform-manifests/c4-03-ec2bastion-securitygroups.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# Security Group for Public Bastion Host
33
module "public_bastion_sg" {
44
source = "terraform-aws-modules/security-group/aws"
5-
#version = "4.5.0"
6-
version = "4.17.2"
5+
#version = "4.17.2"
6+
version = "5.1.0"
77

88
name = "${local.name}-public-bastion-sg"
99
description = "Security Group with SSH port open for everybody (IPv4 CIDR), egress ports are all world open"

14-EBS-CSI-Install-Kubernetes-Storage/01-ekscluster-terraform-manifests/c4-05-ec2bastion-instance.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# Bastion Host - EC2 Instance that will be created in VPC Public Subnet
33
module "ec2_public" {
44
source = "terraform-aws-modules/ec2-instance/aws"
5-
#version = "3.3.0"
6-
version = "5.0.0"
5+
#version = "5.0.0"
6+
version = "5.5.0"
7+
78
# insert the required variables here
89
name = "${local.name}-BastionHost"
910
ami = data.aws_ami.amzlinux2.id

14-EBS-CSI-Install-Kubernetes-Storage/01-ekscluster-terraform-manifests/c4-06-ec2bastion-elasticip.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
resource "aws_eip" "bastion_eip" {
44
depends_on = [ module.ec2_public, module.vpc ]
55
instance = module.ec2_public.id
6-
vpc = true
6+
#vpc = true
7+
domain = "vpc"
78
tags = local.common_tags
89
}
910

14-EBS-CSI-Install-Kubernetes-Storage/01-ekscluster-terraform-manifests/c6-02-iam-oidc-connect-provider.tf

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ output "aws_iam_openid_connect_provider_arn" {
2626
locals {
2727
aws_iam_oidc_connect_provider_extract_from_arn = element(split("oidc-provider/", "${aws_iam_openid_connect_provider.oidc_provider.arn}"), 1)
2828
}
29+
2930
# Output: AWS IAM Open ID Connect Provider
3031
output "aws_iam_openid_connect_provider_extract_from_arn" {
3132
description = "AWS IAM Open ID Connect Provider extract from ARN"

14-EBS-CSI-Install-Kubernetes-Storage/01-ekscluster-terraform-manifests/eks.auto.tfvars

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cluster_name = "eksdemo1"
22
cluster_service_ipv4_cidr = "172.20.0.0/16"
3-
cluster_version = "1.26"
3+
cluster_version = "1.28"
44
cluster_endpoint_private_access = false
55
cluster_endpoint_public_access = true
66
cluster_endpoint_public_access_cidrs = ["0.0.0.0/0"]

14-EBS-CSI-Install-Kubernetes-Storage/01-ekscluster-terraform-manifests/local-exec-output-files/creation-time-vpc-id.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ VPC created on Mon Jan 3 07:19:15 IST 2022 and VPC ID: vpc-0b1ccfc81d2c1115a
1818
VPC created on Tue Jan 4 17:21:40 IST 2022 and VPC ID: vpc-0a218019f176d4454
1919
VPC created on Tue Jan 4 18:45:05 IST 2022 and VPC ID: vpc-051d2dff249bb1da2
2020
VPC created on Wed Jan 5 09:01:42 IST 2022 and VPC ID: vpc-0c55acf7ed5d3eeee
21-
VPC created on Wed Jan 12 08:12:45 IST 2022 and VPC ID: vpc-01a400fc1bb12b228
21+
VPC created on Thu Jan 6 09:37:53 IST 2022 and VPC ID: vpc-0fe02ca9681849577
22+
VPC created on Sun Jan 9 14:39:06 IST 2022 and VPC ID: vpc-0f361e7e2252950c5
23+
VPC created on Mon Jan 10 09:07:06 IST 2022 and VPC ID: vpc-09a1b3d35a01948ef
24+
VPC created on Tue Jan 11 09:59:26 IST 2022 and VPC ID: vpc-0a226ca1703e61e04
25+
VPC created on Tue Dec 19 09:55:26 IST 2023 and VPC ID: vpc-044b87da63a19022a

14-EBS-CSI-Install-Kubernetes-Storage/02-ebs-terraform-manifests/c1-versions.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Terraform Settings Block
22
terraform {
3-
required_version = ">= 1.0.0"
3+
required_version = ">= 1.6.0"
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
#version = "~> 3.70"
8-
version = ">= 4.65"
7+
#version = ">= 4.65"
8+
version = ">= 5.31"
99
}
1010
helm = {
1111
source = "hashicorp/helm"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Terraform Settings Block
2+
terraform {
3+
required_version = ">= 1.0.0"
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
#version = "~> 3.70"
8+
version = ">= 4.65"
9+
}
10+
}
11+
# Adding Backend as S3 for Remote State Storage
12+
backend "s3" {
13+
bucket = "terraform-on-aws-eks"
14+
key = "dev/eks-cluster/terraform.tfstate"
15+
region = "us-east-1"
16+
17+
# For State Locking
18+
dynamodb_table = "dev-ekscluster"
19+
}
20+
}
21+
22+
# Terraform Provider Block
23+
provider "aws" {
24+
region = var.aws_region
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Input Variables
2+
# AWS Region
3+
variable "aws_region" {
4+
description = "Region in which AWS Resources to be created"
5+
type = string
6+
default = "us-east-1"
7+
}
8+
# Environment Variable
9+
variable "environment" {
10+
description = "Environment Variable used as a prefix"
11+
type = string
12+
default = "dev"
13+
}
14+
# Business Division
15+
variable "business_divsion" {
16+
description = "Business Division in the large organization this Infrastructure belongs"
17+
type = string
18+
default = "SAP"
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Define Local Values in Terraform
2+
locals {
3+
owners = var.business_divsion
4+
environment = var.environment
5+
name = "${var.business_divsion}-${var.environment}"
6+
#name = "${local.owners}-${local.environment}"
7+
common_tags = {
8+
owners = local.owners
9+
environment = local.environment
10+
}
11+
eks_cluster_name = "${local.name}-${var.cluster_name}"
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# VPC Input Variables
2+
3+
# VPC Name
4+
variable "vpc_name" {
5+
description = "VPC Name"
6+
type = string
7+
default = "myvpc"
8+
}
9+
10+
# VPC CIDR Block
11+
variable "vpc_cidr_block" {
12+
description = "VPC CIDR Block"
13+
type = string
14+
default = "10.0.0.0/16"
15+
}
16+
17+
# VPC Availability Zones
18+
/*
19+
variable "vpc_availability_zones" {
20+
description = "VPC Availability Zones"
21+
type = list(string)
22+
default = ["us-east-1a", "us-east-1b"]
23+
}
24+
*/
25+
26+
# VPC Public Subnets
27+
variable "vpc_public_subnets" {
28+
description = "VPC Public Subnets"
29+
type = list(string)
30+
default = ["10.0.101.0/24", "10.0.102.0/24"]
31+
}
32+
33+
# VPC Private Subnets
34+
variable "vpc_private_subnets" {
35+
description = "VPC Private Subnets"
36+
type = list(string)
37+
default = ["10.0.1.0/24", "10.0.2.0/24"]
38+
}
39+
40+
# VPC Database Subnets
41+
variable "vpc_database_subnets" {
42+
description = "VPC Database Subnets"
43+
type = list(string)
44+
default = ["10.0.151.0/24", "10.0.152.0/24"]
45+
}
46+
47+
# VPC Create Database Subnet Group (True / False)
48+
variable "vpc_create_database_subnet_group" {
49+
description = "VPC Create Database Subnet Group"
50+
type = bool
51+
default = true
52+
}
53+
54+
# VPC Create Database Subnet Route Table (True or False)
55+
variable "vpc_create_database_subnet_route_table" {
56+
description = "VPC Create Database Subnet Route Table"
57+
type = bool
58+
default = true
59+
}
60+
61+
62+
# VPC Enable NAT Gateway (True or False)
63+
variable "vpc_enable_nat_gateway" {
64+
description = "Enable NAT Gateways for Private Subnets Outbound Communication"
65+
type = bool
66+
default = true
67+
}
68+
69+
# VPC Single NAT Gateway (True or False)
70+
variable "vpc_single_nat_gateway" {
71+
description = "Enable only single NAT Gateway in one Availability Zone to save costs during our demos"
72+
type = bool
73+
default = true
74+
}
75+
76+
77+
78+
79+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# AWS Availability Zones Datasource
2+
data "aws_availability_zones" "available" {
3+
}
4+
5+
# Create VPC Terraform Module
6+
module "vpc" {
7+
source = "terraform-aws-modules/vpc/aws"
8+
#version = "3.11.0"
9+
#version = "~> 3.11"
10+
version = "4.0.1"
11+
12+
# VPC Basic Details
13+
name = local.eks_cluster_name
14+
cidr = var.vpc_cidr_block
15+
azs = data.aws_availability_zones.available.names
16+
public_subnets = var.vpc_public_subnets
17+
private_subnets = var.vpc_private_subnets
18+
19+
# Database Subnets
20+
database_subnets = var.vpc_database_subnets
21+
create_database_subnet_group = var.vpc_create_database_subnet_group
22+
create_database_subnet_route_table = var.vpc_create_database_subnet_route_table
23+
# create_database_internet_gateway_route = true
24+
# create_database_nat_gateway_route = true
25+
26+
# NAT Gateways - Outbound Communication
27+
enable_nat_gateway = var.vpc_enable_nat_gateway
28+
single_nat_gateway = var.vpc_single_nat_gateway
29+
30+
# VPC DNS Parameters
31+
enable_dns_hostnames = true
32+
enable_dns_support = true
33+
34+
35+
tags = local.common_tags
36+
vpc_tags = local.common_tags
37+
38+
# Additional Tags to Subnets
39+
public_subnet_tags = {
40+
Type = "Public Subnets"
41+
"kubernetes.io/role/elb" = 1
42+
"kubernetes.io/cluster/${local.eks_cluster_name}" = "shared"
43+
}
44+
private_subnet_tags = {
45+
Type = "private-subnets"
46+
"kubernetes.io/role/internal-elb" = 1
47+
"kubernetes.io/cluster/${local.eks_cluster_name}" = "shared"
48+
}
49+
50+
database_subnet_tags = {
51+
Type = "database-subnets"
52+
}
53+
# Instances launched into the Public subnet should be assigned a public IP address.
54+
map_public_ip_on_launch = true
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# VPC Output Values
2+
3+
# VPC ID
4+
output "vpc_id" {
5+
description = "The ID of the VPC"
6+
value = module.vpc.vpc_id
7+
}
8+
9+
# VPC CIDR blocks
10+
output "vpc_cidr_block" {
11+
description = "The CIDR block of the VPC"
12+
value = module.vpc.vpc_cidr_block
13+
}
14+
15+
# VPC Private Subnets
16+
output "private_subnets" {
17+
description = "List of IDs of private subnets"
18+
value = module.vpc.private_subnets
19+
}
20+
21+
# VPC Public Subnets
22+
output "public_subnets" {
23+
description = "List of IDs of public subnets"
24+
value = module.vpc.public_subnets
25+
}
26+
27+
# VPC NAT gateway Public IP
28+
output "nat_public_ips" {
29+
description = "List of public Elastic IPs created for AWS NAT Gateway"
30+
value = module.vpc.nat_public_ips
31+
}
32+
33+
# VPC AZs
34+
output "azs" {
35+
description = "A list of availability zones spefified as argument to this module"
36+
value = module.vpc.azs
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
3+
# AWS EC2 Instance Terraform Variables
4+
# EC2 Instance Variables
5+
6+
# AWS EC2 Instance Type
7+
variable "instance_type" {
8+
description = "EC2 Instance Type"
9+
type = string
10+
default = "t3.micro"
11+
}
12+
13+
# AWS EC2 Instance Key Pair
14+
variable "instance_keypair" {
15+
description = "AWS EC2 Key pair that need to be associated with EC2 Instance"
16+
type = string
17+
default = "eks-terraform-key"
18+
}
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# AWS EC2 Instance Terraform Outputs
2+
# Public EC2 Instances - Bastion Host
3+
4+
## ec2_bastion_public_instance_ids
5+
output "ec2_bastion_public_instance_ids" {
6+
description = "List of IDs of instances"
7+
value = module.ec2_public.id
8+
}
9+
10+
## ec2_bastion_public_ip
11+
output "ec2_bastion_public_ip" {
12+
description = "Elastic IP associated to the Bastion Host"
13+
value = aws_eip.bastion_eip.public_ip
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# AWS EC2 Security Group Terraform Module
2+
# Security Group for Public Bastion Host
3+
module "public_bastion_sg" {
4+
source = "terraform-aws-modules/security-group/aws"
5+
#version = "4.5.0"
6+
version = "4.17.2"
7+
8+
name = "${local.name}-public-bastion-sg"
9+
description = "Security Group with SSH port open for everybody (IPv4 CIDR), egress ports are all world open"
10+
vpc_id = module.vpc.vpc_id
11+
# Ingress Rules & CIDR Blocks
12+
ingress_rules = ["ssh-tcp"]
13+
ingress_cidr_blocks = ["0.0.0.0/0"]
14+
# Egress Rule - all-all open
15+
egress_rules = ["all-all"]
16+
tags = local.common_tags
17+
}

0 commit comments

Comments
 (0)