Add EC2 Launch Template strain genesis for AWS horizontal scale.

Ship POST /api/v1/forge/launch-template with cloud-init user-data embedding genesis snapshot hash and strain card ID; first template-tagged auth pins SpreadGeneration=0 and ParentAgentID=template.
This commit is contained in:
AetherForge
2026-06-07 09:57:11 -07:00
parent 7d15888ab0
commit 7191bda6fd
12 changed files with 462 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
export interface LaunchTemplateExportRequest {
server_url: string;
build_id?: string;
strain_card_id?: string;
campaign?: string;
ami_id?: string;
instance_type?: string;
region?: string;
}
export interface LaunchTemplateExportResponse {
success: boolean;
genesis_snapshot_hash: string;
strain_card_id: string;
launch_template_json: string;
user_data_sh: string;
asg_example_json: string;
error?: string;
}
export const LAUNCH_TEMPLATE_FILES = [
{ id: 'launch-template', label: 'launch-template.json', field: 'launch_template_json' as const },
{ id: 'user-data', label: 'user-data.sh', field: 'user_data_sh' as const },
{ id: 'asg-example', label: 'asg-example.json', field: 'asg_example_json' as const },
] as const;
export function launchTemplateZipName(campaign?: string): string {
const slug = (campaign ?? '').trim().toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^-+|-+$/g, '');
return slug ? `aetherforge-launch-template-${slug}.zip` : 'aetherforge-launch-template-genesis.zip';
}
export function downloadLaunchTemplateFile(
resp: LaunchTemplateExportResponse,
file: (typeof LAUNCH_TEMPLATE_FILES)[number]['field'],
filename: string,
): void {
const content = resp[file];
if (!content) return;
const blob = new Blob([content], { type: file === 'user_data_sh' ? 'text/x-shellscript' : 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = filename;
a.click();
URL.revokeObjectURL(url);
}