跳到正文
cccskills
免费在 GitHub 公开

aws-transit-gateway

Use when working with Aws Transit Gateway — aWS Transit Gateway attachment analysis, route table management, peering configuration, and network topology review. Covers TGW inventory, attachment health, route propagation, VPN connection status, and bandwidth utilization.

中文简介正在准备中。当前显示原文说明。

集成工具AWS
查看安装方法

包含的文件(1)

  • SKILL.md8.9 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

AWS Transit Gateway Skill

Analyze AWS Transit Gateway networking with parallel execution and anti-hallucination guardrails.

Relationship to other AWS skills:

  • aws-transit-gateway/ → Transit Gateway-specific analysis (attachments, routes, peering)
  • aws/ → "How to execute" (parallel patterns, throttling, output format)

CRITICAL: Parallel Execution Requirement

ALL independent operations MUST run in parallel using background jobs (&) and wait.

#!/bin/bash
export AWS_PAGER=""

for tgw_id in $tgws; do
  get_tgw_attachments "$tgw_id" &
done
wait

Helper Functions

#!/bin/bash
export AWS_PAGER=""

# List transit gateways
list_tgws() {
  aws ec2 describe-transit-gateways \
    --output text \
    --query 'TransitGateways[].[TransitGatewayId,State,OwnerId,Options.DefaultRouteTableAssociation,Options.DefaultRouteTablePropagation,Options.AmazonSideAsn]'
}

# List attachments for a TGW
list_attachments() {
  local tgw_id=$1
  aws ec2 describe-transit-gateway-attachments \
    --filters Name=transit-gateway-id,Values="$tgw_id" \
    --output text \
    --query 'TransitGatewayAttachments[].[TransitGatewayAttachmentId,ResourceType,ResourceId,State,Association.TransitGatewayRouteTableId]'
}

# List route tables for a TGW
list_route_tables() {
  local tgw_id=$1
  aws ec2 describe-transit-gateway-route-tables \
    --filters Name=transit-gateway-id,Values="$tgw_id" \
    --output text \
    --query 'TransitGatewayRouteTables[].[TransitGatewayRouteTableId,State,DefaultAssociationRouteTable,DefaultPropagationRouteTable]'
}

# Search routes in a route table
search_routes() {
  local rt_id=$1
  aws ec2 search-transit-gateway-routes \
    --transit-gateway-route-table-id "$rt_id" \
    --filters "Name=state,Values=active,blackhole" \
    --output text \
    --query 'Routes[].[DestinationCidrBlock,State,Type,TransitGatewayAttachments[0].TransitGatewayAttachmentId,TransitGatewayAttachments[0].ResourceType]'
}

# Get TGW bandwidth metrics
get_tgw_metrics() {
  local tgw_id=$1 days=${2:-7}
  local end_time start_time
  end_time=$(date -u +"%Y-%m-%dT%H:%M:%S")
  start_time=$(date -u -d "$days days ago" +"%Y-%m-%dT%H:%M:%S" 2>/dev/null || date -u -v-${days}d +"%Y-%m-%dT%H:%M:%S")
  aws cloudwatch get-metric-statistics \
    --namespace AWS/TransitGateway --metric-name BytesIn \
    --dimensions Name=TransitGateway,Value="$tgw_id" \
    --start-time "$start_time" --end-time "$end_time" \
    --period $((days * 86400)) --statistics Sum \
    --output text --query 'Datapoints[0].Sum'
}

Common Operations

1. Transit Gateway Inventory

#!/bin/bash
export AWS_PAGER=""
aws ec2 describe-transit-gateways \
  --output text \
  --query 'TransitGateways[].[TransitGatewayId,State,OwnerId,Options.AmazonSideAsn,Options.DefaultRouteTableAssociation,Options.AutoAcceptSharedAttachments]'

2. Attachment Health Overview

