# Generate CloudFormation templates and copy to templates directory
generate-cfn:
    @echo "Synthesizing CDK stacks..."
    npx cdk synth --strict
    @echo "Copying CloudFormation templates to prefect_aws/templates/ecs/..."
    cp cdk.out/PrefectEcsServiceStack.template.json ../prefect_aws/templates/ecs/service.json
    cp cdk.out/PrefectEcsEventsStack.template.json ../prefect_aws/templates/ecs/events-only.json
    @echo "CloudFormation templates generated and copied successfully!"

# Clean CDK output directory
clean:
    @echo "Cleaning CDK output directory..."
    rm -rf cdk.out/
    @echo "Clean complete!"

# Generate templates with clean first
generate-clean: clean generate-cfn

# Validate generated CloudFormation templates
validate-cfn:
    @echo "Validating CloudFormation templates..."
    aws cloudformation validate-template --template-body file://cdk.out/PrefectEcsServiceStack.template.json
    aws cloudformation validate-template --template-body file://cdk.out/PrefectEcsEventsStack.template.json
    @echo "CloudFormation templates validated successfully!"


# Run tests for CDK stacks
test:
    uv run pytest
