🎁 Get the FREE AI Skills Starter GuideSubscribe →
BytesAgainBytesAgain
🦀 ClawHub

Alibabacloud Sas Multiaccount Manage

by @sdk-team

Manage multiple Alibaba Cloud accounts and batch-export Security Center (SAS) baseline and vulnerability reports via the aliyun CLI and Python scripts. Suppo...

Versionv0.0.1
💡 Examples

#### Refresh account list

Fetch the latest account list from Alibaba Cloud resource directory and write to accounts.json. Existing enable states are preserved; new accounts are enabled by default.

.venv/bin/python accounts.py refresh

#### List all accounts

.venv/bin/python accounts.py list

Sample output:

1225574417218097    cwx                     [enabled]
1234567890123456    prod-account            [disabled]

#### Search accounts

Fuzzy-search by DisplayName, returning AccountId and enable status.

.venv/bin/python accounts.py search cwx
.venv/bin/python accounts.py search prod

#### Enable / disable accounts

Control whether an account participates in subsequent batch exports.

.venv/bin/python accounts.py enable 1225574417218097
.venv/bin/python accounts.py disable 1234567890123456

accounts.json Structure

[
  {
    "AccountId": "1225574417218097",
    "DisplayName": "cwx",
    "FolderId": "r-1Q4pqB",
    "IsMaAccount": "NO",
    "SasVersion": "0",
    "enable": true
  }
]


⚙️ Configuration

  • accounts.py refresh has been executed and account enable/disable configuration is complete.
  • aliyun CLI is configured with valid credentials and has SAS export-record and describe-export-info permissions.
  • Accounts must have Security Center purchased (free edition accounts are skipped automatically).
  • Export cloud platform configuration check results (CSPM)

    Export baselineCspm results for all enabled accounts and merge into baseline-cspm-merged-{date}.xlsx.

    # Export for all enabled accounts
    .venv/bin/python baseline.py export-cspm

    Export for one specific account

    .venv/bin/python baseline.py export-cspm --account-id 1225574417218097

    Export system baseline risk list

    Export exportHcWarning risk list (high/medium/low, all statuses) for all enabled accounts and merge into system-warning-merged-{date}.xlsx.

    # Export for all enabled accounts
    .venv/bin/python baseline.py export-system-warning

    Export for one specific account

    .venv/bin/python baseline.py export-system-warning --account-id 1225574417218097

    Output Files

    | File | Description | |------|------| | baseline-cspm-merged-{date}.xlsx | Merged cloud platform configuration check results, including “Resource Directory Account” column | | system-warning-merged-{date}.xlsx | Merged system baseline risk list, including “Resource Directory Account” column |

    Error Handling

    | Scenario | Behavior | |------|------| | FreeVersionNotPermit | Silently skip this account and continue others | | NoPermission / Forbidden | Silently skip this account | | Export failed (server-side error) | Print [failed] message and continue with other accounts | | All accounts skipped | Print message and exit without output file |


    📋 Tips & Best Practices

  • Scripts must run in a virtual environment. Examples use .venv/bin/python; replace with your actual virtual environment path.
  • Manage aliyun CLI credentials with aliyun configure; do not hardcode AK/SK.
  • SAS API supports only two endpoints: cn-shanghai (China mainland) and ap-southeast-1 (outside China mainland).
  • View on ClawHub
    TERMINAL
    clawhub install alibabacloud-sas-multiaccount-manage

    🧪 Use this skill with your agent

    Most visitors already have an agent. Pick your environment, install or copy the workflow, then run the smoke-test prompt above.

    🔍 Can't find the right skill?

    Search 60,000+ AI agent skills — free, no login needed.

    Search Skills →