#!/bin/bash
export AWS_PAGER=""
TGWS=$(aws ec2 describe-transit-gateways --output text --query 'TransitGateways[].TransitGatewayId')
for tgw in $TGWS; do
  aws ec2 describe-transit-gateway-attachments \
    --filters Name=transit-gateway-id,Values="$tgw" \
    --output text \
    --query "TransitGatewayAttachments[].[\"$tgw\",TransitGatewayAttachmentId,ResourceType,ResourceId,State]" &
done
wait

3. Route Table Analysis

#!/bin/bash
export AWS_PAGER=""
TGWS=$(aws ec2 describe-transit-gateways --output text --query 'TransitGateways[].TransitGatewayId')
for tgw in $TGWS; do
  {
    RTS=$(aws ec2 describe-transit-gateway-route-tables \
      --filters Name=transit-gateway-id,Values="$tgw" \
      --output text --query 'TransitGatewayRouteTables[].TransitGatewayRouteTableId')
    for rt in $RTS; do
      aws ec2 search-transit-gateway-routes \
        --transit-gateway-route-table-id "$rt" \
        --filters "Name=state,Values=active,blackhole" \
        --output text \
        --query "Routes[].[\"$rt\",DestinationCidrBlock,State,Type,TransitGatewayAttachments[0].ResourceType]" &
    done
  }
done
wait

4. VPN Attachment Status

#!/bin/bash
export AWS_PAGER=""
aws ec2 describe-transit-gateway-attachments \
  --filters Name=resource-type,Values=vpn \
  --output text \
  --query 'TransitGatewayAttachments[].[TransitGatewayAttachmentId,TransitGatewayId,ResourceId,State]'

VPN_IDS=$(aws ec2 describe-transit-gateway-attachments \
  --filters Name=resource-type,Values=vpn \
  --output text --query 'TransitGatewayAttachments[].ResourceId')
for vpn in $VPN_IDS; do
  aws ec2 describe-vpn-connections --vpn-connection-ids "$vpn" \
    --output text \
    --query 'VpnConnections[].[VpnConnectionId,State,VgwTelemetry[].[Status,StatusMessage]]' &
done
wait

5. Bandwidth Utilization

#!/bin/bash
export AWS_PAGER=""
END=$(date -u +"%Y-%m-%dT%H:%M:%S")
START=$(date -u -d "7 days ago" +"%Y-%m-%dT%H:%M:%S" 2>/dev/null || date -u -v-7d +"%Y-%m-%dT%H:%M:%S")
TGWS=$(aws ec2 describe-transit-gateways --output text --query 'TransitGateways[].TransitGatewayId')
for tgw in $TGWS; do
  {
    bytes_in=$(aws cloudwatch get-metric-statistics \
      --namespace AWS/TransitGateway --metric-name BytesIn \
      --dimensions Name=TransitGateway,Value="$tgw" \
      --start-time "$START" --end-time "$END" \
      --period 604800 --statistics Sum \
      --output text --query 'Datapoints[0].Sum')
    bytes_out=$(aws cloudwatch get-metric-statistics \
      --namespace AWS/TransitGateway --metric-name BytesOut \
      --dimensions Name=TransitGateway,Value="$tgw" \
      --start-time "$START" --end-time "$END" \
      --period 604800 --statistics Sum \
      --output text --query 'Datapoints[0].Sum')
    printf "%s\tBytesIn:%s\tBytesOut:%s\n" "$tgw" "${bytes_in:-0}" "${bytes_out:-0}"
  } &
done
wait

Anti-Hallucination Rules

  1. Attachment types - Valid resource types: vpc, vpn, direct-connect-gateway, peering, connect. Do not fabricate other types.
  2. Blackhole routes - A blackhole route drops traffic silently. This can indicate a deleted attachment or misconfiguration. Always flag blackhole routes.
  3. search-transit-gateway-routes requires filter - The search-transit-gateway-routes command requires at least one filter. Cannot list all routes without a filter.
  4. Cross-account attachments - TGW can be shared via RAM. Attachments from other accounts show the remote account's resource ID but may not be describable from your account.
  5. Per-attachment metrics - CloudWatch TGW metrics can be filtered by TransitGatewayAttachment dimension for per-attachment bandwidth analysis.

