Clean up AMI builders by default

This commit is contained in:
Timothy J. Aveni
2026-06-20 12:57:40 -07:00
parent 73015da5a3
commit 9d1d41cdef
2 changed files with 7 additions and 6 deletions
+2 -1
View File
@@ -31,7 +31,8 @@ boot generation, reboots once, seeds the ZFS `/nix` volume, installs the final
boot generation that expects `/nix`, and powers off. boot generation that expects `/nix`, and powers off.
After the instance is stopped, `publish-ami.sh` creates the final AMI from the After the instance is stopped, `publish-ami.sh` creates the final AMI from the
stopped instance, tags the AMI and snapshots, and writes `artifact.json`. stopped instance, tags the AMI and snapshots, writes `artifact.json`, and then
destroys the temporary builder resources. Use `--keep-builder` when debugging.
The OpenTofu state in this directory owns only temporary builder resources. The OpenTofu state in this directory owns only temporary builder resources.
The published AMI and its snapshots are created by the script and are not in The published AMI and its snapshots are created by the script and are not in
+5 -5
View File
@@ -5,7 +5,7 @@ aws_region="${AWS_REGION:-us-west-2}"
system="aarch64-linux" system="aarch64-linux"
builder_instance_type="t4g.large" builder_instance_type="t4g.large"
name="nixos-zfs-ec2" name="nixos-zfs-ec2"
destroy_builder=false keep_builder=false
extra_tofu_args=() extra_tofu_args=()
usage() { usage() {
@@ -18,7 +18,7 @@ Options:
--aws-region <region> AWS region (default: AWS_REGION or us-west-2) --aws-region <region> AWS region (default: AWS_REGION or us-west-2)
--builder-instance-type <t> Temporary builder EC2 type (default: t4g.large) --builder-instance-type <t> Temporary builder EC2 type (default: t4g.large)
--name <name> AMI name prefix --name <name> AMI name prefix
--destroy-builder Destroy temporary builder resources after publish --keep-builder Keep temporary builder resources after publish
-h, --help Show this help -h, --help Show this help
Any arguments after `--` are passed through to `tofu apply`. Any arguments after `--` are passed through to `tofu apply`.
@@ -46,8 +46,8 @@ while [ "$#" -gt 0 ]; do
name="$2" name="$2"
shift 2 shift 2
;; ;;
--destroy-builder) --keep-builder)
destroy_builder=true keep_builder=true
shift shift
;; ;;
--) --)
@@ -298,7 +298,7 @@ jq -n \
nixPool: $nixPool nixPool: $nixPool
}' > artifact.json }' > artifact.json
if [ "$destroy_builder" = true ]; then if [ "$keep_builder" = false ]; then
tofu destroy \ tofu destroy \
-var "aws_region=$aws_region" \ -var "aws_region=$aws_region" \
-var "name=$name" \ -var "name=$name" \