Skip to content

Commit 78f1e4d

Browse files
authored
Merge pull request #575 from rust-lang/feat-provision-ubuntu-24-playground-ec2
feat(playground): provision ubuntu 24 ec2
2 parents ca5e95c + c9ead71 commit 78f1e4d

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

terraform/playground/instance.tf

+70
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ resource "aws_eip" "playground" {
55
}
66
}
77

8+
resource "aws_eip" "playground2" {
9+
domain = "vpc"
10+
tags = {
11+
Name = "playground2"
12+
}
13+
}
14+
815
data "dns_a_record_set" "monitoring" {
916
host = "monitoring.infra.rust-lang.org"
1017
}
@@ -98,15 +105,33 @@ resource "aws_network_interface" "playground" {
98105
security_groups = [aws_security_group.playground.id]
99106
}
100107

108+
resource "aws_network_interface" "playground2" {
109+
subnet_id = data.terraform_remote_state.shared.outputs.prod_vpc.public_subnets[0]
110+
security_groups = [aws_security_group.playground.id]
111+
}
112+
101113
resource "aws_eip_association" "playground" {
102114
network_interface_id = aws_network_interface.playground.id
103115
allocation_id = aws_eip.playground.id
104116
}
105117

118+
resource "aws_eip_association" "playground2" {
119+
network_interface_id = aws_network_interface.playground2.id
120+
allocation_id = aws_eip.playground2.id
121+
}
122+
106123
data "aws_route53_zone" "rust_lang_org" {
107124
name = "rust-lang.org"
108125
}
109126

127+
resource "aws_route53_record" "playground2" {
128+
zone_id = data.aws_route53_zone.rust_lang_org.id
129+
name = "play-2.infra.rust-lang.org"
130+
type = "A"
131+
records = [aws_eip.playground2.public_ip]
132+
ttl = 60
133+
}
134+
110135
resource "aws_route53_record" "playground" {
111136
zone_id = data.aws_route53_zone.rust_lang_org.id
112137
name = "play-1.infra.rust-lang.org"
@@ -170,6 +195,21 @@ data "aws_ami" "ubuntu" {
170195
}
171196
}
172197

198+
data "aws_ami" "ubuntu24" {
199+
most_recent = true
200+
owners = ["099720109477"] # Canonical
201+
202+
filter {
203+
name = "name"
204+
values = ["ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*"]
205+
}
206+
207+
filter {
208+
name = "virtualization-type"
209+
values = ["hvm"]
210+
}
211+
}
212+
173213
resource "aws_iam_instance_profile" "playground" {
174214
name = "playground"
175215
role = aws_iam_role.playground.name
@@ -205,6 +245,36 @@ resource "aws_instance" "playground" {
205245
}
206246
}
207247

248+
resource "aws_instance" "playground2" {
249+
ami = data.aws_ami.ubuntu24.id
250+
instance_type = "c5a.large"
251+
key_name = data.terraform_remote_state.shared.outputs.master_ec2_key_pair
252+
iam_instance_profile = aws_iam_instance_profile.playground.name
253+
ebs_optimized = true
254+
disable_api_termination = true
255+
monitoring = false
256+
257+
root_block_device {
258+
volume_type = "gp3"
259+
volume_size = 100
260+
delete_on_termination = true
261+
}
262+
263+
network_interface {
264+
network_interface_id = aws_network_interface.playground2.id
265+
device_index = 0
266+
}
267+
268+
tags = {
269+
Name = "play-2"
270+
}
271+
272+
lifecycle {
273+
# Don't recreate the instance automatically when the AMI changes.
274+
ignore_changes = [ami]
275+
}
276+
}
277+
208278
resource "aws_cloudwatch_metric_alarm" "reboot" {
209279
alarm_name = "playground-status-check"
210280
alarm_description = "Alarms when playground instance is down"

0 commit comments

Comments
 (0)