Increase AMI builder capacity
This commit is contained in:
@@ -46,6 +46,7 @@ locals {
|
||||
? "nixos/*-${var.system}"
|
||||
: var.base_nixos_ami_name_pattern
|
||||
)
|
||||
builder_instance_type = var.builder_instance_type == null ? (var.system == "aarch64-linux" ? "c7g.2xlarge" : "c7i.2xlarge") : var.builder_instance_type
|
||||
base_nixos_ami_id = var.base_nixos_ami_id == null ? data.aws_ami.nixos[0].id : var.base_nixos_ami_id
|
||||
resource_name = "${var.name}-builder-${local.aws_architecture}-${substr(var.input_hash, 0, 12)}"
|
||||
nix_device_id = replace(aws_ebs_volume.nix.id, "-", "")
|
||||
@@ -114,6 +115,8 @@ resource "aws_ebs_volume" "nix" {
|
||||
availability_zone = data.aws_subnet.selected.availability_zone
|
||||
size = var.nix_volume_size_gb
|
||||
type = "gp3"
|
||||
iops = var.nix_volume_iops
|
||||
throughput = var.nix_volume_throughput
|
||||
|
||||
tags = merge(local.tags, {
|
||||
Name = "${local.resource_name}-nix"
|
||||
@@ -122,11 +125,12 @@ resource "aws_ebs_volume" "nix" {
|
||||
|
||||
resource "aws_instance" "builder" {
|
||||
ami = local.base_nixos_ami_id
|
||||
instance_type = var.builder_instance_type
|
||||
instance_type = local.builder_instance_type
|
||||
subnet_id = local.subnet_id
|
||||
vpc_security_group_ids = [aws_security_group.builder.id]
|
||||
iam_instance_profile = aws_iam_instance_profile.builder.name
|
||||
associate_public_ip_address = true
|
||||
ebs_optimized = true
|
||||
key_name = var.ssh_public_key == null ? null : aws_key_pair.admin[0].key_name
|
||||
user_data_replace_on_change = true
|
||||
|
||||
@@ -143,6 +147,8 @@ resource "aws_instance" "builder" {
|
||||
root_block_device {
|
||||
volume_size = var.root_volume_size_gb
|
||||
volume_type = "gp3"
|
||||
iops = var.root_volume_iops
|
||||
throughput = var.root_volume_throughput
|
||||
}
|
||||
|
||||
tags = local.tags
|
||||
|
||||
+26
-2
@@ -38,8 +38,8 @@ variable "flake_lock_rev" {
|
||||
|
||||
variable "builder_instance_type" {
|
||||
type = string
|
||||
default = "t4g.large"
|
||||
description = "Temporary EC2 instance type used to build and seed the AMI."
|
||||
default = null
|
||||
description = "Temporary EC2 instance type used to build and seed the AMI. Defaults to c7g.2xlarge for aarch64-linux and c7i.2xlarge for x86_64-linux."
|
||||
}
|
||||
|
||||
variable "vpc_id" {
|
||||
@@ -78,12 +78,36 @@ variable "root_volume_size_gb" {
|
||||
description = "Temporary builder root EBS volume size. This becomes the final AMI root snapshot size."
|
||||
}
|
||||
|
||||
variable "root_volume_iops" {
|
||||
type = number
|
||||
default = 6000
|
||||
description = "Temporary builder root gp3 IOPS. This affects builder speed only; snapshots do not preserve provisioned IOPS."
|
||||
}
|
||||
|
||||
variable "root_volume_throughput" {
|
||||
type = number
|
||||
default = 250
|
||||
description = "Temporary builder root gp3 throughput in MiB/s. This affects builder speed only; snapshots do not preserve provisioned throughput."
|
||||
}
|
||||
|
||||
variable "nix_volume_size_gb" {
|
||||
type = number
|
||||
default = 50
|
||||
description = "Temporary /nix EBS volume size. This becomes the final AMI /nix snapshot size."
|
||||
}
|
||||
|
||||
variable "nix_volume_iops" {
|
||||
type = number
|
||||
default = 12000
|
||||
description = "Temporary /nix gp3 IOPS used while building and seeding the AMI."
|
||||
}
|
||||
|
||||
variable "nix_volume_throughput" {
|
||||
type = number
|
||||
default = 500
|
||||
description = "Temporary /nix gp3 throughput in MiB/s used while building and seeding the AMI."
|
||||
}
|
||||
|
||||
variable "nix_pool" {
|
||||
type = string
|
||||
default = "nixos-zfs-nix"
|
||||
|
||||
Reference in New Issue
Block a user