Commit Graph

13 Commits

Author SHA1 Message Date
Philip Taron
b1444cab3c nixos/virtualisation/ec2: fix preflight validation and variable scoping
- Preflight validation now validates against the endpoint that issued
  the token (IMDS_BASE_URL) instead of re-scanning all endpoints. The
  previous behavior could silently switch to a different endpoint and
  wasted time retrying unreachable ones.

- Add local keyword to endpoint variables in get_imds_token and
  preflight_imds_token to avoid polluting global scope.
2026-03-24 15:38:20 -07:00
Jared Dunbar
2ef00e2d52 nixos/virtualization/ec2: Adds IPv6 IMDS fetch capability
Updates the EC2 IMDS metadata fetcher script to support IPv6 endpoints. If you start an instance in an IPv6 subnet, if the EC2 instance gets an IPv6 address before the IPv4 address (extremely common), systemd will trigger the IMDS fetcher script and fail to fetch your NixOS configuration, leaving you with a useless unconfigured EC2 instance. This at least allows the NixOS configuration to be fetched and applied.
2026-03-24 15:37:36 -07:00
Philip Taron
d09e847072 nixos/ec2-metadata-fetcher: add lzip user-data decompression
Support decompressing lzip-compressed EC2 user data via lzip -dc.
Includes a corresponding NixOS test.
2026-03-24 14:51:59 -07:00
Philip Taron
f3b392af9b nixos/ec2-metadata-fetcher: add zstd user-data decompression
Support decompressing Zstandard-compressed EC2 user data via zstdcat.
Includes a corresponding NixOS test.
2026-03-24 14:51:59 -07:00
Philip Taron
e3789300b1 nixos/ec2-metadata-fetcher: add xz user-data decompression
Support decompressing XZ-compressed EC2 user data via xzcat.
Includes a corresponding NixOS test.
2026-03-24 14:51:59 -07:00
Philip Taron
45d8ed8f4e nixos/ec2-metadata-fetcher: add bzip2 user-data decompression
Refactor try_decompress to use a decompress_cmd variable, making it
straightforward to add new compression formats. Add bzip2 support
and a corresponding NixOS test.
2026-03-24 14:51:58 -07:00
Philip Taron
cb4dcba409 nixos/ec2-metadata-fetcher: harden try_decompress
- Declare `ftype` as local to avoid leaking into caller scope
- Skip decompression attempt on empty files
- Clean up temp file on decompression failure
2026-03-24 14:51:57 -07:00
Johnny Walker
80a4ce9ab8 nixos/ec2-metadata-fetcher: decompress gzip-compressed user data
Closes https://github.com/NixOS/nixpkgs/issues/290336
2026-03-24 14:51:56 -07:00
Robert Hensing
8146763574 nixos/ec2-data.nix: Print whole host pubkeys
This prints the whole host public keys in the same format as cloud-init.
The main benefit is that this allows the direct generation of a known_hosts
file, simplifying client setup.

This commit also provides a new NixOS test that's an alternative to the
currently broken nixos/tests/ec2.nix tests.
2025-12-23 13:41:44 +01:00
r-vdp
11d9033d85 nixos/ec2: Fix typo, chown -> chmod 2024-10-10 09:02:06 +02:00
r-vdp
8e325b5086 ec2: shellcheck fixes 2024-09-08 12:27:58 +02:00
illustris
7e4e6e8bd7 nixos/ec2: don't populate nonexistent metadata files 2023-02-26 23:25:09 +05:30
Linus Heckemann
36ca2b495f nixos/ec2: use only curl in metadata fetcher, log to console
We don't need both wget and curl, so let's use only curl (which is
part of a minimal NixOS closure, unlike wget).

Logging to the console is helpful for debugging.
2022-11-23 17:19:16 +01:00