#!/usr/bin/env python """Download markdown files with AWS managed ConfigRule info and convert to JSON. The first markdown file is read to obtain the names of markdown files for all the AWS managed config rules. Then each of those markdown files are read and info is extracted with the final results written to a JSON file. The JSON output will look as follows: { "ManagedRules": [ { "ACCESS_KEYS_ROTATED": { "AWS Region": "All supported AWS regions", "Parameters": [ { "Default": "90", "Name": "maxAccessKeyAgeType", "Optional": false, "Type": "intDefault" } ], "Trigger type": "Periodic" }, }, ... ] } """ import json import re import sys import requests MANAGED_RULES_OUTPUT_FILENAME = "../moto/config/resources/aws_managed_rules.json" AWS_MARKDOWN_URL_START = "https://raw.githubusercontent.com/awsdocs/aws-config-developer-guide/main/doc_source/" LIST_OF_MARKDOWNS_URL = "managed-rules-by-aws-config.md" def managed_rule_info(lines): """Return dict of qualifiers/rules extracted from a markdown file.""" rule_info = {} label_pattern = re.compile(r"(?:\*\*)(?P