Export and backup Alibaba Cloud WAF protection configurations for WAF 3.0 and WAF 2.0 instances.
Supports both China mainland (cn-hangzhou) and international (ap-southeast-1) regions.
Output format: Excel workbooks (.xlsx) with each data module as a separate sheet.
Triggers: "WAF backup", "WAF config export", "WAF config backup", "protection config backup"
Export and backup all WAF protection configurations as Excel workbooks (.xlsx) for disaster recovery, auditing, configuration migration, or compliance review. Each data module is saved as a separate sheet within the workbook.
Run aliyun version to verify >= 3.3.3. If not installed or version too low,
run curl -fsSL https://aliyuncli.alicdn.com/setup.sh | bash to install/update,
or see references/cli-installation-guide.md for detailed instructions.
Pre-check: Aliyun CLI plugin update required
[MUST] run aliyun configure set --auto-plugin-install true to enable automatic plugin installation.
[MUST] run aliyun plugin update to ensure that any existing plugins are always up-to-date.
Pre-check: Python openpyxl library required
Excel (.xlsx) output requires the openpyxl Python library.
bash
pip3 install openpyxl
Environment Variables
No environment variables are required. All parameters are provided via CLI flags or confirmed interactively.
Authentication
Pre-check: Alibaba Cloud Credentials Required
Security Rules:
NEVER read, echo, or print AK/SK values (e.g., echo $ALIBABA_CLOUD_ACCESS_KEY_ID is FORBIDDEN)
NEVER ask the user to input AK/SK directly in the conversation or command line
NEVER use aliyun configure set with literal credential values
ONLY use aliyun configure list to check credential status
bash
aliyun configure list
Check the output for a valid profile (AK, STS, or OAuth identity).
Configure credentials outside of this session (via aliyun configure in terminal or environment variables in shell profile)
Return and re-run after aliyun configure list shows a valid profile
RAM Policy
This skill requires read-only permissions for WAF APIs. See references/ram-policies.md for the full IAM policy JSON.
Action
WAF Version
Description
waf:DescribeInstance
3.0
Query instance info
waf:DescribeDefenseResources
3.0
List defense resources
waf:DescribeDefenseResourceGroups
3.0
List resource groups
waf:DescribeDefenseTemplates
3.0
List defense templates
waf:DescribeDefenseRules
3.0
List defense rules
waf:DescribeTemplateResources
3.0
List template-resource bindings
waf:DescribeMajorProtectionBlackIps
3.0
List major protection black IPs
waf:DescribeAddresses
3.0
List address book entries
waf:DescribeInstanceInfo
2.0
Query instance info
waf:DescribeDomainNames
2.0
List domains
waf:DescribeProtectionModuleRules
2.0
List protection rules
waf:DescribeProtectionModuleStatus
2.0
Query module status
waf:DescribeProtectionModuleMode
2.0
Query module mode
waf:DescribeDomainRuleGroup
2.0
Query domain rule group
[MUST] Permission Failure Handling: When any command or API call fails due to permission errors at any point during execution, follow this process:
Read references/ram-policies.md to get the full list of permissions required by this SKILL
Use ram-permission-diagnose skill to guide the user through requesting the necessary permissions
Pause and wait until the user confirms that the required permissions have been granted
Observability (MUST follow for every aliyun command)
Upon loading this skill, generate a random session ID (32-char lowercase hex string) once for the entire session. Use it as {session-id} below.
Rule: Every aliyun CLI command that calls a cloud API MUST include the --user-agent flag.
Local utility commands (e.g. configure, plugin, version) do not support this flag and should be excluded.
Do not skip, alter the format, or omit --user-agent on any aliyun API command invocation.
Parameter Confirmation
IMPORTANT: Parameter Confirmation — Before executing any command or API call,
ALL user-customizable parameters (e.g., RegionId, instance names, CIDR blocks,
passwords, domain names, resource specifications, etc.) MUST be confirmed with the
user. Do NOT assume or use default values without explicit user approval.
Backup Domain Rule Group — describe-domain-rule-group per domain → append to sheet "domain-rule-groups"
CRITICAL: All WAF 2.0 commands MUST include --api-version 2019-09-10 and --region {region}.
The --region flag sets the API endpoint region. Without it, non-China-mainland instances (e.g., ap-southeast-1) will not be found — the API defaults to cn-hangzhou and returns the China mainland instance instead.
Phase 5: Generate Manifest
Create {BACKUP_DIR}/manifest.json containing:
backupTime — ISO 8601 timestamp
regions — object with per-region details (WAF version, instance ID, sheet counts)
totalFiles — total number of backup Excel (.xlsx) files
Success Verification
Verify manifest.json exists and is valid JSON
Compare Excel file count against totalFiles in manifest
Spot-check: open waf3-{region}.xlsx and verify "defense-resources" sheet has data rows (WAF 3.0), or open waf2-{region}.xlsx and verify "domain-names" sheet has data rows (WAF 2.0)