This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "aws" { | |
profile = "default" | |
region = "us-east-1" | |
} | |
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "~> 3.21" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_vpc" "main" { | |
# The CIDR block for the VPC | |
cidr_block = "192.168.0.0/16" | |
# Make your instances shared on the host | |
instance_tenancy = "default" | |
# Required for EKS. Enable/Disable DNS support in the VPC | |
enable_dns_support = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_subnet" "public_1" { | |
# The VPC ID to create in. | |
vpc_id = aws_vpc.main.id | |
# The CIDR block for the subnet. | |
cidr_block = "192.168.0.0/18" | |
# The AZ for the subnet. | |
availability_zone = "us-east-1a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_internet_gateway" "main" { | |
# The VPC ID to create in. | |
vpc_id = aws_vpc.main.id | |
# A map of tags to assign to the resource | |
tags = { | |
"Name" = "main" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_eip" "nat1" { | |
#EIP may require IGW to exist prior to association. | |
# Use depends_on to set an explicit dependency on the IGW. | |
depends_on = [ | |
aws_internet_gateway.main | |
] | |
} | |
resource "aws_eip" "nat2" { | |
#EIP may require IGW to exist prior to association. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_nat_gateway" "gw1" { | |
# The allocation ID of the Elastic IP address for the gateway | |
allocation_id = aws_eip.nat1.id | |
# The subnet ID of the subnet in which to place the gateway | |
subnet_id = aws_subnet.public_1.id | |
# A map of tags to assign to the resource | |
tags = { | |
"Name" = "NAT 1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_route_table" "public" { | |
# The VPC ID. | |
vpc_id = aws_vpc.main.id | |
route { | |
# The CIDR block of the route | |
cidr_block = "0.0.0.0/0" | |
# Identifier of the VPC internet gateway or a virtual private gateway | |
gateway_id = aws_internet_gateway.main.id | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_route_table_association" "public1" { | |
# The subnet ID to create an association | |
subnet_id = aws_subnet.public_1.id | |
# The ID of the routing table to associate with | |
route_table_id = aws_route_table.public.id | |
} | |
resource "aws_route_table_association" "public2" { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_iam_role" "eks_cluster" { | |
# The name of the role | |
name = "eks-cluster" | |
# The policy that grants an entity permission to assume the role. | |
# Used to access AWS resources that you might not normally have access to. | |
# The role that Amazon EKS will use to create AWS resources for Kubernetes clusters | |
assume_role_policy = <<POLICY | |
{ | |
"Version": "2012-10-17", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create IAM role for EKS Node Group | |
resource "aws_iam_role" "nodes_general" { | |
# The name of the role | |
name = "eks-node-group-general" | |
# The policy that grants an entity permission to assume the role. | |
assume_role_policy = <<POLICY | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ |
OlderNewer