27 lines
833 B
Python
27 lines
833 B
Python
"""EC2 user-data template rendering for builder instance bootstrap."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import textwrap
|
|
|
|
|
|
def render_userdata(slot_id: str, ssm_param: str = "/nix-builder/ts-authkey") -> str:
|
|
"""Render user-data that seeds AMI bootstrap inputs only.
|
|
|
|
The AMI's buildbot-ami-bootstrap service consumes this env file and handles
|
|
SSM fetch + tailscale-autoconnect config generation.
|
|
"""
|
|
return textwrap.dedent(f"""\
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SLOT_ID="{slot_id}"
|
|
SSM_PARAM="{ssm_param}"
|
|
|
|
# Seed AMI bootstrap inputs only; buildbot-ami-bootstrap reads this file.
|
|
cat > /etc/nix-builder-bootstrap-env <<EOF
|
|
SLOT_ID="$SLOT_ID"
|
|
TS_SSM_PARAM="$SSM_PARAM"
|
|
EOF
|
|
chmod 600 /etc/nix-builder-bootstrap-env
|
|
""")
|