92 lines
2.1 KiB
HCL
92 lines
2.1 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-0fd8802f94ed1c969"
|
|
associate_public_ip_address = true
|
|
instance_type = "t3.large"
|
|
key_name = "overseer.ligthert.net"
|
|
tags = {
|
|
Name = "controlplane"
|
|
}
|
|
root_block_device {
|
|
volume_size = "64"
|
|
volume_type = "gp2"
|
|
}
|
|
#user_data = "sudo apt-get update -y; sudo apt-get upgrade -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-0fd8802f94ed1c969"
|
|
associate_public_ip_address = true
|
|
instance_type = "t3.large"
|
|
key_name = "overseer.ligthert.net"
|
|
tags = {
|
|
Name = "node"
|
|
}
|
|
root_block_device {
|
|
volume_size = "64"
|
|
volume_type = "gp2"
|
|
}
|
|
#user_data = "sudo apt-get update -y; sudo apt-get upgrade -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
|
|
} |