"""Terraform composer for NIKAME."""
from __future__ import annotations

from nikame.blueprint.engine import Blueprint
from nikame.composers.terraform.aws import AWSTerraformProvider


def generate_terraform(blueprint: Blueprint) -> dict[str, str]:
    """Generate Terraform files based on the blueprint cloud target."""
    cloud = blueprint.modules[0].ctx.cloud if blueprint.modules else "aws"

    if cloud == "aws":
        provider = AWSTerraformProvider()
    else:
        # For GCP/Azure, we raise an error until providers are implemented
        # This prevents silent incorrect (AWS) generation.
        from nikame.exceptions import NikameNotImplementedError
        raise NikameNotImplementedError(
            f"Terraform generation for '{cloud}' is not yet implemented. "
            "Currently only 'aws' is supported."
        )

    return provider.generate(blueprint)
