Add ssm_document spread lane for owned EC2 via SSM Run Command.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
This commit is contained in:
60
server/web/src/components/Emberwake/SSMSpreadPanel.tsx
Normal file
60
server/web/src/components/Emberwake/SSMSpreadPanel.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
import { api } from '../../api/client';
|
||||
import { spreadTechniqueDocUrl } from '../../help/spreadTechniques';
|
||||
|
||||
export interface SSMSpreadPanelProps {
|
||||
serverBase: string;
|
||||
buildId?: string;
|
||||
campaign?: string;
|
||||
}
|
||||
|
||||
function CopyBlock({ label, text }: { label: string; text: string }) {
|
||||
const [ok, setOk] = useState(false);
|
||||
return (
|
||||
<div className="ssm-spread-copy-block">
|
||||
<div className="ssm-spread-copy-head">
|
||||
<strong>{label}</strong>
|
||||
<button type="button" className="btn btn-outline btn-sm" onClick={() => void navigator.clipboard?.writeText(text).then(() => { setOk(true); setTimeout(() => setOk(false), 1500); })}>
|
||||
{ok ? 'Copied' : 'Copy'}
|
||||
</button>
|
||||
</div>
|
||||
<pre className="ssm-spread-pre">{text}</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function SSMSpreadPanel({ serverBase, buildId = '', campaign = '' }: SSMSpreadPanelProps) {
|
||||
const [awsCli, setAwsCli] = useState('aws');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [err, setErr] = useState('');
|
||||
const [bundle, setBundle] = useState<Awaited<ReturnType<typeof api.fetchSSMSpreadBundle>>['bundle'] | null>(null);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setErr(''); setBusy(true);
|
||||
try {
|
||||
const res = await api.fetchSSMSpreadBundle({ server_url: serverBase, build_id: buildId.trim(), campaign: campaign.trim(), aws_cli_path: awsCli.trim(), platform: 'linux' });
|
||||
setBundle(res.bundle);
|
||||
} catch (e) {
|
||||
setErr(e instanceof Error ? e.message : String(e)); setBundle(null);
|
||||
} finally { setBusy(false); }
|
||||
}, [serverBase, buildId, campaign, awsCli]);
|
||||
|
||||
return (
|
||||
<div className="ssm-spread-panel">
|
||||
<p className="emberwake-section-desc">Owned EC2 — SSM Run Command curls erasure manifest/shards from your command deck. <a href={spreadTechniqueDocUrl('ssm-document')} target="_blank" rel="noreferrer">Playbook</a></p>
|
||||
<div className="ssm-spread-controls">
|
||||
<label className="label" htmlFor="ssm-aws-cli">AWS CLI path (optional)</label>
|
||||
<input id="ssm-aws-cli" className="input mono" value={awsCli} onChange={(e) => setAwsCli(e.target.value)} />
|
||||
<button type="button" className="btn btn-primary" disabled={busy || !serverBase.trim()} onClick={() => void load()}>{busy ? 'Generating…' : 'Generate SSM bundle'}</button>
|
||||
</div>
|
||||
{err ? <p className="form-error">{err}</p> : null}
|
||||
{bundle ? (
|
||||
<div className="ssm-spread-results">
|
||||
<CopyBlock label="SSM document JSON" text={bundle.document} />
|
||||
<CopyBlock label="Run Command invocation" text={bundle.run_command} />
|
||||
<CopyBlock label="create-document.sh" text={bundle.create_document_cli} />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user