Skip to content

Commit

Permalink
Merge pull request #623 from rust-lang/chore-delete-old-bastion-ec2
Browse files Browse the repository at this point in the history
chore: delete old bastion EC2
  • Loading branch information
MarcoIeni authored Oct 28, 2024
2 parents 03c2717 + 97a2773 commit eaddc68
Showing 1 changed file with 0 additions and 69 deletions.
69 changes: 0 additions & 69 deletions terraform/bastion/instance.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,18 @@

// Associate an elastic IP to the instance.

resource "aws_eip" "bastion" {
vpc = true
tags = {
Name = "bastion"
}
}

resource "aws_eip" "bastion2" {
domain = "vpc"
tags = {
Name = "bastion2"
}
}

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

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

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

resource "aws_eip_association" "bastion2" {
network_interface_id = aws_network_interface.bastion2.id
allocation_id = aws_eip.bastion2.id
Expand All @@ -42,14 +25,6 @@ data "aws_route53_zone" "rust_lang_org" {
name = "rust-lang.org"
}

resource "aws_route53_record" "bastion" {
zone_id = data.aws_route53_zone.rust_lang_org.id
name = "bastion1.infra.rust-lang.org"
type = "A"
records = [aws_eip.bastion.public_ip]
ttl = 300
}

resource "aws_route53_record" "bastion2" {
zone_id = data.aws_route53_zone.rust_lang_org.id
name = "bastion.infra.rust-lang.org"
Expand All @@ -60,21 +35,6 @@ resource "aws_route53_record" "bastion2" {

// Create the EC2 instance itself.

data "aws_ami" "ubuntu_bionic" {
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 @@ -90,35 +50,6 @@ data "aws_ami" "ubuntu24" {
}
}

resource "aws_instance" "bastion" {
ami = data.aws_ami.ubuntu_bionic.id
instance_type = "t3a.micro"
key_name = data.terraform_remote_state.shared.outputs.master_ec2_key_pair
ebs_optimized = true
disable_api_termination = true
monitoring = false

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

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

tags = {
Name = "bastion"
}

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

resource "aws_instance" "bastion2" {
ami = data.aws_ami.ubuntu24.id
instance_type = "t3a.micro"
Expand Down

0 comments on commit eaddc68

Please sign in to comment.