-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
74 lines (62 loc) · 2.05 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#### Fixed AMI issues, fixed conflict with Subnets, fixed resource parameter types, works as of 08--08 for testing
provider "aws" {
region = "us-gov-west-1"
}
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "subnet_a" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-gov-west-1a"
map_public_ip_on_launch = true
}
resource "aws_internet_gateway" "main" {
vpc_id = aws_vpc.main.id
}
resource "aws_route_table" "public" {
vpc_id = aws_vpc.main.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.main.id
}
}
resource "aws_route_table_association" "a" {
subnet_id = aws_subnet.subnet_a.id
route_table_id = aws_route_table.public.id
}
resource "aws_security_group" "rke2" {
vpc_id = aws_vpc.main.id
ingress {
from_port = 0
to_port = 65535
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 65535
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
# Testing new AMI ami-0a0eef34ee77351a3
resource "aws_instance" "rke2_server" {
ami = "ami-0e7315f6773f0b25e" # To get your ami run this command: aws ec2 describe-images --owners amazon --filters "Name=name,Values=amzn2-ami-hvm-*-x86_64-gp2" --query "Images[*].[ImageId,CreationDate]" --region us-gov-west-1 --output text | sort -k2 -r | head -n 1
instance_type = "t3.medium"
subnet_id = aws_subnet.subnet_a.id
vpc_security_group_ids = [aws_security_group.rke2.id] # Use vpc_security_group_ids instead of security_group_ids was the fix here
tags = {
Name = "RKE2-Server"
}
}
resource "aws_instance" "rke2_agent" {
count = 2
ami = "ami-0e7315f6773f0b25e" # Replace with a valid AMI ID from the above command
instance_type = "t3.medium"
subnet_id = aws_subnet.subnet_a.id
vpc_security_group_ids = [aws_security_group.rke2.id] # Use vpc_security_group_ids instead of security_group_ids
tags = {
Name = "RKE2-Agent-${count.index + 1}"
}
}