diff --git a/infrastructure/.gitignore b/infrastructure/.gitignore new file mode 100644 index 00000000..21e6d3cb --- /dev/null +++ b/infrastructure/.gitignore @@ -0,0 +1,37 @@ +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log +crash.*.log + +# Exclude all .tfvars files, which are likely to contain sensitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +*.tfvars +*.tfvars.json + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Ignore transient lock info files created by terraform apply +.terraform.tfstate.lock.info + +# Include override files you do wish to add to version control using negated pattern +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Ignore CLI configuration files +.terraformrc +terraform.rc \ No newline at end of file diff --git a/infrastructure/main.tf b/infrastructure/main.tf index 7ed6a029..2b8c1ae7 100644 --- a/infrastructure/main.tf +++ b/infrastructure/main.tf @@ -1,60 +1,71 @@ -# Create a VPC resource "aws_vpc" "main" { - cidr_block = "10.0.0.0/16" - enable_dns_hostnames = true + cidr_block = "10.0.0.0/16" + enable_dns_hostnames = true + } -# create a subnet 1 resource "aws_subnet" "subnet_1" { - vpc_id = aws_vpc.main.id - cidr_block = "10.0.0.0/20" - availability_zone = "us-east-1b" - map_public_ip_on_launch = true -} + vpc_id = aws_vpc.main.id + cidr_block = "10.0.0.0/20" + availability_zone = "ap-south-1a" + map_public_ip_on_launch = true + } -# create a subnet 2 resource "aws_subnet" "subnet_2" { - vpc_id = aws_vpc.main.id - cidr_block = "10.0.16.0/20" - availability_zone = "us-east-1c" - map_public_ip_on_launch = true -} + vpc_id = aws_vpc.main.id + cidr_block = "10.0.16.0/20" + availability_zone = "ap-south-1b" + map_public_ip_on_launch = true + } -# create a subnet 3 resource "aws_subnet" "subnet_3" { - vpc_id = aws_vpc.main.id - cidr_block = "10.0.32.0/20" - availability_zone = "us-east-1d" - map_public_ip_on_launch = true -} - + vpc_id = aws_vpc.main.id + cidr_block = "10.0.32.0/20" + availability_zone = "ap-south-1c" + map_public_ip_on_launch = true + } resource "aws_internet_gateway" "internet_gw" { - vpc_id = aws_vpc.main.id + vpc_id = aws_vpc.main.id } resource "aws_route_table" "route_table" { - vpc_id = aws_vpc.main.id - + vpc_id = aws_vpc.main.id route { cidr_block = "0.0.0.0/0" gateway_id = aws_internet_gateway.internet_gw.id + } route { cidr_block = "10.0.0.0/16" gateway_id = "local" - } + } +} + + +resource "aws_route_table_association" "subnet_1_association" { + subnet_id = aws_subnet.subnet_1.id + route_table_id = aws_route_table.route_table.id +} + +resource "aws_route_table_association" "subnet_2_association" { + subnet_id = aws_subnet.subnet_2.id + route_table_id = aws_route_table.route_table.id +} + +resource "aws_route_table_association" "subnet_3_association" { + subnet_id = aws_subnet.subnet_3.id + route_table_id = aws_route_table.route_table.id } -# Use of EKS Module module "eks" { source = "terraform-aws-modules/eks/aws" version = "~> 19.0" - cluster_name = "devops-url2qr-capstone" + cluster_name = "devops-capstone-project" cluster_version = "1.27" cluster_endpoint_public_access = true @@ -66,9 +77,9 @@ module "eks" { eks_managed_node_groups = { green = { min_size = 1 - max_size = 1 + max_size = 2 desired_size = 1 instance_types = ["t3.medium"] } } -} +} \ No newline at end of file diff --git a/infrastructure/provider.tf b/infrastructure/provider.tf index 893b14f9..e435a56d 100644 --- a/infrastructure/provider.tf +++ b/infrastructure/provider.tf @@ -7,7 +7,9 @@ terraform { } } + + # Configure the AWS Provider provider "aws" { - region = "us-east-1" -} + region = "ap-south-1" +} \ No newline at end of file