Skip to content

Commit

Permalink
Merge pull request #591 from rust-lang/delete-play-1-ec2-instance
Browse files Browse the repository at this point in the history
delete `play-1` EC2 instance
  • Loading branch information
MarcoIeni authored Oct 7, 2024
2 parents 28bb58d + d97371d commit 7790f2c
Showing 1 changed file with 1 addition and 71 deletions.
72 changes: 1 addition & 71 deletions terraform/playground/instance.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
resource "aws_eip" "playground" {
vpc = true
tags = {
Name = "playground"
}
}

resource "aws_eip" "playground2" {
domain = "vpc"
tags = {
Expand Down Expand Up @@ -100,21 +93,11 @@ resource "aws_security_group" "playground" {
}
}

resource "aws_network_interface" "playground" {
subnet_id = data.terraform_remote_state.shared.outputs.prod_vpc.public_subnets[0]
security_groups = [aws_security_group.playground.id]
}

resource "aws_network_interface" "playground2" {
subnet_id = data.terraform_remote_state.shared.outputs.prod_vpc.public_subnets[0]
security_groups = [aws_security_group.playground.id]
}

resource "aws_eip_association" "playground" {
network_interface_id = aws_network_interface.playground.id
allocation_id = aws_eip.playground.id
}

resource "aws_eip_association" "playground2" {
network_interface_id = aws_network_interface.playground2.id
allocation_id = aws_eip.playground2.id
Expand All @@ -132,14 +115,6 @@ resource "aws_route53_record" "playground2" {
ttl = 60
}

resource "aws_route53_record" "playground" {
zone_id = data.aws_route53_zone.rust_lang_org.id
name = "play-1.infra.rust-lang.org"
type = "A"
records = [aws_eip.playground.public_ip]
ttl = 60
}

// Create the IAM role used by the playground.

resource "aws_iam_role" "playground" {
Expand Down Expand Up @@ -180,21 +155,6 @@ resource "aws_iam_role" "playground" {

// Create the EC2 instance itself.

data "aws_ami" "ubuntu" {
most_recent = true
owners = ["099720109477"] # Canonical

filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}
}

data "aws_ami" "ubuntu24" {
most_recent = true
owners = ["099720109477"] # Canonical
Expand All @@ -215,36 +175,6 @@ resource "aws_iam_instance_profile" "playground" {
role = aws_iam_role.playground.name
}

resource "aws_instance" "playground" {
ami = data.aws_ami.ubuntu.id
instance_type = "c5a.large"
key_name = data.terraform_remote_state.shared.outputs.master_ec2_key_pair
iam_instance_profile = aws_iam_instance_profile.playground.name
ebs_optimized = true
disable_api_termination = true
monitoring = false

root_block_device {
volume_type = "gp3"
volume_size = 100
delete_on_termination = true
}

network_interface {
network_interface_id = aws_network_interface.playground.id
device_index = 0
}

tags = {
Name = "play-1"
}

lifecycle {
# Don't recreate the instance automatically when the AMI changes.
ignore_changes = [ami]
}
}

resource "aws_instance" "playground2" {
ami = data.aws_ami.ubuntu24.id
instance_type = "c5a.large"
Expand Down Expand Up @@ -290,7 +220,7 @@ resource "aws_cloudwatch_metric_alarm" "reboot" {
treat_missing_data = "ignore"

dimensions = {
InstanceId = aws_instance.playground.id
InstanceId = aws_instance.playground2.id
}

actions_enabled = true
Expand Down

0 comments on commit 7790f2c

Please sign in to comment.