Skip to content

Commit d051ccb

Browse files
committed
Re-added infrastructure directory with correct files
1 parent fd4f7a1 commit d051ccb

File tree

4 files changed

+240
-0
lines changed

4 files changed

+240
-0
lines changed

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# Crash log files
9+
crash.log
10+
crash.*.log
11+
12+
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
13+
# password, private keys, and other secrets. These should not be part of version
14+
# control as they are data points which are potentially sensitive and subject
15+
# to change depending on the environment.
16+
*.tfvars
17+
*.tfvars.json
18+
19+
# Ignore override files as they are usually used to override resources locally and so
20+
# are not checked in
21+
override.tf
22+
override.tf.json
23+
*_override.tf
24+
*_override.tf.json
25+
26+
# Ignore transient lock info files created by terraform apply
27+
.terraform.tfstate.lock.info
28+
29+
# Include override files you do wish to add to version control using negated pattern
30+
# !example_override.tf
31+
32+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
33+
# example: *tfplan*
34+
35+
# Ignore CLI configuration files
36+
.terraformrc
37+
terraform.rc

.terraform.lock.hcl

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.tf

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Create a VPC
2+
resource "aws_vpc" "main" {
3+
cidr_block = "10.0.0.0/16"
4+
enable_dns_hostnames = true
5+
}
6+
7+
# Create Subnet 1
8+
resource "aws_subnet" "subnet_1" {
9+
vpc_id = aws_vpc.main.id
10+
cidr_block = "10.0.0.0/20"
11+
availability_zone = "eu-west-2a"
12+
map_public_ip_on_launch = true
13+
}
14+
15+
# Create Subnet 2
16+
resource "aws_subnet" "subnet_2" {
17+
vpc_id = aws_vpc.main.id
18+
cidr_block = "10.0.16.0/20" # Updated CIDR to prevent overlap with Subnet 1
19+
availability_zone = "eu-west-2b"
20+
map_public_ip_on_launch = true
21+
}
22+
23+
# Create Subnet 3
24+
resource "aws_subnet" "subnet_3" {
25+
vpc_id = aws_vpc.main.id
26+
cidr_block = "10.0.32.0/20" # Updated CIDR to prevent overlap with Subnet 1
27+
availability_zone = "eu-west-2c"
28+
map_public_ip_on_launch = true
29+
}
30+
31+
# Create an Internet Gateway
32+
resource "aws_internet_gateway" "internet_gw" {
33+
vpc_id = aws_vpc.main.id
34+
}
35+
36+
# Create a Route Table
37+
resource "aws_route_table" "route_table" {
38+
vpc_id = aws_vpc.main.id
39+
40+
route {
41+
cidr_block = "0.0.0.0/0"
42+
gateway_id = aws_internet_gateway.internet_gw.id
43+
}
44+
45+
route {
46+
cidr_block = "10.0.0.0/16"
47+
gateway_id = "local"
48+
}
49+
}
50+
51+
resource "aws_route_table_association" "subnet_1_association" {
52+
subnet_id = aws_subnet.subnet_1.id
53+
route_table_id = aws_route_table.route_table.id
54+
}
55+
resource "aws_route_table_association" "subnet_2_association" {
56+
subnet_id = aws_subnet.subnet_2.id
57+
route_table_id = aws_route_table.route_table.id
58+
}
59+
resource "aws_route_table_association" "subnet_3_association" {
60+
subnet_id = aws_subnet.subnet_3.id
61+
route_table_id = aws_route_table.route_table.id
62+
}
63+
64+
module "eks" {
65+
source = "terraform-aws-modules/eks/aws"
66+
version = "~> 19.0"
67+
68+
cluster_name = "devops-capstone-project"
69+
cluster_version = "1.27"
70+
71+
cluster_endpoint_public_access = true
72+
73+
vpc_id = aws_vpc.main.id
74+
subnet_ids = [aws_subnet.subnet_1.id, aws_subnet.subnet_2.id, aws_subnet.subnet_3.id]
75+
control_plane_subnet_ids = [aws_subnet.subnet_1.id, aws_subnet.subnet_2.id, aws_subnet.subnet_3.id]
76+
77+
eks_managed_node_groups = {
78+
green = {
79+
min_size = 1
80+
max_size = 1
81+
desired_size = 1
82+
instance_types = ["t3.medium"]
83+
}
84+
}
85+
}

provider.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = "~> 5.0"
6+
}
7+
}
8+
}
9+
10+
# Configure the AWS Provider
11+
provider "aws" {
12+
region = "eu-west-2"
13+
}

0 commit comments

Comments
 (0)