Increase AMI builder capacity
This commit is contained in:
@@ -46,6 +46,7 @@ locals {
|
|||||||
? "nixos/*-${var.system}"
|
? "nixos/*-${var.system}"
|
||||||
: var.base_nixos_ami_name_pattern
|
: 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
|
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)}"
|
resource_name = "${var.name}-builder-${local.aws_architecture}-${substr(var.input_hash, 0, 12)}"
|
||||||
nix_device_id = replace(aws_ebs_volume.nix.id, "-", "")
|
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
|
availability_zone = data.aws_subnet.selected.availability_zone
|
||||||
size = var.nix_volume_size_gb
|
size = var.nix_volume_size_gb
|
||||||
type = "gp3"
|
type = "gp3"
|
||||||
|
iops = var.nix_volume_iops
|
||||||
|
throughput = var.nix_volume_throughput
|
||||||
|
|
||||||
tags = merge(local.tags, {
|
tags = merge(local.tags, {
|
||||||
Name = "${local.resource_name}-nix"
|
Name = "${local.resource_name}-nix"
|
||||||
@@ -122,11 +125,12 @@ resource "aws_ebs_volume" "nix" {
|
|||||||
|
|
||||||
resource "aws_instance" "builder" {
|
resource "aws_instance" "builder" {
|
||||||
ami = local.base_nixos_ami_id
|
ami = local.base_nixos_ami_id
|
||||||
instance_type = var.builder_instance_type
|
instance_type = local.builder_instance_type
|
||||||
subnet_id = local.subnet_id
|
subnet_id = local.subnet_id
|
||||||
vpc_security_group_ids = [aws_security_group.builder.id]
|
vpc_security_group_ids = [aws_security_group.builder.id]
|
||||||
iam_instance_profile = aws_iam_instance_profile.builder.name
|
iam_instance_profile = aws_iam_instance_profile.builder.name
|
||||||
associate_public_ip_address = true
|
associate_public_ip_address = true
|
||||||
|
ebs_optimized = true
|
||||||
key_name = var.ssh_public_key == null ? null : aws_key_pair.admin[0].key_name
|
key_name = var.ssh_public_key == null ? null : aws_key_pair.admin[0].key_name
|
||||||
user_data_replace_on_change = true
|
user_data_replace_on_change = true
|
||||||
|
|
||||||
@@ -143,6 +147,8 @@ resource "aws_instance" "builder" {
|
|||||||
root_block_device {
|
root_block_device {
|
||||||
volume_size = var.root_volume_size_gb
|
volume_size = var.root_volume_size_gb
|
||||||
volume_type = "gp3"
|
volume_type = "gp3"
|
||||||
|
iops = var.root_volume_iops
|
||||||
|
throughput = var.root_volume_throughput
|
||||||
}
|
}
|
||||||
|
|
||||||
tags = local.tags
|
tags = local.tags
|
||||||
|
|||||||
+26
-2
@@ -38,8 +38,8 @@ variable "flake_lock_rev" {
|
|||||||
|
|
||||||
variable "builder_instance_type" {
|
variable "builder_instance_type" {
|
||||||
type = string
|
type = string
|
||||||
default = "t4g.large"
|
default = null
|
||||||
description = "Temporary EC2 instance type used to build and seed the AMI."
|
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" {
|
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."
|
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" {
|
variable "nix_volume_size_gb" {
|
||||||
type = number
|
type = number
|
||||||
default = 50
|
default = 50
|
||||||
description = "Temporary /nix EBS volume size. This becomes the final AMI /nix snapshot size."
|
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" {
|
variable "nix_pool" {
|
||||||
type = string
|
type = string
|
||||||
default = "nixos-zfs-nix"
|
default = "nixos-zfs-nix"
|
||||||
|
|||||||
Reference in New Issue
Block a user