!atvIbxHoEqNcAIxYpN:nixos.org

NixOS AWS

64 Members
15 Servers

Load older messages


SenderMessageTime
28 Apr 2025
@adam:robins.wtfadamcstephensI wrote a simple module that will pull a secret down with the CLI given an ARN and some permissions. Creates a basic dir in /run to avoid storing them on disk22:51:20
@adam:robins.wtfadamcstephensAPI is roughly what you get from agenix22:51:47
@adam:robins.wtfadamcstephensWe do pull one secret during cloud-init, but otherwise try and keep it as simple as possible. Cloud init's main job is to discover the proper system store path, pull it, and switch to it, and a couple other imperative things about the system for PS1 and an env file. Our apps also now read their secrets directly on startup, so most secrets never get written outside memory.22:53:48
@kranzes:matrix.orgIlan Joselevich (Kranzes)
In reply to @adam:robins.wtf
I wrote a simple module that will pull a secret down with the CLI given an ARN and some permissions. Creates a basic dir in /run to avoid storing them on disk
Do you have this in a public repo somewhere?
23:04:17
29 Apr 2025
@adam:robins.wtfadamcstephensNo, it's all internal currently00:07:43
@adam:robins.wtfadamcstephensI'll try and remember to throw it in a gist at least01:30:26
@adam:robins.wtfadamcstephensIt's a very simplistic module :)01:30:37
@adam:robins.wtfadamcstephenshttps://gist.github.com/adamcstephens/9f45c33fa02270f669f2cd164faafea714:21:37
1 May 2025
@commiterate:matrix.orgcommiterate

might be easier to write a systemd unit (e.g. oneshot + optional timer or ExecStartPre) which does the credential pull than relying on boot user scripts.

Ideally the boot userscript just does a nixos-rebuild switch --flake {flake URL} and nothing else

19:46:13
@commiterate:matrix.orgcommiteratee.g. I'm using an ExecStartPre in a GitLab Runner systemd unit which fetches a GitLab Runner authn token from AWS Secrets Manager19:46:58
@commiterate:matrix.orgcommiterate *

might be easier to write a systemd unit (e.g. oneshot + optional timer or ExecStartPre) which does the credential pull ratherer than relying on boot user scripts.

Ideally the boot userscript just does a nixos-rebuild switch --flake {flake URL} and nothing else

19:55:12
@commiterate:matrix.orgcommiterate *

might be easier to write a systemd unit (e.g. oneshot + optional timer or ExecStartPre) which does the credential pull rather than relying on boot user scripts.

Ideally the boot userscript just does a nixos-rebuild switch --flake {flake URL} and nothing else

19:55:18
@adam:robins.wtfadamcstephenssure, but if you need a secret to access the flake URL then you have to bootstrap somehow :)20:10:34
@adam:robins.wtfadamcstephensmade me realize i accidentally dropped the service from the above gist when redacting it. updated.20:36:15
3 May 2025
@commiterate:matrix.orgcommiterate🤦 forgot about private flakes, my company still uses a network trust model instead of zero trust so just being in the right VPC is enough19:29:57
4 May 2025
@arianvp:matrix.orgArianDon’t do nix eval on your hosts! just pull nix store paths!09:04:38
@arianvp:matrix.orgArianWe put the nix store path in the user-data at work and then reboot into the new config09:05:08
@arianvp:matrix.orgArianso our hosts only need to have access to S309:05:24
@arianvp:matrix.orgArianto substitute09:05:29
@arianvp:matrix.orgArian though the S3 substituter in Nix is completely broken beyond belief 09:05:37
@arianvp:matrix.orgArianI need to find time to rewrite it09:05:40
@arianvp:matrix.orgArianhttps://github.com/NixOS/nix/issues/1308409:05:54
@arianvp:matrix.orgArian * 09:06:13
@p14:matrix.orgp14 Arian: oof! That sounds pretty nasty, though the fix is looking quite simple. How far out is the fix? It sounds like you've done a lot of the work for it already... 11:43:47
5 May 2025
@arianvp:matrix.orgArian

Hey all, I have a message from the foundation I think makes sense to forward here:

⁦Hey everyone, happy almost‑Monday for some, and full‑on Monday for most! 😉

