tokenkey-stage0-edge-lightsail-ip-rotation
- Repo stars 0
- Author updated Live
- Author repo sub2api
- Domain
- Other
- Compatible agents
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- Trust score
- 88 / 100 · community maintained
- Author / version / license
- @youxuanxue · no license declared
- Token usage
- Lean
- Setup complexity
- Plug-and-play
- External API key
- Not required
- Operating systems
- Unspecified (assume cross-platform)
- Runtime requirements
- No special requirements
- Permissions
-
- Read-only
- Write / modify
- Network behavior
- External requests
- Install commands
- 26 variants
Profile is derived at build time from SKILL.md and install vectors. Subject to drift from author intent.
Heads up: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: tokenkey-stage0-edge-lightsail-ip-rotation
description: >- 适用于通过 deploy-edge-lightsail-stage0.yml 部署的 Lightsail Edge(与 EC2 EIP 路径不通用)。 EC2 路径见 tokenkey-…
category: other
runtime: no special runtime
---
# tokenkey-stage0-edge-lightsail-ip-rotation output preview
## PART A: Task fit
- Use case: >- 适用于通过 deploy-edge-lightsail-stage0.yml 部署的 Lightsail Edge(与 EC2 EIP 路径不通用)。 EC2 路径见 tokenkey-stage0-edge-ip-rotation。Lightsail 路径没有 CloudFormation,所以没有 drift IMPORT 这一节。 makes outbound network calls. Works with Claude Code, Cursor, Cline and 23 more..
- Inputs: target material, constraints, expected output, and acceptance criteria.
- Evidence boundary: follow “确定性基线 / 调用参数 / 0) 前置” and do not present inference as author intent.
## PART B: Execution result
- **01** The card summarizes the use case; runtime output centers on “>- 适用于通过 deploy-edge-lightsail-stage0.yml 部署的 Lightsail Edge(与 EC2 EIP 路径不通用)。 EC2 路径见 tokenkey-stage0-edge-ip-rotation。Lightsail 路径没有 CloudFormation,所以没有 drift IMPORT 这一节。 makes outbound network calls. Works with Claude Code, Cursor, Cline and 23 more.”.
- **02** When the source has headings, the agent prioritizes “确定性基线 / 调用参数 / 0) 前置” so the result follows the author’s structure.
- **03** Typical output includes task judgment, concrete steps, required commands or file edits, validation, and follow-up options.
- **04** Risk context follows the fingerprint: read files, write/modify files; may access external network resources; usually needs no extra API key.
## Running Rules
- read files, write/modify files; may access external network resources; usually needs no extra API key.
- Validate with a small sample before expanding scope.
- Return the result, validation criteria, and next iteration options. The source mentions slash commands such as `/tokenkey-stage0-edge-lightsail-ip-rotation`, `/tokenkey`; use them first when your agent supports command triggers.
Name target files or source material, expected output, forbidden changes, and whether network or shell access is allowed. Permission fingerprint: read files, write/modify files.
Start with a small task and check whether the result follows “确定性基线 / 调用参数 / 0) 前置”. Inspect diffs, logs, previews, or tests before expanding scope.
Confirm the final output includes a concrete result, evidence, and next action. If it stays generic, tighten inputs, boundaries, and acceptance criteria.
---
name: tokenkey-stage0-edge-lightsail-ip-rotation
description: >- 适用于通过 deploy-edge-lightsail-stage0.yml 部署的 Lightsail Edge(与 EC2 EIP 路径不通用)。 EC2 路径见 tokenkey-…
category: other
source: youxuanxue/sub2api
---
# tokenkey-stage0-edge-lightsail-ip-rotation
## When to use
- >- 适用于通过 deploy-edge-lightsail-stage0.yml 部署的 Lightsail Edge(与 EC2 EIP 路径不通用)。 EC2 路径见 tokenkey-stage0-edge-ip-rotatio…
- Use it when the task has clear inputs, repeatable steps, and validation criteria.
## What to provide
- Target material, scope, expected result, and forbidden changes.
- Whether network, commands, file writes, or external services are allowed.
## Execution rules
- Organize steps around “确定性基线 / 调用参数 / 0) 前置” and keep inference separate from source facts.
- read files, write/modify files; may access external network resources; usually needs no extra API key.
- Validate with a small sample before expanding the task.
## Output requirements
- Return the deliverable, key evidence, validation method, and next action.
- Mark missing information as unknown; do not invent commands, platforms, or dependencies. The author source anchors workflow facts; repository files anchor sources and commands; Fluxly only adds fit, limitations, and quality judgment.
skill "tokenkey-stage0-edge-lightsail-ip-rotation" {
input -> user goal + target files + boundaries + acceptance criteria
context -> 确定性基线 / 调用参数 / 0) 前置
rules -> SKILL.md triggers / order / output contract
runtime -> no special runtime | read files, write/modify files | may access external network resources
guardrails -> usually needs no extra API key + small-sample validation + diff/log review
output -> copyable result + checklist + next iteration
} TokenKey:Lightsail Edge 静态 IP 轮换(污染快速恢复)
适用于通过 deploy-edge-lightsail-stage0.yml 部署的 Lightsail Edge(与 EC2 EIP 路径不通用)。
EC2 路径见 tokenkey-stage0-edge-ip-rotation。Lightsail 路径没有 CloudFormation,所以没有 drift IMPORT 这一节。
确定性基线
| 步骤 | 类型 | 承载 |
|---|---|---|
| 解析 edge → region / instance / static IP name / domain | 机械 | ops/lightsail/rotate-static-ip.sh(jq 读 edge-targets-lightsail.json) |
| 计划输出(dry run) | 机械 | 同上脚本默认行为(无 --apply) |
| 三步 swap(allocate → detach → attach → release) | 机械 | 同上脚本 --apply |
| 候选 IP 撞 exclusion registry 时重试 | 机械 | 同上脚本(默认最多 5 次) |
| 释放旧 IP 后写入 exclusion registry | 机械 | deploy/aws/stage0/record-polluted-ip.py(由 rotate 脚本调用) |
| 把 ssm_prefix/public_ip 改成新 IP | 机械 | 同上脚本 |
| Porkbun DNS A 记录更新 | 真判断 | prompt(人工操作 Porkbun) |
| 外部干净出口验证 | 真判断 | prompt(选择哪个 observation host 取决于运营当时态势) |
调用参数
/tokenkey-stage0-edge-lightsail-ip-rotation edge_id=<id> [step=plan|swap|verify|all]
step=plan(默认)—ops/lightsail/rotate-static-ip.sh <edge_id>打印计划,无 AWS 变更。step=swap—ops/lightsail/rotate-static-ip.sh <edge_id> --apply,销毁旧 IP。step=verify— 用上一步产生的 new_ip 做 SNI 验证 + smoke。step=all— 串起 plan → 等用户确认 → swap → 提示 DNS → verify。
0) 前置
git fetch origin main && git checkout main && git pull --ff-only
bash scripts/preflight.sh
aws sts get-caller-identity # 确认目标账户
确认 edge 已经在 deploy/aws/lightsail/edge-targets-lightsail.json 里 deployable=true,且 ssm_prefix/public_ip 与 aws lightsail get-static-ip 报告的 ipAddress 一致;不一致先用 aws ssm put-parameter 把 SSM 修对,再开始轮换。
Adopt 命名:instance_name / static_ip_name 以 matrix 为准(如 us2 → tokenkey-edge-us-va1-ls / StaticIp-2),不要假设 tokenkey-edge-<edge_id>-ls-ip。
1) Plan
bash ops/lightsail/rotate-static-ip.sh <edge_id>
输出形如:
=== Lightsail Edge IP rotation plan ===
edge_id : uk1
lightsail_region : eu-west-2
instance_name : tokenkey-edge-uk1-ls
domain : api-uk1.tokenkey.dev
old_static_ip_name: tokenkey-edge-uk1-ls-ip
old_ip : 18.x.x.x
new_static_ip_name: tokenkey-edge-uk1-ls-ip-rot-<ts>
ssm_prefix : /tokenkey/lightsail/uk1
用户确认 old_ip 确实被污染,再进入 swap。
2) Swap
bash ops/lightsail/rotate-static-ip.sh <edge_id> --apply --reason 'upstream-api-risk-block-YYYY-MM-DD'
脚本顺序:
aws lightsail allocate-static-ip新名字(若候选 IP 已在edge-polluted-ips.json则 release 并重试)aws lightsail detach-static-ip旧名字aws lightsail attach-static-ip新名字到 instanceaws lightsail get-static-ip读出 NEW ipaws ssm put-parameter写${ssm_prefix}/public_ip = <new_ip>aws lightsail release-static-ip旧名字(该 IP 进入 AWS pool)record-polluted-ip.py append把旧 IP 写入 exclusion registry(记得 commit JSON + 跑scripts/edge-ip-status.sh --check)
输出最后会打印 NEW ip 和 DNS / smoke 提示。
同账户 IP 池注意:Lightsail 在同账户同 region 复用 IP 池。rotate 脚本会查
edge-polluted-ips.json并在候选 IP 已登记时自动重试;释放的旧 IP 也会自动 append 进 registry,避免再次撞回。
3) DNS 与 Caddy
去 Porkbun 把 api-<edge_id>.tokenkey.dev 的 A 记录改成 NEW ip。等 dig +short @1.1.1.1 指向 NEW ip(常见约 1 分钟)。
IP 变更后重启 Caddy 以刷新 ACME / 绑定:
bash ops/stage0/verify-edge-lightsail-network.sh <edge_id> --renew-cert
4) Verify(独立观察点)
不要用刚改 DNS 的本地,去 tk_post_deploy_smoke.sh 或者任意干净出口:
curl -sS --resolve api-<edge_id>.tokenkey.dev:443:<new_ip> \
https://api-<edge_id>.tokenkey.dev/health
应当 200。然后跑一次 workflow smoke:
CONFIRM=$(python3 deploy/aws/lightsail/resolve-edge-lightsail-target.py \
--edge-id <edge_id> | awk -F= '/^instance_name=/{print $2}')
gh workflow run deploy-edge-lightsail-stage0.yml \
-f edge_id=<edge_id> -f operation=smoke \
-f confirm_instance="$CONFIRM"
gh run watch --exit-status $(gh run list -w deploy-edge-lightsail-stage0.yml -L 1 --json databaseId -q '.[0].databaseId')
最后用 tokenkey-online-traffic-profile 或 tokenkey-online-log-troubleshooting 看 5 分钟内 Anthropic upstream 是否回到正常 2xx 比例。
5) Acceptance(机械化输出)
edge_id : <id>
old_ip : <old_ip>
new_ip : <new_ip>
domain : api-<id>.tokenkey.dev
verify : curl <new_ip>:443 → 200; smoke run → green
6) 失败模式
| 现象 | 解读 | 应对 |
|---|---|---|
allocate-static-ip 报 ServiceQuotaExceededException |
该 region 还有未释放的 Static IP(默认 quota=5) | aws lightsail get-static-ips 看清单,释放无主的 |
attach-static-ip 报 OperationFailureException |
instance 处于非 running 状态 |
aws lightsail get-instance 查 state,等到 running 再重试 |
| 切完 NEW ip 仍被污染 | 撞回同 region 老 IP,或同 ASN 被整段封 | 立刻重跑一次 swap;如再次撞回考虑跨 region 增设新 edge |
| DNS 没改但 smoke 通过 | 漏掉 verify 的 --resolve |
必须显式 --resolve 强制 SNI 到新 IP |
Decide Fit First
Design Intent
How To Use It
Boundaries And Review