-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2.tf
58 lines (47 loc) · 1.58 KB
/
ec2.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
# Find the latest Amazon Linux 2 AMI
data "aws_ami" "amazon_linux_2" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["amzn2-ami-hvm-*-x86_64-gp2"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
}
# Create EC2 Instance
resource "aws_instance" "deepseek_r1" {
ami = data.aws_ami.amazon_linux_2.id
instance_type = "g4dn.xlarge"
iam_instance_profile = aws_iam_instance_profile.deepseek_r1_instance_profile.name
subnet_id = aws_subnet.public[0].id
root_block_device {
volume_size = 50
volume_type = "gp3"
encrypted = true
}
vpc_security_group_ids = [aws_security_group.deepseek_sg.id]
# Metadata options to enforce IMDSv2
metadata_options {
http_tokens = "required" # Requires IMDSv2
http_endpoint = "enabled" # Optional: Enable or disable IMDS
http_put_response_hop_limit = 2 # if the hop limit is 1, the IMDSv2 response does not return because going to the container is considered an additional network hop.
}
tags = {
Name = "deepseek-r1"
}
#instance_market_options {
# market_type = "spot"
# spot_options {
# instance_interruption_behavior = "terminate" # Optional, defaults to terminate
# max_price = "0.3" # Maximum price you are willing to pay
# }
#}
# User data to install NVIDIA drivers, Docker and Ollama
user_data = base64encode(file("./scripts/setup_ollama.sh"))
}
resource "aws_eip" "public_ip" {
instance = aws_instance.deepseek_r1.id
}