We’re kicking off our AWS cache sponsorship renewal (shoutout to the AWS Open Source teams for sponsoring us for two consecutive years now) and could use your help. If you work at AWS, or know someone who does, please drop me a note!

Each year we put together a summary of how Nix adds value on AWS, and real‑world examples make our case much stronger. If you’ve used Nix for anything on EC2, Lambda, EKS, CodeBuild, caching Docker layers, reducing build times, improving deploy consistency, or anything else in the AWS ecosystem, I’d love to hear about it. Even a quick bullet point or link to a project helps!

Thanks in advance for any pointers or introductions you can share. 🙏

07:48:56
@arianvp:matrix.orgArian So e.g. @commiterate:matrix.orgor @adam:robins.wtfif you are in a position where you could share a blurb about how you're using AWS + Nix at your company that'd be really awesome. No obligation of course. 07:51:21
6 May 2025
@commiterate:matrix.orgcommiterate

We use Nix + system-manager to bake reproducible Amazon Linux 2023 AMIs. There's a shell script snippet in this GitHub issue: https://github.com/aws/ec2-image-builder-roadmap/issues/110

# Switch from ssm-user to the default user.
sudo su ec2-user

# Install RPM packages.
sudo dnf install --assumeyes curl-minimal git

# Install Nix.
curl --fail --location https://install.determinate.systems/nix/tag/v3.1.1 --proto '=https' --show-error --silent --tlsv1.2 | sh -s -- install --no-confirm
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

# Setup Nix flake registry.
nix registry add nixpkgs github:NixOS/nixpkgs/{Git revision hash}
nix registry add system-manager github:numtide/system-manager/{Git revision hash}

# Install Nix packages.
nix profile install system-manager

# Apply system-manager configuration (installs system-wide packages and sets up systemd units).
sudo $(command -v system-manager) pre-populate --flake 'git+{Git HTTPs URL}&rev={Git revision hash}#{system-manager flake output key}'

CloudFormation templates are generated with the AWS CDK. The infrastructure code essentially:

  • Locks an Amazon-managed AMI ARN from their SSM public parameters into the cdk.context.json file.
  • Calls nix flake metadata to get the flake's Git hash and construct a flake URL (we run Nix eval on a system in a VPC with company network connectivity).
  • Generates an SSM document with the flake URL.
  • Sets up the EC2 Image Builder infrastructure that auto-builds an AMI on CloudFormation stack deploys.
  • Reference the AMI in a launch template which is then used in an auto-scaling group.
  • Use CloudFormation rolling update to bounce the auto-scaling group (until ASG instance refresh is supported in CloudFormation).

Once the CloudFormation image import situation is improved, we'll move the non-bootstrap stuff to use NixOS disk images created with the systemd-repart helpers.

18:10:47
@commiterate:matrix.orgcommiterate *

We use Nix + system-manager to bake reproducible Amazon Linux 2023 AMIs. There's a shell script snippet in this GitHub issue: https://github.com/aws/ec2-image-builder-roadmap/issues/110

# Switch from ssm-user to the default user.
sudo su ec2-user

# Install RPM packages.
sudo dnf install --assumeyes curl-minimal git

# Install Nix.
curl --fail --location https://install.determinate.systems/nix/tag/v3.1.1 --proto '=https' --show-error --silent --tlsv1.2 | sh -s -- install --no-confirm
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

# Setup Nix flake registry.
nix registry add nixpkgs github:NixOS/nixpkgs/{Git revision hash}
nix registry add system-manager github:numtide/system-manager/{Git revision hash}

# Install Nix packages.
nix profile install system-manager

# Apply system-manager configuration (installs system-wide packages and sets up systemd units).
sudo $(command -v system-manager) pre-populate --flake 'git+{Git HTTPs URL}&rev={Git revision hash}#{system-manager flake output key}'

CloudFormation templates are generated with the AWS CDK. The infrastructure code essentially:

  • Locks an Amazon-managed AMI ARN from their SSM public parameters into the cdk.context.json file.
  • Calls nix flake metadata to get the flake's Git hash and construct a flake URL (we run Nix eval on a system in a VPC with company network connectivity).
  • Generates an SSM document with the flake URL.
  • Sets up the EC2 Image Builder infrastructure that auto-builds an AMI on CloudFormation stack deploys.
  • Reference the AMI in a launch template which is then used in an auto-scaling group.
  • Use CloudFormation rolling update to bounce the auto-scaling group (until ASG instance refresh is supported in CloudFormation).

