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

92 lines
2.1 KiB
Terraform
Raw Permalink Normal View History

2022-11-14 23:24:05 +01:00
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" {
2022-11-16 22:43:34 +01:00
ami = "ami-0fd8802f94ed1c969"
2022-11-14 23:24:05 +01:00
associate_public_ip_address = true
instance_type = "t3.large"
key_name = "overseer.ligthert.net"
tags = {
Name = "controlplane"
}
root_block_device {
2022-11-16 22:43:34 +01:00
volume_size = "64"
2022-11-14 23:24:05 +01:00
volume_type = "gp2"
}
2022-11-16 22:43:34 +01:00
#user_data = "sudo apt-get update -y; sudo apt-get upgrade -y"
2022-11-14 23:24:05 +01:00
vpc_security_group_ids = [aws_security_group.k8s.id]
}
output "controlplane_public_ip" {
value = aws_instance.controlplane.public_ip
}
output "controlplane_private_ip" {
2022-11-16 22:43:34 +01:00
value = aws_instance.controlplane.private_ip
2022-11-14 23:24:05 +01:00
}
output "controlplane_instance_id" {
value = aws_instance.controlplane.arn
}
resource "aws_instance" "node" {
2022-11-16 22:43:34 +01:00
ami = "ami-0fd8802f94ed1c969"
2022-11-14 23:24:05 +01:00
associate_public_ip_address = true
instance_type = "t3.large"
key_name = "overseer.ligthert.net"
tags = {
Name = "node"
}
root_block_device {
2022-11-16 22:43:34 +01:00
volume_size = "64"
2022-11-14 23:24:05 +01:00
volume_type = "gp2"
}
2022-11-16 22:43:34 +01:00
#user_data = "sudo apt-get update -y; sudo apt-get upgrade -y"
2022-11-14 23:24:05 +01:00
vpc_security_group_ids = [aws_security_group.k8s.id]
}
output "node_public_ip" {
value = aws_instance.node.public_ip
}
output "node_private_ip" {
2022-11-16 22:43:34 +01:00
value = aws_instance.node.private_ip
2022-11-14 23:24:05 +01:00
}
output "node_instance_id" {
value = aws_instance.node.arn
}