INNER CODE UNIT · Python

is_cloudformation_template

awslabs/awsome-distributed-ai · .github/scripts/stage-template-publish.py:47

def is_cloudformation_template(path: Path) -> bool:
    try:
        document = load_yaml(path)
    except yaml.YAMLError as exc:
        raise ValueError(f"{path}: invalid YAML: {exc}") from exc
    return isinstance(document, dict) and isinstance(document.get("Resources"), dict)


def normalize_key(key: str) -> str:
    key = key.strip().lstrip("/")
    if not key:
        raise ValueError("empty S3 key")
    if ".." in Path(key).parts:
        raise ValueError(f"destination key must not contain '..': {key}")
    if not S3_KEY_RE.match(key):
        raise ValueError(f"destination key contains unsupported characters: {key}")
    return key

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…