Once the CloudFormation image import situation is improved, we'll move the non-bootstrap stuff to use NixOS disk images created with the systemd-repart helpers.

18:11:04
@commiterate:matrix.orgcommiterate *

We use Nix + system-manager to bake reproducible Amazon Linux 2023 AMIs. There's a shell script snippet in this GitHub issue: https://github.com/aws/ec2-image-builder-roadmap/issues/110

# Switch from ssm-user to the default user.
sudo su ec2-user

# Install RPM packages.
sudo dnf install --assumeyes curl-minimal git

# Install Nix.
curl --fail --location https://install.determinate.systems/nix/tag/v3.1.1 --proto '=https' --show-error --silent --tlsv1.2 | sh -s -- install --no-confirm
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

# Setup Nix flake registry.
nix registry add nixpkgs github:NixOS/nixpkgs/{Git revision hash}
nix registry add system-manager github:numtide/system-manager/{Git revision hash}

# Install Nix packages.
nix profile install system-manager

# Apply system-manager configuration (installs system-wide packages and sets up systemd units).
sudo $(command -v system-manager) pre-populate --flake 'git+{Git HTTPs URL}&rev={Git revision hash}#{system-manager flake output key}'

CloudFormation templates are generated with the AWS CDK. The infrastructure code essentially:

  • Locks an Amazon-managed AMI ARN from their SSM public parameters into the cdk.context.json file.
  • Calls nix flake metadata to get the flake's Git hash and construct a flake URL for the flake itself and some inputs needed in the script (we run Nix eval on a system in a VPC with company network connectivity).
  • Generates an SSM document with the flake URL.
  • Sets up the EC2 Image Builder infrastructure that auto-builds an AMI on CloudFormation stack deploys.
  • Reference the AMI in a launch template which is then used in an auto-scaling group.
  • Use CloudFormation rolling update to bounce the auto-scaling group (until ASG instance refresh is supported in CloudFormation).

Once the CloudFormation image import situation is improved, we'll move the non-bootstrap stuff to use NixOS disk images created with the systemd-repart helpers.

18:12:11
@commiterate:matrix.orgcommiterate *

We use Nix + system-manager to bake reproducible Amazon Linux 2023 AMIs. There's a shell script snippet in this GitHub issue: https://github.com/aws/ec2-image-builder-roadmap/issues/110

# Switch from ssm-user to the default user.
sudo su ec2-user

# Install RPM packages.
sudo dnf install --assumeyes curl-minimal git

# Install Nix.
curl --fail --location https://install.determinate.systems/nix/tag/v3.1.1 --proto '=https' --show-error --silent --tlsv1.2 | sh -s -- install --no-confirm
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

# Setup Nix flake registry.
nix registry add nixpkgs github:NixOS/nixpkgs/{Git revision hash}
nix registry add system-manager github:numtide/system-manager/{Git revision hash}

# Install Nix packages.
nix profile install system-manager

# Apply system-manager configuration (installs system-wide packages and sets up systemd units).
sudo $(command -v system-manager) pre-populate --flake 'git+{Git HTTPs URL}&rev={Git revision hash}#{system-manager flake output key}'

CloudFormation templates are generated with the AWS CDK. The infrastructure code essentially:

  • Locks an Amazon-managed AMI ARN from their SSM public parameters into the cdk.context.json file.
  • Calls nix flake metadata to get the flake's Git hash and construct a flake URL for the flake itself and some inputs needed in the script (we run Nix eval on a system in a VPC with company network connectivity).
  • Generates an SSM document with the flake URL.
  • Sets up the EC2 Image Builder infrastructure that auto-builds an AMI on CloudFormation stack deploys.
  • Reference the AMI in a launch template which is then used in an auto-scaling group.
  • Use CloudFormation rolling update to bounce the auto-scaling group (until ASG instance refresh is supported in CloudFormation).

Once the CloudFormation image import situation is improved, we'll move the non-bootstrap stuff to use NixOS disk images created with the systemd-repart helpers.

This ends up being fully reproducible because Amazon Linux 2023 locks the Amazon Linux package repository version (these are globally versioned now), so any Nix dependencies like curl and git locked by the AMI itself.

18:13:00

Show newer messages


Back to Room ListRoom Version: 10