Output Format

Present results as a structured report:

Aws Transit Gateway Report
══════════════════════════
Resources discovered: [count]

Resource       Status    Key Metric    Issues
──────────────────────────────────────────────
[name]         [ok/warn] [value]       [findings]

Summary: [total] resources | [ok] healthy | [warn] warnings | [crit] critical
Action Items: [list of prioritized findings]

Target ≤50 lines of output. Use tables for multi-resource comparisons.

Counter-Rationalizations

ShortcutCounterWhy
"I'll skip discovery and check known resources"Always run Phase 1 discovery firstResource names change, new resources appear — assumed names cause errors
"The user only asked for a quick check"Follow the full discovery → analysis flowQuick checks miss critical issues; structured analysis catches silent failures
"Default configuration is probably fine"Audit configuration explicitlyDefaults often leave logging, security, and optimization features disabled
"Metrics aren't needed for this"Always check relevant metrics when availableAPI/CLI responses show current state; metrics reveal trends and intermittent issues
"I don't have access to that"Try the command and report the actual errorAssumed permission failures prevent useful investigation; actual errors are informative

Common Pitfalls

  • Data transfer charges: TGW charges $0.02/GB for cross-AZ data transfer. This is in addition to the hourly attachment charge ($0.05/hour).
  • Route limits: Default 10,000 routes per TGW route table. Static routes have priority over propagated routes.
  • Peering limitations: TGW peering does not support route propagation. Routes must be added statically.
  • CloudWatch statistics syntax: Use spaces not commas: --statistics Average Maximum.
  • Multi-region: TGW is regional. Cross-region connectivity requires TGW peering.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Cloudflare GraphQL Analytics for zone traffic, firewall events, Workers metrics, and schema exploration. Use when querying Cloudflare analytics data or exploring the GraphQL API.

中文简介正在准备中。当前显示原文说明。

cloudthinker-ai/CloudSkills62026年4月5日 更新

Use when working with Alloydb — google AlloyDB instance analysis, query insights, columnar engine optimization, maintenance windows, and cluster health.

中文简介正在准备中。当前显示原文说明。

cloudthinker-ai/CloudSkills62026年4月5日 更新

Use when working with Aqua — aqua Security platform analysis. Covers container runtime protection, image assurance policies, compliance frameworks, vulnerability management, workload protection, and registry scanning. Use when analyzing container security posture, reviewing image compliance, investigating runtime alerts, or auditing security policies.

中文简介正在准备中。当前显示原文说明。

cloudthinker-ai/CloudSkills62026年4月5日 更新

Use when working with Bigquery — google BigQuery job analysis, slot utilization, cost analysis, dataset management, and query optimization.

中文简介正在准备中。当前显示原文说明。

cloudthinker-ai/CloudSkills62026年4月5日 更新

Use when working with Cassandra — apache Cassandra keyspace analysis, compaction strategies, repair status, nodetool operations, and cluster health monitoring.

中文简介正在准备中。当前显示原文说明。

cloudthinker-ai/CloudSkills62026年4月5日 更新

Use when working with Checkov — checkov infrastructure-as-code security scanning. Covers Terraform, CloudFormation, Kubernetes, and Dockerfile scanning, policy management, custom checks, compliance frameworks, and suppression management. Use when scanning IaC for security misconfigurations, evaluating compliance, managing custom policies, or reviewing scan results.

中文简介正在准备中。当前显示原文说明。

cloudthinker-ai/CloudSkills62026年4月5日 更新

查看 cloudthinker-ai 的全部技能

报告此技能的问题