!atvIbxHoEqNcAIxYpN:nixos.org

NixOS AWS

65 Members
17 Servers

Load older messages


SenderMessageTime
20 Jul 2024
@joerg:thalheim.ioMic92 joined the room.10:39:23
22 Jul 2024
@luke:vuksta.comLuke joined the room.22:24:00
23 Jul 2024
@ezzobirbezziou:matrix.orgEzzobir Bezziou joined the room.08:21:01
29 Jul 2024
@philip4g:matrix.orgPhilip joined the room.19:09:41
@philip4g:matrix.orgPhilip

Hello all! I've set up NixOS on AWS by booting into a NixOS AMI, then doing nixos-install onto a custom EBS volume. After that, I switched the boot device of my EC2 instance from the AMI-created temporary EBS volume to my new custom volume and booting the instance from it.

Now I have the AMI-created EBS volume still, although it's not attached to anything. I'd like to get rid of it. I think the cleanest way would be to detach the NixOS AMI from the EC2 instance. AFAIK I don't need the AMI anymore, since I have the OS installed to EBS. But I don't find a way to have an EC2 instance without an AMI!

Any advice on how to get rid of the AMI or its EBS volume?

19:14:07
@arianvp:matrix.orgArianThere is no need to do this. The AMI is a proper NixOS installation19:43:21
@arianvp:matrix.orgArianyou can just do nixos-rebuild switch on the existing EBS volume19:43:27
@arianvp:matrix.orgArian

Note that the AMI is and EBS volume already

19:44:04
@arianvp:matrix.orgArianit’s a pointer to an EBS snapshot; that then gets mounted as an EBS volume19:44:17
@arianvp:matrix.orgArianWhat exactly are you trying ot do?19:45:04
@arianvp:matrix.orgArianif you want to change the EBS volume type; you can do that already without nixos-installing to a different EBS volume. You can select the EBS volume type in the DeviceMapping19:45:40
@arianvp:matrix.orgArian

e.g. if you’re using Terraform:


data "aws_ami" "nixos_arm64" {
  owners      = ["427812963091"]
  most_recent = true

  filter {
    name   = "name"
    values = ["nixos/24.05*"]
  }
  filter {
    name   = "architecture"
    values = ["arm64"] # or "x86_64"
  }
}

resource “aws_instance” “my_instance” {

  ami           = data.aws_ami.nixos_arm64.id
  instance_type = "t4g.nano"
  root_block_device {
    volume_size = 500
    volume_type = “io2”
  }

}

Will boot the NixOS AMI on an io2 EBS volume of 500GB size. NixOS will resize the partition and file system automatically on first boot

19:48:04
@arianvp:matrix.orgArian

EC2 instance must have an associated AMI and Root Block Device. You cant detach it

19:49:00
30 Jul 2024
@philip4g:matrix.orgPhilip

What exactly are you trying ot do?

I want to install NixOS on an EBS volume that's decoupled from the instance. For example, if I delete the EC2 instance with the NixOS AMI, then the default 4 GB EBS volume gets deleted. I want to be able to replace the instance with something larger or smaller without losing my OS install.

16:03:41
@arianvp:matrix.orgArianYou can set this as an option on the instance16:09:45
@arianvp:matrix.orgArianhttps://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#delete_on_termination16:10:02
@arianvp:matrix.orgArian

set delete_on_termination to false. it will keep the volume around

16:10:23
@arianvp:matrix.orgArianNote that you can resize instances without destroying the instance16:10:33
@arianvp:matrix.orgArianresize just causes the machine to reboot. 16:10:43
@arianvp:matrix.orgArianYou can also take a snapshot of your volume and then turn that into an AMI again if you want16:11:10
@arianvp:matrix.orgArianthe problem is that even if you have the OS on separate instance; it’s not gonna help you. Pretty sure AWS’s EFI Firmware will boot from the root block device first. And creating an instance without an associated AMI is not possible16:15:17
@arianvp:matrix.orgArianso I’d advice taking a snapshot of your root volume and registering it as a new AMI if you really need to destroy an instance16:15:36
@arianvp:matrix.orgArianbut for most operations the instance doesn’t need to be destroyed. Resizing the volume, resizing the instance etc can all happen without destroying the instance16:15:56
31 Jul 2024
@philip4g:matrix.orgPhilipThanks. This is interesting. I guess I see EC2 and AMIs as the relationship between PCs and CD drives. I insert a CD with the OS installation data. I boot up the PC, then install the OS onto the hard drive. Then I can unplug the CD drive and boot with just the hard drive.07:08:43
@philip4g:matrix.orgPhilipSo for me, the NixOS AMI is the installation media only, removable. Whereas the attached EBS volume is what boots. Now that I have NixOS installed on my EBS volume and attached, I don't know anymore what value the AMI brings.07:09:35
@arianvp:matrix.orgArian

AMIs are not installation media. They’re fully working operating system snapshots. I would not suggest installing the OS on a secondary EBS volume.

If you want to boot a new instance with the old volume you can take a snapshot of the volume and use that as the AMI for the new instance

17:20:19
9 Aug 2024
@AleXoundOS:matrix.org@AleXoundOS:matrix.orgHas anybody used NixOS AMI as part of a CloudFormation product in Marketplace? So, not as SAS, but a consumer gets deployment (including NixOS AMI) in its own AWS Cloud? Are there any special requirements for AMIs which NixOS AMI does not meet in case of Marketplace?09:17:16
@arianvp:matrix.orgArianI think it should just work? The AMI is public10:20:33
@arianvp:matrix.orgArianI’m not a 100% sure10:24:01
@arianvp:matrix.orgArian

You might need to clone the AMI into your own account first (e.g. using CloneImage)

10:24:13

Show newer messages


Back to Room ListRoom Version: 10