Skip to content

Instantly share code, notes, and snippets.

View ensean's full-sized avatar
🌎

ensean

🌎
  • Guangzhou, China
View GitHub Profile
"""
Audit AWS Organization accounts:
1. List all active accounts (including management account)
2. Check Bedrock Claude usage via CloudWatch metrics in the past 15 months
3. Retrieve contact information for each account
4. Classify by region (Mainland China, Hong Kong, Others) and generate report
Prerequisites:
- Run this script from the AWS Organizations MANAGEMENT account
- Python 3.12+ with boto3 installed (pip install boto3)
@ensean
ensean / activate.md
Created July 6, 2026 06:26
sonnet-5 and fable-5 测试
  1. Bedrock root 账号生成 Bedrock API 短期密钥
  2. export 环境变量执行命令

export AWS_BEARER_TOKEN_BEDROCK=bedrock-api-key-YmVkcm9jay

# sonnet-5 激活
curl -X POST \
    "https://bedrock-runtime.us-east-1.amazonaws.com/model/global.anthropic.claude-sonnet-5/invoke" \
@ensean
ensean / kiro-cli-term-issues.md
Last active June 26, 2026 16:13
kiro-cli-term PTY wrapper: known issues tracker (terminal slowdown, vim paste hang, CPU drain)

kiro-cli-term PTY Wrapper: Known Issues Tracker

A collection of open issues caused by kiro-cli-term unconditionally replacing every interactive shell session via exec. All issues share the same root cause and have received no maintainer response.


Root Cause

The kiro-cli installer injects shell integration hooks into ~/.zshrc that exec-replace every interactive zsh session with kiro-cli-term (a PTY wrapper). This behavior is inherited from the Amazon Q CLI fork and has no documented opt-out.

@ensean
ensean / kiro-cli-term-fix.md
Last active June 26, 2026 15:39
kiro-cli-term PTY wrapper terminal slowdown fix (new tab delay, vim paste hang)

kiro-cli-term PTY Wrapper 导致终端卡顿的修复方案

问题描述

安装 kiro-cli 后,安装程序会在 ~/.zshrc 中注入 shell 集成 hook,在每次启动交互式 zsh 时通过 exec 无条件将 shell 进程替换为 kiro-cli-term(一个 PTY wrapper)。这会导致:

  • 新建终端 tab 需要约 5 秒(未安装时不到 1 秒)
  • vim 粘贴导致终端无响应 — 大段输入在 PTY 层被丢弃或卡住
  • 空闲时持续占用 CPU — 每个终端 session 都有一个 kiro-cli-term 进程消耗约 2% CPU
  • kill kiro-cli-term 会直接关闭整个 tab — 因为 exec 替换后它就是 shell 进程本身
@ensean
ensean / README.md
Last active June 11, 2026 09:16
query_bedrock_price

bedrock-pricing.py

查询 Amazon Bedrock 模型价格(通过 AWS Price List API),输出对齐 官网定价页

依赖

  • Python 3
  • boto3(已配置 AWS credentials)

用法

@ensean
ensean / query_dns.py
Created April 29, 2026 08:28
query dns
#!/usr/bin/env python3
"""批量查询所有 HostedZone 的 DNSQueries 指标,绕过 Metrics Insights 500 条限制"""
import boto3
from datetime import datetime, timezone, timedelta
PROFILE = "default"
REGION = "us-east-1"
PERIOD = 3600
@ensean
ensean / query-hostzone.sh
Created April 29, 2026 07:47
query-hostzone
#!/bin/bash
# 批量查询所有 HostedZone 的 DNSQueries 指标
# 绕过 Metrics Insights 500 条时间序列限制
set -e
PROFILE="default"
REGION="us-east-1"
PERIOD=3600
START_TIME=$(date -u -v-1d +%Y-%m-%dT%H:%M:%SZ)
@ensean
ensean / RTBFabric-iam.json
Created April 27, 2026 07:44
RTBFabric-iam.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "RTBFabricGatewayManagement",
"Effect": "Allow",
"Action": [
"rtbfabric:GetRequesterGateway",
"rtbfabric:UpdateRequesterGateway",
"rtbfabric:DeleteRequesterGateway",
@ensean
ensean / README.md
Last active March 26, 2026 01:50
基于Bedrock Invocation Logging 统计 Bedrock 用量

Bedrock Usage Stats

Amazon Bedrock 调用量统计与费用估算工具。从 CloudWatch Logs 中提取 Bedrock 调用日志,结合 AWS Price List API 实时定价,按用户和模型维度汇总 token 用量及费用。

功能

  • 从 CloudWatch Logs Insights 查询 Bedrock 调用记录
  • 自动获取 AWS Price List API 实时定价(支持 regional / global / 长上下文定价)
  • 按 requestId 去重,按「用户 ARN + 模型」聚合
  • 区分标准定价与长上下文定价(输入 token > 200K 时自动切换)
@ensean
ensean / go.mod
Created January 12, 2026 08:14
geplaces demo
module aws-location-suggest
go 1.23
require (
github.com/aws/aws-sdk-go-v2 v1.41.1
github.com/aws/aws-sdk-go-v2/config v1.32.7
github.com/aws/aws-sdk-go-v2/service/geoplaces v1.8.0
)