This repository has been archived on 2023-12-14. You can view files and clone it, but cannot push or open issues or pull requests.
k8s-training/k8s-infra.tf
2022-11-16 20:34:12 +01:00

92 lines
2.0 KiB
HCL

terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0.0"
}
}
}
provider "aws" {
region = "eu-west-1"
}
resource "aws_security_group" "k8s" {
description = "Access all the K8S boxes"
name = "k8s-sg"
ingress {
description = "Allow from all of the Internets"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
egress {
description = "Allow to contact the Internet"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
}
resource "aws_instance" "controlplane" {
ami = "ami-0ee415e1b8b71305f"
associate_public_ip_address = true
instance_type = "t3.large"
key_name = "overseer.ligthert.net"
tags = {
Name = "controlplane"
}
root_block_device {
volume_size = "128"
volume_type = "gp2"
}
user_data = "yum update -y"
vpc_security_group_ids = [aws_security_group.k8s.id]
}
output "controlplane_public_ip" {
value = aws_instance.controlplane.public_ip
}
output "controlplane_private_ip" {
value = aws_instance.controlplane.private_ip
}
output "controlplane_instance_id" {
value = aws_instance.controlplane.arn
}
resource "aws_instance" "node" {
ami = "ami-0ee415e1b8b71305f"
associate_public_ip_address = true
instance_type = "t3.large"
key_name = "overseer.ligthert.net"
tags = {
Name = "node"
}
root_block_device {
volume_size = "128"
volume_type = "gp2"
}
user_data = "yum update -y"
vpc_security_group_ids = [aws_security_group.k8s.id]
}
output "node_public_ip" {
value = aws_instance.node.public_ip
}
output "node_private_ip" {
value = aws_instance.node.private_ip
}
output "node_instance_id" {
value = aws_instance.node.arn
}