icdev 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- args/agent_config.yaml +113 -0
- args/audit_regimes/cisa_sbd.json +381 -0
- args/audit_regimes/cmmc_l2.json +906 -0
- args/audit_regimes/dod_cssp.json +393 -0
- args/audit_regimes/dodi_5000_87.json +297 -0
- args/audit_regimes/fedramp_moderate.json +650 -0
- args/audit_regimes/ieee_1012.json +373 -0
- args/audit_regimes/nist_800_171.json +624 -0
- args/audit_regimes/nist_800_53.json +907 -0
- args/cloudforge_blueprints/aws_commercial.yaml +29 -0
- args/cloudforge_blueprints/aws_govcloud_il4.yaml +34 -0
- args/cloudforge_blueprints/aws_govcloud_il5.yaml +38 -0
- args/cloudforge_blueprints/azure_commercial.yaml +28 -0
- args/cloudforge_blueprints/azure_gov_il4.yaml +32 -0
- args/cloudforge_blueprints/azure_gov_il5.yaml +36 -0
- args/cloudforge_blueprints/gcp_commercial.yaml +28 -0
- args/cloudforge_blueprints/oci_commercial.yaml +28 -0
- args/cloudforge_config.yaml +231 -0
- args/cloudforge_runbook_templates/backup_verify.yaml +98 -0
- args/cloudforge_runbook_templates/dr_failover.yaml +107 -0
- args/cloudforge_runbook_templates/health_check.yaml +97 -0
- args/cloudforge_runbook_templates/incident_response.yaml +101 -0
- args/cloudforge_runbook_templates/migration_cutover.yaml +105 -0
- args/cloudforge_runbook_templates/patch_rollout.yaml +92 -0
- args/cloudforge_runbook_templates/zone_provision.yaml +93 -0
- args/code_pattern_config.yaml +151 -0
- args/code_quality_config.yaml +47 -0
- args/compliance_config.yaml +17 -0
- args/control_inheritance.yaml +177 -0
- args/csp_mcp_config.yaml +41 -0
- args/cui_markings.yaml +35 -0
- args/databridge_config.yaml +232 -0
- args/db_config.yaml +116 -0
- args/decision_tables/agent_trust_decision.yaml +143 -0
- args/decision_tables/ato_boundary_impact.yaml +132 -0
- args/decision_tables/deployment_approval.yaml +152 -0
- args/degradation_matrix.yaml +163 -0
- args/devsecops_config.yaml +286 -0
- args/endpoint_security_config.yaml +207 -0
- args/exit_criteria.yaml +102 -0
- args/feature_flags.yaml +235 -0
- args/file_access_tiers.yaml +88 -0
- args/forge_studio/blueprint_config.yaml +27 -0
- args/forge_studio/component_catalog.json +411 -0
- args/forge_studio/workflow_templates.yaml +103 -0
- args/govcon_config.yaml +41 -0
- args/harness_config.yaml +67 -0
- args/innovation_config.yaml +321 -0
- args/knowledge_graph_config.yaml +113 -0
- args/llm_config.yaml +222 -0
- args/marketplace_config.yaml +260 -0
- args/monitoring_config.yaml +127 -0
- args/mosa_config.yaml +190 -0
- args/observability_tracing_config.yaml +170 -0
- args/owasp_agentic_config.yaml +171 -0
- args/pipeline_gates.yaml +197 -0
- args/project_defaults.yaml +235 -0
- args/prompt_chains.yaml +163 -0
- args/rag_config.yaml +167 -0
- args/research_config.yaml +89 -0
- args/resilience_config.yaml +197 -0
- args/ricoas_config.yaml +191 -0
- args/security_gates.yaml +763 -0
- args/storage_config.yaml +63 -0
- args/writeguard_config.yaml +131 -0
- args/zta_config.yaml +247 -0
- context/__init__.py +6 -0
- context/agent/__init__.py +6 -0
- context/agent/response_schemas/__init__.py +6 -0
- context/agent/response_schemas/debate_position.json +46 -0
- context/agent/response_schemas/fitness_scorecard.json +74 -0
- context/agent/response_schemas/review_decision.json +39 -0
- context/agent/response_schemas/task_decomposition.json +82 -0
- context/agent/response_schemas/veto_decision.json +40 -0
- context/agentic/__init__.py +6 -0
- context/agentic/architecture_patterns.md +269 -0
- context/agentic/capability_registry.yaml +223 -0
- context/agentic/csp_integration.md +30 -0
- context/agentic/csp_mcp_registry.yaml +280 -0
- context/agentic/fitness_rubric.md +56 -0
- context/agentic/governance_baseline.md +205 -0
- context/ci/__init__.py +6 -0
- context/ci/worktree_templates.json +44 -0
- context/cloud/__init__.py +6 -0
- context/cloud/csp_service_registry.json +739 -0
- context/compliance/__init__.py +6 -0
- context/compliance/ai_rmf_crosswalk.yaml +226 -0
- context/compliance/atlas_mitigations.json +293 -0
- context/compliance/atlas_techniques.json +833 -0
- context/compliance/cisa_sbd_requirements.json +477 -0
- context/compliance/cjis_security_policy.json +522 -0
- context/compliance/cmmc_practices.json +2494 -0
- context/compliance/cmmc_report_template.md +142 -0
- context/compliance/cnssi_1253_overlay.json +109 -0
- context/compliance/control_crosswalk.json +1914 -0
- context/compliance/control_families/__init__.py +6 -0
- context/compliance/csp_certifications.json +251 -0
- context/compliance/cssp_report_template.md +193 -0
- context/compliance/cui_templates/__init__.py +6 -0
- context/compliance/cui_templates/banner_block.txt +4 -0
- context/compliance/cui_templates/code_header.txt +8 -0
- context/compliance/cui_templates/document_template.md +35 -0
- context/compliance/data_type_framework_map.json +321 -0
- context/compliance/data_type_registry.json +147 -0
- context/compliance/dod_cssp_8530.json +463 -0
- context/compliance/eu_ai_act_annex_iii.json +108 -0
- context/compliance/export_templates/__init__.py +6 -0
- context/compliance/export_templates/emass_controls.csv.j2 +4 -0
- context/compliance/export_templates/evidence_package.md.j2 +39 -0
- context/compliance/export_templates/executive_summary.md.j2 +55 -0
- context/compliance/export_templates/poam_tracking.csv.j2 +4 -0
- context/compliance/fedramp_20x_ksi_schemas.json +133 -0
- context/compliance/fedramp_high_baseline.json +4370 -0
- context/compliance/fedramp_moderate_baseline.json +2183 -0
- context/compliance/fedramp_report_template.md +181 -0
- context/compliance/fips_200_areas.json +362 -0
- context/compliance/gao_ai_accountability.json +262 -0
- context/compliance/hipaa_security_rule.json +720 -0
- context/compliance/hitrust_csf_v11.json +930 -0
- context/compliance/impact_level_profiles.json +251 -0
- context/compliance/incident_response_template.md +1110 -0
- context/compliance/iso27001_2022_controls.json +750 -0
- context/compliance/iso27001_nist_bridge.json +382 -0
- context/compliance/iso42001_controls.json +254 -0
- context/compliance/ivv_checklist_template.md +80 -0
- context/compliance/ivv_report_template.md +116 -0
- context/compliance/ivv_requirements.json +372 -0
- context/compliance/mosa_crosswalk.json +327 -0
- context/compliance/mosa_framework.json +250 -0
- context/compliance/narrative_templates/AC.md.j2 +101 -0
- context/compliance/narrative_templates/AU.md.j2 +106 -0
- context/compliance/narrative_templates/IA.md.j2 +104 -0
- context/compliance/narrative_templates/SC.md.j2 +102 -0
- context/compliance/narrative_templates/SI.md.j2 +111 -0
- context/compliance/narrative_templates/__init__.py +6 -0
- context/compliance/narrative_templates/default.md.j2 +50 -0
- context/compliance/narrative_templates/executive_summary.j2 +27 -0
- context/compliance/narrative_templates/poam_milestone.j2 +19 -0
- context/compliance/narrative_templates/ssp_section.j2 +11 -0
- context/compliance/nist_800_171_controls.json +1552 -0
- context/compliance/nist_800_207_crosswalk.json +399 -0
- context/compliance/nist_800_207_zta.json +258 -0
- context/compliance/nist_800_53.json +324 -0
- context/compliance/nist_ai_600_1_genai.json +326 -0
- context/compliance/nist_ai_rmf.json +206 -0
- context/compliance/nist_sp_800_60_types.json +1667 -0
- context/compliance/omb_m25_21_high_impact_ai.json +248 -0
- context/compliance/omb_m26_04_unbiased_ai.json +262 -0
- context/compliance/owasp_agentic_asi.json +133 -0
- context/compliance/owasp_agentic_threats.json +285 -0
- context/compliance/owasp_llm_top10.json +274 -0
- context/compliance/pci_dss_v4.json +510 -0
- context/compliance/poam_template.md +117 -0
- context/compliance/safeai_controls.json +512 -0
- context/compliance/sbd_report_template.md +77 -0
- context/compliance/siem_config_templates/__init__.py +6 -0
- context/compliance/siem_config_templates/filebeat.yml +213 -0
- context/compliance/siem_config_templates/log_sources.json +208 -0
- context/compliance/soc2_trust_criteria.json +661 -0
- context/compliance/ssp_template.md +432 -0
- context/compliance/stig_templates/__init__.py +6 -0
- context/compliance/stig_templates/webapp_stig.json +139 -0
- context/compliance/xai_requirements.json +108 -0
- context/dashboard/__init__.py +6 -0
- context/dashboard/nlq_examples.json +50 -0
- context/dashboard/schema_descriptions.json +23 -0
- context/icdev_methodology.md +100 -0
- context/integration/__init__.py +6 -0
- context/integration/approval_workflows.json +32 -0
- context/integration/gitlab_field_mappings.json +33 -0
- context/integration/jira_field_mappings.json +32 -0
- context/integration/reqif_export_schema.json +23 -0
- context/integration/servicenow_field_mappings.json +22 -0
- context/languages/__init__.py +6 -0
- context/languages/framework_patterns.json +205 -0
- context/languages/language_registry.json +279 -0
- context/llm/__init__.py +6 -0
- context/llm/example_provider.py +89 -0
- context/marketplace/assets/writeguard-core.yaml +100 -0
- context/marketplace/assets/writeguard-govcon.yaml +45 -0
- context/marketplace/assets/writeguard-style-guides.yaml +44 -0
- context/mbse/__init__.py +6 -0
- context/mbse/des_report_template.md +162 -0
- context/mbse/des_requirements.json +411 -0
- context/mbse/digital_thread_patterns.json +403 -0
- context/mbse/reqif_schema.json +280 -0
- context/mbse/sysml_element_types.json +432 -0
- context/oscal/NIST_SP-800-53_rev5_catalog.json +254987 -0
- context/oscal/README.md +43 -0
- context/patterns/__init__.py +6 -0
- context/profiles/__init__.py +6 -0
- context/profiles/dod_baseline_v1.yaml +145 -0
- context/profiles/fedramp_baseline_v1.yaml +143 -0
- context/profiles/financial_baseline_v1.yaml +142 -0
- context/profiles/healthcare_baseline_v1.yaml +135 -0
- context/profiles/law_enforcement_v1.yaml +129 -0
- context/profiles/startup_v1.yaml +134 -0
- context/rag/source_mappings.json +42 -0
- context/requirements/__init__.py +6 -0
- context/requirements/ambiguity_patterns.json +97 -0
- context/requirements/boundary_impact_rules.json +123 -0
- context/requirements/default_constitutions.json +67 -0
- context/requirements/document_extraction_rules.json +58 -0
- context/requirements/gap_patterns.json +108 -0
- context/requirements/readiness_rubric.json +78 -0
- context/requirements/red_alternative_patterns.json +210 -0
- context/requirements/safe_templates.json +72 -0
- context/requirements/spec_quality_checklist.json +122 -0
- context/research/regulatory_registry.json +114 -0
- context/research/verticals/cybersecurity.json +127 -0
- context/research/verticals/defense.json +104 -0
- context/research/verticals/fintech.json +125 -0
- context/research/verticals/healthcare.json +118 -0
- context/research/verticals/logistics.json +117 -0
- context/research/verticals/trading.json +145 -0
- context/simulation/__init__.py +6 -0
- context/simulation/architecture_patterns.json +36 -0
- context/simulation/coa_templates.json +38 -0
- context/simulation/cost_models.json +23 -0
- context/simulation/risk_categories.json +46 -0
- context/supply_chain/__init__.py +6 -0
- context/supply_chain/isa_templates.json +129 -0
- context/supply_chain/nist_800_161_controls.json +247 -0
- context/supply_chain/scrm_risk_matrix.json +147 -0
- context/templates/__init__.py +6 -0
- context/templates/ansible/__init__.py +6 -0
- context/templates/ansible/playbooks/__init__.py +6 -0
- context/templates/ansible/roles/__init__.py +6 -0
- context/templates/gitlab_ci/__init__.py +6 -0
- context/templates/grafana/__init__.py +6 -0
- context/templates/kubernetes/__init__.py +6 -0
- context/templates/project/__init__.py +6 -0
- context/templates/project/api/__init__.py +6 -0
- context/templates/project/cli/__init__.py +6 -0
- context/templates/project/data_pipeline/__init__.py +6 -0
- context/templates/project/iac/__init__.py +6 -0
- context/templates/project/javascript_frontend/__init__.py +6 -0
- context/templates/project/javascript_frontend/src/__init__.py +6 -0
- context/templates/project/javascript_frontend/tests/__init__.py +6 -0
- context/templates/project/microservice/__init__.py +6 -0
- context/templates/project/python_backend/__init__.py +6 -0
- context/templates/project/python_backend/src/__init__.py +6 -0
- context/templates/project/python_backend/tests/__init__.py +6 -0
- context/templates/project/python_backend/tests/features/__init__.py +6 -0
- context/templates/project/python_backend/tests/steps/__init__.py +6 -0
- context/templates/terraform/__init__.py +6 -0
- context/templates/terraform/govcloud_base/__init__.py +6 -0
- context/templates/terraform/modules/__init__.py +6 -0
- context/tone/__init__.py +6 -0
- context/writing/grammar_rules/common_errors.json +306 -0
- context/writing/grammar_rules/govcon_vocabulary.json +113 -0
- context/writing/style_guides/academic.yaml +43 -0
- context/writing/style_guides/business.yaml +42 -0
- context/writing/style_guides/government.yaml +59 -0
- context/writing/style_guides/proposal.yaml +58 -0
- context/writing/style_guides/technical.yaml +43 -0
- docs/adr/README.md +66 -0
- docs/adr/connector-forge-decisions.md +318 -0
- docs/adr/core-decisions.md +289 -0
- docs/adr/db-decisions.md +94 -0
- docs/adr/harness-decisions.md +122 -0
- docs/adr/innovation-decisions.md +262 -0
- docs/adr/marketplace-decisions.md +109 -0
- docs/adr/sbd-decisions.md +109 -0
- docs/adr/scale-engine-decisions.md +108 -0
- docs/adr/writeguard-decisions.md +136 -0
- docs/architecture/bounded-contexts.md +1032 -0
- docs/features/phase-65-writeguard.md +139 -0
- docs/features/phase-66-marketplace-commerce.md +79 -0
- docs/features/phase-67-knowledge-ingestion-rag-autodraft.md +97 -0
- docs/features/phase-68-enhanced-autodraft-pipeline.md +109 -0
- docs/features/phase-69-proposalai-marketplace-module.md +131 -0
- docs/features/phase-70-databridge.md +214 -0
- docs/features/phase-71-databridge-messaging.md +102 -0
- docs/implementation-plan-architecture-evolution.md +614 -0
- docs/marketplace/CONTRIBUTING.md +124 -0
- docs/marketplace/module_manifest_schema.yaml +83 -0
- docs/research/ai-architecture-patterns-2024-2026.md +1236 -0
- docs/research/app-builder-platform-analysis.md +582 -0
- docs/research/architecture-patterns-c4-ddd-agentic.md +871 -0
- docs/research/flowable-boat-competitive-analysis.md +426 -0
- docs/research/modern-dev-practices-2024-2026.md +1615 -0
- docs/research/secure-by-design-cloudyrion-adaptation.md +270 -0
- goals/agent_management.md +144 -0
- goals/ai_accountability.md +90 -0
- goals/ai_narratives.md +79 -0
- goals/ai_transparency.md +76 -0
- goals/ato_simulator.md +78 -0
- goals/audit_engine.md +177 -0
- goals/bite_sized_plans.md +225 -0
- goals/boundary_supply_chain.md +206 -0
- goals/brainstorming_gate.md +186 -0
- goals/build_app.md +604 -0
- goals/cato_live_evidence.md +77 -0
- goals/cloudforge.md +106 -0
- goals/code_intelligence.md +197 -0
- goals/compliance_workflow.md +858 -0
- goals/connector_forge.md +133 -0
- goals/databridge.md +128 -0
- goals/deploy_workflow.md +390 -0
- goals/developer_scorecard.md +78 -0
- goals/devsecops_workflow.md +408 -0
- goals/firmware_sbom.md +79 -0
- goals/forge_hub.md +78 -0
- goals/golden_path.md +77 -0
- goals/harness_engineering.md +91 -0
- goals/integration_testing.md +189 -0
- goals/knowledge_graph.md +128 -0
- goals/maintenance_audit.md +196 -0
- goals/manifest.md +50 -0
- goals/monitoring.md +126 -0
- goals/mosa_workflow.md +463 -0
- goals/multi_agent_orchestration.md +68 -0
- goals/observability_traceability_xai.md +154 -0
- goals/owasp_agentic_security.md +395 -0
- goals/pr_intelligence.md +78 -0
- goals/requirements_intake.md +213 -0
- goals/secure_by_design.md +135 -0
- goals/security_scan.md +381 -0
- goals/self_healing.md +120 -0
- goals/simulation_engine.md +111 -0
- goals/subagent_review.md +205 -0
- goals/systematic_debugging.md +257 -0
- goals/tdd_workflow.md +403 -0
- goals/template_exchange.md +77 -0
- goals/thread_heatmap.md +77 -0
- goals/threat_modeler.md +77 -0
- goals/verification_iron_law.md +192 -0
- goals/vsm_dashboard.md +76 -0
- goals/writeguard.md +89 -0
- goals/zero_trust_architecture.md +403 -0
- hardprompts/__init__.py +6 -0
- hardprompts/agent/__init__.py +6 -0
- hardprompts/agent/agentic_architect.md +100 -0
- hardprompts/agent/debate_prompt.md +32 -0
- hardprompts/agent/fitness_evaluation.md +48 -0
- hardprompts/agent/governance_review.md +214 -0
- hardprompts/agent/reviewer_prompt.md +34 -0
- hardprompts/agent/skill_design.md +172 -0
- hardprompts/agent/task_decomposition.md +275 -0
- hardprompts/agent/veto_check_prompt.md +33 -0
- hardprompts/architect/__init__.py +6 -0
- hardprompts/architect/api_design.md +283 -0
- hardprompts/architect/data_model.md +277 -0
- hardprompts/architect/system_design.md +180 -0
- hardprompts/builder/__init__.py +6 -0
- hardprompts/builder/code_generation.md +59 -0
- hardprompts/builder/refactor.md +58 -0
- hardprompts/builder/scaffold_project.md +69 -0
- hardprompts/builder/test_generation.md +87 -0
- hardprompts/ci/__init__.py +6 -0
- hardprompts/ci/worktree_setup.md +35 -0
- hardprompts/compliance/__init__.py +6 -0
- hardprompts/compliance/cmmc_assessment.md +63 -0
- hardprompts/compliance/cssp_assessment.md +75 -0
- hardprompts/compliance/cui_marking.md +86 -0
- hardprompts/compliance/fedramp_assessment.md +55 -0
- hardprompts/compliance/ivv_assessment.md +96 -0
- hardprompts/compliance/poam_generation.md +57 -0
- hardprompts/compliance/sbd_assessment.md +101 -0
- hardprompts/compliance/security_categorization.md +74 -0
- hardprompts/compliance/ssp_generation.md +56 -0
- hardprompts/compliance/stig_evaluation.md +63 -0
- hardprompts/dashboard/__init__.py +6 -0
- hardprompts/dashboard/nlq_system_prompt.md +26 -0
- hardprompts/infra/__init__.py +6 -0
- hardprompts/infra/k8s_manifests.md +118 -0
- hardprompts/infra/pipeline_generation.md +160 -0
- hardprompts/infra/terraform_generation.md +92 -0
- hardprompts/integration/__init__.py +6 -0
- hardprompts/integration/approval_review.md +17 -0
- hardprompts/integration/jira_mapping.md +25 -0
- hardprompts/integration/servicenow_mapping.md +14 -0
- hardprompts/knowledge/__init__.py +6 -0
- hardprompts/knowledge/pattern_detection.md +73 -0
- hardprompts/knowledge/recommendation_engine.md +90 -0
- hardprompts/knowledge/root_cause_analysis.md +91 -0
- hardprompts/maintenance/__init__.py +6 -0
- hardprompts/maintenance/maintenance_assessment.md +82 -0
- hardprompts/mbse/__init__.py +6 -0
- hardprompts/mbse/digital_thread.md +67 -0
- hardprompts/mbse/model_import.md +62 -0
- hardprompts/mbse/model_to_code.md +65 -0
- hardprompts/modernization/__init__.py +6 -0
- hardprompts/modernization/legacy_analysis.md +93 -0
- hardprompts/modernization/migration_planning.md +150 -0
- hardprompts/modernization/seven_r_assessment.md +107 -0
- hardprompts/proposal_draft.md +53 -0
- hardprompts/rag_citation.md +12 -0
- hardprompts/rag_rerank.md +31 -0
- hardprompts/requirements/__init__.py +6 -0
- hardprompts/requirements/bdd_generation.md +35 -0
- hardprompts/requirements/clarification_prioritization.md +29 -0
- hardprompts/requirements/decomposition.md +60 -0
- hardprompts/requirements/document_extraction.md +45 -0
- hardprompts/requirements/gap_detection.md +70 -0
- hardprompts/requirements/intake_conversation.md +101 -0
- hardprompts/requirements/readiness_assessment.md +39 -0
- hardprompts/requirements/spec_quality.md +33 -0
- hardprompts/requirements/traceability_analysis.md +23 -0
- hardprompts/security/__init__.py +6 -0
- hardprompts/security/endpoint_security.md +78 -0
- hardprompts/security/threat_model.md +70 -0
- hardprompts/security/vulnerability_assessment.md +81 -0
- hardprompts/simulation/__init__.py +6 -0
- hardprompts/simulation/architecture_impact.md +27 -0
- hardprompts/simulation/coa_alternative.md +27 -0
- hardprompts/simulation/coa_generation.md +25 -0
- hardprompts/simulation/compliance_impact.md +28 -0
- hardprompts/simulation/cost_estimation.md +33 -0
- hardprompts/simulation/risk_assessment.md +28 -0
- hardprompts/translation/code_translation.md +68 -0
- hardprompts/translation/dependency_suggestion.md +44 -0
- hardprompts/translation/test_translation.md +64 -0
- hardprompts/translation/translation_repair.md +59 -0
- icdev-0.0.3.dist-info/METADATA +909 -0
- icdev-0.0.3.dist-info/RECORD +1214 -0
- icdev-0.0.3.dist-info/WHEEL +5 -0
- icdev-0.0.3.dist-info/entry_points.txt +9 -0
- icdev-0.0.3.dist-info/licenses/LICENSE +201 -0
- icdev-0.0.3.dist-info/licenses/NOTICE +11 -0
- icdev-0.0.3.dist-info/top_level.txt +7 -0
- memory/MEMORY.md +52 -0
- memory/logs/2026-02-14.md +17 -0
- memory/logs/2026-03-03.md +2 -0
- memory/logs/__init__.py +1 -0
- tools/a2a/icdev_callback_client.py +210 -0
- tools/agent/cards/architect_card.json +29 -0
- tools/agent/cards/builder_card.json +34 -0
- tools/agent/cards/compliance_card.json +29 -0
- tools/agent/cards/connector_forge_card.json +49 -0
- tools/agent/cards/devsecops_zta_card.json +24 -0
- tools/agent/cards/knowledge_card.json +29 -0
- tools/agent/cards/monitor_card.json +29 -0
- tools/agent/cards/orchestrator_card.json +29 -0
- tools/agent/cards/requirements_analyst_card.json +24 -0
- tools/agent/cards/security_card.json +29 -0
- tools/agent/cards/simulation_card.json +24 -0
- tools/agent/cards/supply_chain_card.json +24 -0
- tools/analysis/__init__.py +1 -0
- tools/analysis/code_analyzer.py +770 -0
- tools/analysis/runtime_feedback.py +379 -0
- tools/analytics/__init__.py +2 -0
- tools/analytics/scorecard.py +538 -0
- tools/analytics/vsm_engine.py +612 -0
- tools/architecture/__init__.py +2 -0
- tools/architecture/adr_extractor.py +393 -0
- tools/audit/__init__.py +1 -0
- tools/audit/audit_logger.py +199 -0
- tools/audit/audit_query.py +153 -0
- tools/audit/decision_recorder.py +73 -0
- tools/audit_engine/__init__.py +12 -0
- tools/audit_engine/ai_advisor.py +906 -0
- tools/audit_engine/cli.py +286 -0
- tools/audit_engine/comparator.py +305 -0
- tools/audit_engine/eject_scaffolder.py +399 -0
- tools/audit_engine/engine.py +614 -0
- tools/audit_engine/git_fetcher.py +341 -0
- tools/audit_engine/regime_loader.py +200 -0
- tools/audit_engine/regime_updater.py +325 -0
- tools/audit_engine/report_card.py +289 -0
- tools/audit_engine/scanner.py +684 -0
- tools/audit_engine/self_heal.py +1042 -0
- tools/ci/__init__.py +2 -0
- tools/ci/connectors/__init__.py +2 -0
- tools/ci/connectors/base_connector.py +80 -0
- tools/ci/connectors/connector_registry.py +188 -0
- tools/ci/connectors/mattermost_connector.py +159 -0
- tools/ci/connectors/slack_connector.py +197 -0
- tools/ci/core/__init__.py +2 -0
- tools/ci/core/air_gap_detector.py +115 -0
- tools/ci/core/comment_handler.py +192 -0
- tools/ci/core/conversation_manager.py +480 -0
- tools/ci/core/event_envelope.py +500 -0
- tools/ci/core/event_router.py +444 -0
- tools/ci/core/failure_parser.py +397 -0
- tools/ci/core/recovery_engine.py +527 -0
- tools/ci/gate_enforcer.py +361 -0
- tools/ci/modules/__init__.py +2 -0
- tools/ci/modules/agent.py +271 -0
- tools/ci/modules/git_ops.py +175 -0
- tools/ci/modules/state.py +117 -0
- tools/ci/modules/vcs.py +303 -0
- tools/ci/modules/workflow_ops.py +295 -0
- tools/ci/modules/worktree.py +337 -0
- tools/ci/pipeline_config_generator.py +558 -0
- tools/ci/pr_intelligence.py +485 -0
- tools/ci/triggers/__init__.py +2 -0
- tools/ci/triggers/gitlab_task_monitor.py +327 -0
- tools/ci/triggers/poll_trigger.py +237 -0
- tools/ci/triggers/webhook_server.py +356 -0
- tools/ci/workflows/__init__.py +2 -0
- tools/ci/workflows/icdev_build.py +140 -0
- tools/ci/workflows/icdev_comply.py +284 -0
- tools/ci/workflows/icdev_document.py +152 -0
- tools/ci/workflows/icdev_e2e.py +188 -0
- tools/ci/workflows/icdev_patch.py +186 -0
- tools/ci/workflows/icdev_plan.py +202 -0
- tools/ci/workflows/icdev_plan_build.py +41 -0
- tools/ci/workflows/icdev_plan_build_test.py +46 -0
- tools/ci/workflows/icdev_plan_build_test_review.py +47 -0
- tools/ci/workflows/icdev_review.py +126 -0
- tools/ci/workflows/icdev_sdlc.py +261 -0
- tools/ci/workflows/icdev_test.py +240 -0
- tools/cli/__init__.py +1 -0
- tools/cli/output_formatter.py +756 -0
- tools/cloudforge/__init__.py +12 -0
- tools/cloudforge/airgap/__init__.py +2 -0
- tools/cloudforge/airgap/il_classifier.py +70 -0
- tools/cloudforge/airgap/offline_validator.py +42 -0
- tools/cloudforge/airgap/shift_emulator.py +155 -0
- tools/cloudforge/airgap/sneakernet.py +91 -0
- tools/cloudforge/cd_hub/__init__.py +2 -0
- tools/cloudforge/cd_hub/canary_deployer.py +88 -0
- tools/cloudforge/cd_hub/gitops_renderer.py +123 -0
- tools/cloudforge/cd_hub/hub_controller.py +143 -0
- tools/cloudforge/cd_hub/pipeline_bridge.py +30 -0
- tools/cloudforge/cd_hub/rollback_engine.py +29 -0
- tools/cloudforge/cd_hub/spoke_agent.py +51 -0
- tools/cloudforge/compliance/__init__.py +2 -0
- tools/cloudforge/compliance/ato_accelerator.py +272 -0
- tools/cloudforge/compliance/control_inheritor.py +127 -0
- tools/cloudforge/compliance/evidence_generator.py +129 -0
- tools/cloudforge/compliance/poam_bridge.py +41 -0
- tools/cloudforge/compliance/ssp_bridge.py +52 -0
- tools/cloudforge/compliance/stig_bridge.py +41 -0
- tools/cloudforge/container_forge/__init__.py +2 -0
- tools/cloudforge/container_forge/bigbang_renderer.py +85 -0
- tools/cloudforge/container_forge/hardener.py +169 -0
- tools/cloudforge/container_forge/image_scanner_bridge.py +33 -0
- tools/cloudforge/container_forge/runtime_policy.py +87 -0
- tools/cloudforge/container_forge/sbom_bridge.py +42 -0
- tools/cloudforge/finops/__init__.py +2 -0
- tools/cloudforge/finops/anomaly_detector.py +78 -0
- tools/cloudforge/finops/budget_tracker.py +96 -0
- tools/cloudforge/finops/chargeback.py +69 -0
- tools/cloudforge/finops/cost_collector.py +141 -0
- tools/cloudforge/finops/optimizer.py +55 -0
- tools/cloudforge/hybrid/__init__.py +2 -0
- tools/cloudforge/hybrid/connection_manager.py +141 -0
- tools/cloudforge/hybrid/dns_federator.py +56 -0
- tools/cloudforge/hybrid/health_monitor.py +108 -0
- tools/cloudforge/hybrid/identity_federator.py +53 -0
- tools/cloudforge/hybrid/network_bridge.py +68 -0
- tools/cloudforge/hybrid/topology_manager.py +147 -0
- tools/cloudforge/hybrid/workload_abstractor.py +92 -0
- tools/cloudforge/iac/__init__.py +2 -0
- tools/cloudforge/iac/drift_detector.py +154 -0
- tools/cloudforge/iac/module_library.py +265 -0
- tools/cloudforge/iac/opentofu_adapter.py +89 -0
- tools/cloudforge/iac/pulumi_renderer.py +292 -0
- tools/cloudforge/iac/state_backend.py +146 -0
- tools/cloudforge/iac/terraform_renderer.py +626 -0
- tools/cloudforge/landing_zone/__init__.py +2 -0
- tools/cloudforge/landing_zone/blueprint_loader.py +98 -0
- tools/cloudforge/landing_zone/blueprint_validator.py +113 -0
- tools/cloudforge/landing_zone/zone_provisioner.py +306 -0
- tools/cloudforge/landing_zone/zone_state.py +143 -0
- tools/cloudforge/mbse_thread/__init__.py +2 -0
- tools/cloudforge/mbse_thread/ato_thread_weaver.py +111 -0
- tools/cloudforge/mbse_thread/control_tracer.py +68 -0
- tools/cloudforge/mbse_thread/system_boundary.py +83 -0
- tools/cloudforge/metastore/__init__.py +2 -0
- tools/cloudforge/metastore/dependency_graph.py +202 -0
- tools/cloudforge/metastore/discovery.py +192 -0
- tools/cloudforge/metastore/registry.py +185 -0
- tools/cloudforge/metastore/rto_tracker.py +92 -0
- tools/cloudforge/metastore/runbook_linker.py +82 -0
- tools/cloudforge/migration/__init__.py +2 -0
- tools/cloudforge/migration/assessor.py +187 -0
- tools/cloudforge/migration/cutover_orchestrator.py +117 -0
- tools/cloudforge/migration/databridge_bridge.py +92 -0
- tools/cloudforge/migration/planner.py +98 -0
- tools/cloudforge/migration/risk_scorer.py +97 -0
- tools/cloudforge/migration/validation_runner.py +45 -0
- tools/cloudforge/migration/workload_inventory.py +107 -0
- tools/cloudforge/provider.py +319 -0
- tools/cloudforge/providers/__init__.py +2 -0
- tools/cloudforge/providers/aws_commercial.py +92 -0
- tools/cloudforge/providers/aws_govcloud.py +229 -0
- tools/cloudforge/providers/aws_secret.py +83 -0
- tools/cloudforge/providers/azure_commercial.py +80 -0
- tools/cloudforge/providers/azure_gov.py +91 -0
- tools/cloudforge/providers/azure_secret.py +71 -0
- tools/cloudforge/providers/gcp.py +102 -0
- tools/cloudforge/providers/oci.py +102 -0
- tools/cloudforge/registry.py +140 -0
- tools/cloudforge/runbooks/__init__.py +2 -0
- tools/cloudforge/runbooks/ai_generator.py +119 -0
- tools/cloudforge/runbooks/dag_validator.py +219 -0
- tools/cloudforge/runbooks/engine.py +470 -0
- tools/cloudforge/runbooks/models.py +99 -0
- tools/cloudforge/runbooks/snippet_library.py +158 -0
- tools/cloudforge/runbooks/template_loader.py +122 -0
- tools/cloudforge/runbooks/visualization.py +108 -0
- tools/cloudforge/siem/__init__.py +2 -0
- tools/cloudforge/siem/alert_rules.py +86 -0
- tools/cloudforge/siem/correlation_engine.py +61 -0
- tools/cloudforge/siem/log_aggregator.py +113 -0
- tools/cloudforge/siem/siem_dashboard_data.py +28 -0
- tools/cloudforge/supply_chain/__init__.py +2 -0
- tools/cloudforge/supply_chain/bridge.py +33 -0
- tools/cloudforge/supply_chain/iac_dependency_scanner.py +36 -0
- tools/cloudforge/supply_chain/provider_trust_scorer.py +54 -0
- tools/compat/__init__.py +21 -0
- tools/compat/cli_harmonizer.py +251 -0
- tools/compat/datetime_utils.py +18 -0
- tools/compat/db_utils.py +190 -0
- tools/compat/platform_utils.py +123 -0
- tools/compliance/__init__.py +1 -0
- tools/compliance/accountability_manager.py +391 -0
- tools/compliance/ai_accountability_audit.py +287 -0
- tools/compliance/ai_impact_assessor.py +267 -0
- tools/compliance/ai_incident_response.py +295 -0
- tools/compliance/ai_inventory_manager.py +233 -0
- tools/compliance/ai_reassessment_scheduler.py +250 -0
- tools/compliance/ai_transparency_audit.py +247 -0
- tools/compliance/atlas_assessor.py +276 -0
- tools/compliance/atlas_report_generator.py +1199 -0
- tools/compliance/base_assessor.py +591 -0
- tools/compliance/cato_live_engine.py +607 -0
- tools/compliance/cato_monitor.py +1371 -0
- tools/compliance/cato_scheduler.py +698 -0
- tools/compliance/cjis_assessor.py +76 -0
- tools/compliance/classification_manager.py +1340 -0
- tools/compliance/cmmc_assessor.py +1478 -0
- tools/compliance/cmmc_report_generator.py +1087 -0
- tools/compliance/compliance_detector.py +452 -0
- tools/compliance/compliance_exporter.py +418 -0
- tools/compliance/compliance_status.py +810 -0
- tools/compliance/control_mapper.py +488 -0
- tools/compliance/crosswalk_engine.py +1208 -0
- tools/compliance/cssp_assessor.py +1032 -0
- tools/compliance/cssp_evidence_collector.py +716 -0
- tools/compliance/cssp_report_generator.py +1103 -0
- tools/compliance/cui_marker.py +387 -0
- tools/compliance/diagram_validator.py +599 -0
- tools/compliance/emass/__init__.py +2 -0
- tools/compliance/emass/emass_client.py +822 -0
- tools/compliance/emass/emass_export.py +758 -0
- tools/compliance/emass/emass_sync.py +807 -0
- tools/compliance/eu_ai_act_classifier.py +193 -0
- tools/compliance/evidence_collector.py +459 -0
- tools/compliance/fairness_assessor.py +310 -0
- tools/compliance/fedramp_20x_ksi_emitter.py +692 -0
- tools/compliance/fedramp_assessor.py +1795 -0
- tools/compliance/fedramp_authorization_packager.py +137 -0
- tools/compliance/fedramp_ksi_generator.py +349 -0
- tools/compliance/fedramp_report_generator.py +1115 -0
- tools/compliance/fips199_categorizer.py +869 -0
- tools/compliance/fips200_validator.py +304 -0
- tools/compliance/firmware_sbom.py +646 -0
- tools/compliance/gao_ai_assessor.py +228 -0
- tools/compliance/gao_evidence_builder.py +302 -0
- tools/compliance/hipaa_assessor.py +78 -0
- tools/compliance/hitrust_assessor.py +49 -0
- tools/compliance/incident_response_plan.py +705 -0
- tools/compliance/inheritance_engine.py +693 -0
- tools/compliance/iso27001_assessor.py +92 -0
- tools/compliance/iso42001_assessor.py +114 -0
- tools/compliance/ivv_assessor.py +2314 -0
- tools/compliance/ivv_report_generator.py +1649 -0
- tools/compliance/model_card_generator.py +291 -0
- tools/compliance/mosa_assessor.py +117 -0
- tools/compliance/multi_regime_assessor.py +441 -0
- tools/compliance/narrative_generator.py +1012 -0
- tools/compliance/narrative_quality_gate.py +701 -0
- tools/compliance/narrative_workflow.py +814 -0
- tools/compliance/nist_800_207_assessor.py +191 -0
- tools/compliance/nist_ai_600_1_assessor.py +185 -0
- tools/compliance/nist_ai_rmf_assessor.py +110 -0
- tools/compliance/nist_lookup.py +244 -0
- tools/compliance/omb_m25_21_assessor.py +225 -0
- tools/compliance/omb_m26_04_assessor.py +185 -0
- tools/compliance/oscal_catalog_adapter.py +395 -0
- tools/compliance/oscal_generator.py +2157 -0
- tools/compliance/oscal_tools.py +1182 -0
- tools/compliance/oscal_validator.py +692 -0
- tools/compliance/owasp_agentic_assessor.py +227 -0
- tools/compliance/owasp_asi_assessor.py +197 -0
- tools/compliance/owasp_llm_assessor.py +245 -0
- tools/compliance/pci_dss_assessor.py +80 -0
- tools/compliance/pi_compliance_tracker.py +1447 -0
- tools/compliance/poam_generator.py +388 -0
- tools/compliance/resolve_marking.py +272 -0
- tools/compliance/sbd_assessor.py +2070 -0
- tools/compliance/sbd_report_generator.py +1223 -0
- tools/compliance/sbom_generator.py +993 -0
- tools/compliance/siem_config_generator.py +661 -0
- tools/compliance/slsa_attestation_generator.py +479 -0
- tools/compliance/soc2_assessor.py +77 -0
- tools/compliance/ssp_generator.py +556 -0
- tools/compliance/stig_checker.py +712 -0
- tools/compliance/swft_evidence_bundler.py +326 -0
- tools/compliance/system_card_generator.py +303 -0
- tools/compliance/template_exchange.py +513 -0
- tools/compliance/traceability_matrix.py +1268 -0
- tools/compliance/universal_classification_manager.py +1159 -0
- tools/compliance/xacta/__init__.py +2 -0
- tools/compliance/xacta/xacta_client.py +438 -0
- tools/compliance/xacta/xacta_export.py +546 -0
- tools/compliance/xacta/xacta_sync.py +322 -0
- tools/compliance/xai_assessor.py +231 -0
- tools/core/__init__.py +2 -0
- tools/core/circuit_breaker.py +353 -0
- tools/core/compliance_sidecar.py +344 -0
- tools/core/container.py +110 -0
- tools/core/errors.py +256 -0
- tools/core/feature_flags.py +311 -0
- tools/core/task_dlq.py +350 -0
- tools/dashboard/__init__.py +2 -0
- tools/dashboard/app.py +6288 -0
- tools/dashboard/templates/agent_evolution.html +287 -0
- tools/dashboard/templates/agents/list.html +71 -0
- tools/dashboard/templates/agents.html +132 -0
- tools/dashboard/templates/architecture.html +289 -0
- tools/dashboard/templates/ato_simulator.html +170 -0
- tools/dashboard/templates/audit_engine.html +844 -0
- tools/dashboard/templates/base.html +236 -0
- tools/dashboard/templates/cato_live.html +116 -0
- tools/dashboard/templates/cloudforge.html +195 -0
- tools/dashboard/templates/cloudforge_finops.html +111 -0
- tools/dashboard/templates/cloudforge_hybrid.html +122 -0
- tools/dashboard/templates/cloudforge_metastore.html +234 -0
- tools/dashboard/templates/cloudforge_migration.html +87 -0
- tools/dashboard/templates/cloudforge_runbooks.html +201 -0
- tools/dashboard/templates/cloudforge_siem.html +94 -0
- tools/dashboard/templates/compliance_accel.html +292 -0
- tools/dashboard/templates/crashes.html +122 -0
- tools/dashboard/templates/databridge.html +305 -0
- tools/dashboard/templates/databridge_analytics.html +195 -0
- tools/dashboard/templates/databridge_mapping.html +345 -0
- tools/dashboard/templates/databridge_messaging.html +321 -0
- tools/dashboard/templates/decisions.html +258 -0
- tools/dashboard/templates/devices.html +151 -0
- tools/dashboard/templates/devsecops_maturity.html +278 -0
- tools/dashboard/templates/edge_ai.html +128 -0
- tools/dashboard/templates/firmware.html +120 -0
- tools/dashboard/templates/firmware_sbom.html +193 -0
- tools/dashboard/templates/forge_hub.html +196 -0
- tools/dashboard/templates/forge_studio.html +379 -0
- tools/dashboard/templates/forge_studio_analytics.html +360 -0
- tools/dashboard/templates/forge_studio_builder.html +1637 -0
- tools/dashboard/templates/forge_studio_compliance.html +310 -0
- tools/dashboard/templates/forge_studio_deploy.html +573 -0
- tools/dashboard/templates/forge_studio_enterprise.html +888 -0
- tools/dashboard/templates/forge_studio_marketplace.html +502 -0
- tools/dashboard/templates/forge_studio_workflow.html +696 -0
- tools/dashboard/templates/golden_path.html +175 -0
- tools/dashboard/templates/govcon.html +280 -0
- tools/dashboard/templates/harness.html +148 -0
- tools/dashboard/templates/index.html +207 -0
- tools/dashboard/templates/intelligence.html +336 -0
- tools/dashboard/templates/knowledge/index.html +190 -0
- tools/dashboard/templates/knowledge_graph.html +739 -0
- tools/dashboard/templates/login.html +51 -0
- tools/dashboard/templates/marketplace.html +336 -0
- tools/dashboard/templates/marketplace_admin.html +247 -0
- tools/dashboard/templates/missions.html +403 -0
- tools/dashboard/templates/narratives.html +154 -0
- tools/dashboard/templates/pr_intelligence.html +151 -0
- tools/dashboard/templates/proposals/detail.html +300 -0
- tools/dashboard/templates/proposals/list.html +52 -0
- tools/dashboard/templates/proposals/sam_detail.html +132 -0
- tools/dashboard/templates/proposals/section_detail.html +375 -0
- tools/dashboard/templates/research.html +222 -0
- tools/dashboard/templates/resilience.html +300 -0
- tools/dashboard/templates/scorecard.html +162 -0
- tools/dashboard/templates/simulator.html +131 -0
- tools/dashboard/templates/template_exchange.html +147 -0
- tools/dashboard/templates/thread_heatmap.html +151 -0
- tools/dashboard/templates/threat_model.html +195 -0
- tools/dashboard/templates/vsm.html +141 -0
- tools/dashboard/templates/writeguard.html +277 -0
- tools/databridge/__init__.py +5 -0
- tools/databridge/agent/__init__.py +2 -0
- tools/databridge/agent/daemon.py +227 -0
- tools/databridge/agent/tunnel.py +101 -0
- tools/databridge/agent/ws_relay.py +91 -0
- tools/databridge/analytics.py +167 -0
- tools/databridge/arrow_pipeline.py +327 -0
- tools/databridge/connection_manager.py +424 -0
- tools/databridge/connector.py +331 -0
- tools/databridge/connectors/__init__.py +2 -0
- tools/databridge/connectors/argocd_connector.py +160 -0
- tools/databridge/connectors/avro_connector.py +203 -0
- tools/databridge/connectors/azure_blob.py +63 -0
- tools/databridge/connectors/cdc_connector.py +205 -0
- tools/databridge/connectors/csv_connector.py +172 -0
- tools/databridge/connectors/datadog_connector.py +153 -0
- tools/databridge/connectors/discord_messaging.py +215 -0
- tools/databridge/connectors/dynamics365.py +151 -0
- tools/databridge/connectors/elasticsearch_connector.py +145 -0
- tools/databridge/connectors/email_base.py +114 -0
- tools/databridge/connectors/excel_connector.py +175 -0
- tools/databridge/connectors/fsspec_base.py +300 -0
- tools/databridge/connectors/gcs.py +53 -0
- tools/databridge/connectors/github_connector.py +138 -0
- tools/databridge/connectors/gitlab_connector.py +132 -0
- tools/databridge/connectors/gmail_connector.py +182 -0
- tools/databridge/connectors/hdfs.py +57 -0
- tools/databridge/connectors/health_base.py +401 -0
- tools/databridge/connectors/hubspot.py +124 -0
- tools/databridge/connectors/imap_connector.py +171 -0
- tools/databridge/connectors/jenkins_connector.py +138 -0
- tools/databridge/connectors/jira_connector.py +86 -0
- tools/databridge/connectors/json_connector.py +184 -0
- tools/databridge/connectors/kafka_connector.py +246 -0
- tools/databridge/connectors/kinesis_connector.py +238 -0
- tools/databridge/connectors/local_fs.py +30 -0
- tools/databridge/connectors/matrix.py +197 -0
- tools/databridge/connectors/mattermost_messaging.py +184 -0
- tools/databridge/connectors/messaging_base.py +172 -0
- tools/databridge/connectors/mssql.py +63 -0
- tools/databridge/connectors/mysql.py +57 -0
- tools/databridge/connectors/netsuite.py +170 -0
- tools/databridge/connectors/o365_mail.py +196 -0
- tools/databridge/connectors/oracle.py +65 -0
- tools/databridge/connectors/pagerduty_connector.py +162 -0
- tools/databridge/connectors/parquet_connector.py +131 -0
- tools/databridge/connectors/postgresql.py +58 -0
- tools/databridge/connectors/s3.py +65 -0
- tools/databridge/connectors/saas_base.py +198 -0
- tools/databridge/connectors/salesforce.py +126 -0
- tools/databridge/connectors/sap.py +89 -0
- tools/databridge/connectors/servicenow.py +60 -0
- tools/databridge/connectors/signal_messaging.py +150 -0
- tools/databridge/connectors/slack_messaging.py +203 -0
- tools/databridge/connectors/smtp_connector.py +126 -0
- tools/databridge/connectors/soap_base.py +258 -0
- tools/databridge/connectors/splunk_connector.py +171 -0
- tools/databridge/connectors/sql_base.py +310 -0
- tools/databridge/connectors/sqlite_connector.py +76 -0
- tools/databridge/connectors/teams.py +148 -0
- tools/databridge/connectors/telegram.py +192 -0
- tools/databridge/connectors/whatsapp.py +137 -0
- tools/databridge/data_profiler.py +99 -0
- tools/databridge/forge/__init__.py +6 -0
- tools/databridge/forge/base_selector.py +150 -0
- tools/databridge/forge/code_generator.py +206 -0
- tools/databridge/forge/community_hub.py +539 -0
- tools/databridge/forge/forge_agent.py +306 -0
- tools/databridge/forge/import_handler.py +133 -0
- tools/databridge/forge/integration_tester.py +127 -0
- tools/databridge/forge/marketplace_publisher.py +164 -0
- tools/databridge/forge/promoter.py +159 -0
- tools/databridge/forge/sandbox_manager.py +257 -0
- tools/databridge/forge/spec_parser.py +358 -0
- tools/databridge/forge/static_validator.py +363 -0
- tools/databridge/forge/templates/__init__.py +591 -0
- tools/databridge/format_converter.py +188 -0
- tools/databridge/mapping_engine.py +348 -0
- tools/databridge/messaging/__init__.py +5 -0
- tools/databridge/messaging/agent_bridge.py +254 -0
- tools/databridge/messaging/message_envelope.py +111 -0
- tools/databridge/messaging/message_logger.py +204 -0
- tools/databridge/messaging/messaging_daemon.py +326 -0
- tools/databridge/messaging/oauth2_manager.py +411 -0
- tools/databridge/pii_detector.py +221 -0
- tools/databridge/registry.py +352 -0
- tools/databridge/relay_server.py +105 -0
- tools/databridge/scale/__init__.py +16 -0
- tools/databridge/scale/backpressure.py +134 -0
- tools/databridge/scale/chunked_pipeline.py +169 -0
- tools/databridge/scale/connection_pool.py +293 -0
- tools/databridge/scale/engine.py +492 -0
- tools/databridge/scale/worker_pool.py +140 -0
- tools/databridge/scale/write_batcher.py +250 -0
- tools/databridge/schema_engine.py +324 -0
- tools/databridge/stream_manager.py +225 -0
- tools/databridge/sync_engine.py +411 -0
- tools/databridge/transforms.py +302 -0
- tools/db/__init__.py +1 -0
- tools/db/backup.py +312 -0
- tools/db/backup_manager.py +832 -0
- tools/db/init_icdev_db.py +7753 -0
- tools/db/init_sparkpilot_db.py +431 -0
- tools/db/migrate.py +177 -0
- tools/db/migrate_innovation_audit.py +165 -0
- tools/db/migration_runner.py +548 -0
- tools/db/migrations/001_baseline/meta.json +9 -0
- tools/db/migrations/001_baseline/up.py +67 -0
- tools/db/migrations/002_memory_enhancements/down.sql +8 -0
- tools/db/migrations/002_memory_enhancements/meta.json +9 -0
- tools/db/migrations/002_memory_enhancements/up.py +119 -0
- tools/db/migrations/003_dev_profiles/meta.json +8 -0
- tools/db/migrations/003_dev_profiles/up.py +93 -0
- tools/db/migrations/004_innovation_engine/down.py +19 -0
- tools/db/migrations/004_innovation_engine/up.py +227 -0
- tools/db/migrations/005_phase_37_ai_security/down.py +19 -0
- tools/db/migrations/005_phase_37_ai_security/up.py +257 -0
- tools/db/migrations/006_phase_36_evolution/down.py +21 -0
- tools/db/migrations/006_phase_36_evolution/up.py +323 -0
- tools/db/migrations/007_phase_38_cloud/down.py +14 -0
- tools/db/migrations/007_phase_38_cloud/up.py +110 -0
- tools/db/migrations/008_phase36_37_integration/up.py +55 -0
- tools/db/migrations/__init__.py +2 -0
- tools/db/pg_migrate.py +642 -0
- tools/db/storage.py +1080 -0
- tools/decisions/__init__.py +2 -0
- tools/decisions/dmn_engine.py +695 -0
- tools/devsecops/__init__.py +2 -0
- tools/devsecops/attestation_manager.py +449 -0
- tools/devsecops/network_segmentation_generator.py +604 -0
- tools/devsecops/pdp_config_generator.py +1246 -0
- tools/devsecops/pipeline_security_generator.py +475 -0
- tools/devsecops/policy_generator.py +644 -0
- tools/devsecops/profile_manager.py +374 -0
- tools/devsecops/service_mesh_generator.py +1063 -0
- tools/devsecops/zta_maturity_scorer.py +355 -0
- tools/devsecops/zta_terraform_generator.py +1301 -0
- tools/edge_ai/__init__.py +2 -0
- tools/edge_ai/model_manager.py +200 -0
- tools/embedded/__init__.py +2 -0
- tools/embedded/cmake_generator.py +318 -0
- tools/embedded/crash_analyzer.py +191 -0
- tools/embedded/nl_to_firmware.py +277 -0
- tools/events/__init__.py +1 -0
- tools/events/event_bus.py +199 -0
- tools/finetune/pair_generator.py +832 -0
- tools/fleet/__init__.py +2 -0
- tools/fleet/device_registry.py +148 -0
- tools/fleet/ota_manager.py +153 -0
- tools/forge_studio/__init__.py +13 -0
- tools/forge_studio/analytics/__init__.py +0 -0
- tools/forge_studio/analytics/process_miner.py +383 -0
- tools/forge_studio/audit.py +183 -0
- tools/forge_studio/blueprint/__init__.py +2 -0
- tools/forge_studio/blueprint/build_tracker.py +317 -0
- tools/forge_studio/blueprint/export_engine.py +441 -0
- tools/forge_studio/blueprint/parent_client.py +335 -0
- tools/forge_studio/catalog/__init__.py +2 -0
- tools/forge_studio/catalog/component_registry.py +176 -0
- tools/forge_studio/catalog/schema_validator.py +193 -0
- tools/forge_studio/compliance/__init__.py +1 -0
- tools/forge_studio/compliance/compliance_wiring.py +554 -0
- tools/forge_studio/deploy/__init__.py +1 -0
- tools/forge_studio/deploy/airgap_packager.py +466 -0
- tools/forge_studio/deploy/deploy_engine.py +1792 -0
- tools/forge_studio/deploy/env_manager.py +431 -0
- tools/forge_studio/eject/__init__.py +2 -0
- tools/forge_studio/eject/docker_compose_generator.py +237 -0
- tools/forge_studio/eject/eject_engine.py +230 -0
- tools/forge_studio/eject/expo_scaffolder.py +303 -0
- tools/forge_studio/eject/nextjs_scaffolder.py +338 -0
- tools/forge_studio/enterprise/__init__.py +0 -0
- tools/forge_studio/enterprise/custom_frameworks.py +826 -0
- tools/forge_studio/enterprise/hardening_engine.py +1530 -0
- tools/forge_studio/enterprise/sso_manager.py +718 -0
- tools/forge_studio/enterprise/whitelabel_engine.py +887 -0
- tools/forge_studio/formula/__init__.py +0 -0
- tools/forge_studio/formula/expression_engine.py +562 -0
- tools/forge_studio/formula/formula_registry.py +265 -0
- tools/forge_studio/generator/__init__.py +2 -0
- tools/forge_studio/generator/app_generator.py +584 -0
- tools/forge_studio/generator/complexity_detector.py +368 -0
- tools/forge_studio/generator/prompt_templates.py +104 -0
- tools/forge_studio/generator/spec_builder.py +192 -0
- tools/forge_studio/intake_bridge.py +898 -0
- tools/forge_studio/marketplace/__init__.py +0 -0
- tools/forge_studio/marketplace/component_hub.py +428 -0
- tools/forge_studio/models.py +369 -0
- tools/forge_studio/renderer/__init__.py +2 -0
- tools/forge_studio/renderer/json_render_engine.py +623 -0
- tools/forge_studio/renderer/layout_engine.py +214 -0
- tools/forge_studio/renderer/rn_component_map.py +182 -0
- tools/forge_studio/supabase/__init__.py +2 -0
- tools/forge_studio/supabase/auth_generator.py +283 -0
- tools/forge_studio/supabase/migration_generator.py +93 -0
- tools/forge_studio/supabase/schema_generator.py +281 -0
- tools/forge_studio/tenant_manager.py +387 -0
- tools/forge_studio/workflow/__init__.py +2 -0
- tools/forge_studio/workflow/bpmn_adapter.py +489 -0
- tools/govcon/draft_orchestrator.py +1151 -0
- tools/govcon/engine_enrichment.py +373 -0
- tools/govcon/knowledge_base.py +487 -0
- tools/govcon/knowledge_ingestion.py +510 -0
- tools/govcon/sam_scanner.py +754 -0
- tools/harness/__init__.py +6 -0
- tools/harness/exit_criteria_evaluator.py +231 -0
- tools/harness/maturity_assessor.py +347 -0
- tools/harness/scaffold_harness.py +416 -0
- tools/harness/trace_analyzer.py +281 -0
- tools/infra/__init__.py +1 -0
- tools/infra/ansible_generator.py +867 -0
- tools/infra/dockerfile_generator.py +359 -0
- tools/infra/infra_status.py +384 -0
- tools/infra/ironbank_metadata_generator.py +403 -0
- tools/infra/k8s_generator.py +1000 -0
- tools/infra/pipeline_generator.py +830 -0
- tools/infra/rollback.py +389 -0
- tools/infra/terraform_generator.py +1140 -0
- tools/infra/terraform_generator_azure.py +1252 -0
- tools/infra/terraform_generator_gcp.py +951 -0
- tools/infra/terraform_generator_ibm.py +359 -0
- tools/infra/terraform_generator_oci.py +918 -0
- tools/infra/terraform_generator_onprem.py +318 -0
- tools/knowledge/__init__.py +1 -0
- tools/knowledge/knowledge_ingest.py +281 -0
- tools/knowledge/pattern_detector.py +681 -0
- tools/knowledge/recommendation_engine.py +449 -0
- tools/knowledge/self_heal_analyzer.py +492 -0
- tools/knowledge_graph/__init__.py +2 -0
- tools/knowledge_graph/graph_rag.py +498 -0
- tools/knowledge_graph/ingester.py +406 -0
- tools/knowledge_graph/insight_generator.py +369 -0
- tools/knowledge_graph/text_network.py +832 -0
- tools/llm/__init__.py +72 -0
- tools/llm/anthropic_provider.py +170 -0
- tools/llm/azure_openai_provider.py +338 -0
- tools/llm/bedrock_provider.py +315 -0
- tools/llm/embedding_provider.py +438 -0
- tools/llm/gemini_provider.py +381 -0
- tools/llm/ibm_watsonx_provider.py +231 -0
- tools/llm/oci_genai_provider.py +462 -0
- tools/llm/ollama_provider.py +350 -0
- tools/llm/openai_provider.py +225 -0
- tools/llm/prompt_registry.py +447 -0
- tools/llm/provider.py +355 -0
- tools/llm/provider_sdk.py +175 -0
- tools/llm/router.py +1124 -0
- tools/llm/semantic_cache.py +394 -0
- tools/llm/vertex_ai_provider.py +374 -0
- tools/maintenance/__init__.py +2 -0
- tools/maintenance/dependency_scanner.py +1016 -0
- tools/maintenance/maintenance_auditor.py +804 -0
- tools/maintenance/remediation_engine.py +957 -0
- tools/maintenance/vulnerability_checker.py +978 -0
- tools/manifest.md +1066 -0
- tools/marketplace/asset_installer.py +639 -0
- tools/marketplace/feedback_validator.py +359 -0
- tools/marketplace/license_client.py +458 -0
- tools/marketplace/module_crypto.py +544 -0
- tools/marketplace/module_runtime.py +236 -0
- tools/marketplace/token_store.py +264 -0
- tools/mbse/__init__.py +3 -0
- tools/mbse/des_assessor.py +1173 -0
- tools/mbse/des_report_generator.py +787 -0
- tools/mbse/diagram_extractor.py +792 -0
- tools/mbse/digital_thread.py +1650 -0
- tools/mbse/model_code_generator.py +1115 -0
- tools/mbse/model_control_mapper.py +410 -0
- tools/mbse/pi_model_tracker.py +1079 -0
- tools/mbse/reqif_parser.py +1468 -0
- tools/mbse/sync_engine.py +1789 -0
- tools/mbse/thread_heatmap.py +445 -0
- tools/mbse/xmi_parser.py +1558 -0
- tools/mcp/builder_server.py +64 -0
- tools/mcp/compliance_server.py +64 -0
- tools/mcp/connector_forge_server.py +155 -0
- tools/mcp/core_server.py +64 -0
- tools/mcp/devsecops_server.py +11 -0
- tools/mcp/devsecops_zta_server.py +64 -0
- tools/mcp/knowledge_server.py +64 -0
- tools/mcp/monitor_server.py +64 -0
- tools/mcp/ops_server.py +300 -0
- tools/mcp/requirements_analyst_server.py +64 -0
- tools/mcp/requirements_server.py +11 -0
- tools/mcp/security_server.py +64 -0
- tools/mcp/simulation_server.py +64 -0
- tools/mcp/supply_chain_server.py +64 -0
- tools/mcp/tool_registry.py +299 -0
- tools/memory/__init__.py +2 -0
- tools/memory/auto_capture.py +346 -0
- tools/memory/embed_memory.py +157 -0
- tools/memory/history_compressor.py +334 -0
- tools/memory/hybrid_search.py +235 -0
- tools/memory/maintenance_cron.py +288 -0
- tools/memory/memory_consolidation.py +439 -0
- tools/memory/memory_db.py +132 -0
- tools/memory/memory_read.py +101 -0
- tools/memory/memory_write.py +221 -0
- tools/memory/semantic_search.py +138 -0
- tools/memory/time_decay.py +434 -0
- tools/missions/__init__.py +2 -0
- tools/missions/mission_engine.py +459 -0
- tools/monitor/__init__.py +1 -0
- tools/monitor/alert_correlator.py +486 -0
- tools/monitor/auto_resolver.py +603 -0
- tools/monitor/health_checker.py +507 -0
- tools/monitor/heartbeat_daemon.py +779 -0
- tools/monitor/log_analyzer.py +507 -0
- tools/monitor/metric_collector.py +484 -0
- tools/mosa/__init__.py +10 -0
- tools/mosa/icd_generator.py +358 -0
- tools/mosa/modular_design_analyzer.py +682 -0
- tools/mosa/mosa_code_enforcer.py +348 -0
- tools/mosa/tsp_generator.py +265 -0
- tools/observability/__init__.py +100 -0
- tools/observability/genai_attributes.py +88 -0
- tools/observability/instrumentation.py +140 -0
- tools/observability/mlflow_exporter.py +193 -0
- tools/observability/otel_tracer.py +168 -0
- tools/observability/provenance/__init__.py +3 -0
- tools/observability/provenance/prov_recorder.py +322 -0
- tools/observability/shap/__init__.py +3 -0
- tools/observability/shap/agent_shap.py +274 -0
- tools/observability/sqlite_tracer.py +360 -0
- tools/observability/trace_context.py +205 -0
- tools/observability/tracer.py +230 -0
- tools/orchestration/__init__.py +1 -0
- tools/orchestration/peer_channels.py +254 -0
- tools/orchestration/saga_coordinator.py +390 -0
- tools/project/__init__.py +1 -0
- tools/project/manifest_loader.py +418 -0
- tools/project/project_create.py +350 -0
- tools/project/project_list.py +171 -0
- tools/project/project_scaffold.py +1715 -0
- tools/project/project_status.py +478 -0
- tools/project/session_context_builder.py +752 -0
- tools/project/validate_manifest.py +54 -0
- tools/rag/corrective_rag.py +582 -0
- tools/rag/source_registry.py +482 -0
- tools/requirements/__init__.py +1 -0
- tools/requirements/ai_governance_scorer.py +207 -0
- tools/requirements/boundary_analyzer.py +1281 -0
- tools/requirements/clarification_engine.py +605 -0
- tools/requirements/complexity_scorer.py +369 -0
- tools/requirements/consistency_analyzer.py +789 -0
- tools/requirements/constitution_manager.py +592 -0
- tools/requirements/decomposition_engine.py +764 -0
- tools/requirements/document_extractor.py +1002 -0
- tools/requirements/elicitation_techniques.py +508 -0
- tools/requirements/gap_detector.py +260 -0
- tools/requirements/intake_engine.py +2175 -0
- tools/requirements/prd_generator.py +839 -0
- tools/requirements/prd_validator.py +584 -0
- tools/requirements/readiness_scorer.py +302 -0
- tools/requirements/spec_organizer.py +1015 -0
- tools/requirements/spec_quality_checker.py +1083 -0
- tools/requirements/traceability_builder.py +566 -0
- tools/research/__init__.py +3 -0
- tools/research/academic_scanner.py +130 -0
- tools/research/build_buy_analyzer.py +229 -0
- tools/research/challenge_scorer.py +280 -0
- tools/research/community_scanner.py +174 -0
- tools/research/cross_engine_bridge.py +124 -0
- tools/research/dossier_generator.py +305 -0
- tools/research/landscape_scanner.py +315 -0
- tools/research/regulatory_scanner.py +248 -0
- tools/research/research_manager.py +469 -0
- tools/research/source_scanner.py +150 -0
- tools/research/vertical_loader.py +118 -0
- tools/saas/__init__.py +0 -0
- tools/saas/licensing/__init__.py +0 -0
- tools/saas/licensing/license_validator.py +345 -0
- tools/scaffold/__init__.py +2 -0
- tools/scaffold/golden_path.py +504 -0
- tools/security/__init__.py +1 -0
- tools/security/agent_output_validator.py +330 -0
- tools/security/agent_trust_scorer.py +652 -0
- tools/security/ai_bom_generator.py +718 -0
- tools/security/ai_telemetry_logger.py +469 -0
- tools/security/atlas_red_team.py +541 -0
- tools/security/code_pattern_scanner.py +382 -0
- tools/security/confabulation_detector.py +265 -0
- tools/security/container_scanner.py +489 -0
- tools/security/dependency_auditor.py +942 -0
- tools/security/endpoint_security_scanner.py +626 -0
- tools/security/mcp_tool_authorizer.py +242 -0
- tools/security/output_verifier.py +427 -0
- tools/security/prompt_injection_detector.py +737 -0
- tools/security/sast_runner.py +946 -0
- tools/security/secret_detector.py +376 -0
- tools/security/threat_modeler.py +678 -0
- tools/security/tool_chain_validator.py +357 -0
- tools/security/vuln_scanner.py +536 -0
- tools/simulation/__init__.py +2 -0
- tools/simulation/ato_simulator.py +517 -0
- tools/simulation/coa_generator.py +1539 -0
- tools/simulation/monte_carlo.py +745 -0
- tools/simulation/scenario_manager.py +1060 -0
- tools/simulation/simulation_engine.py +1091 -0
- tools/simulator/__init__.py +2 -0
- tools/simulator/sim_runner.py +272 -0
- tools/supply_chain/__init__.py +2 -0
- tools/supply_chain/cve_triager.py +690 -0
- tools/supply_chain/dependency_graph.py +630 -0
- tools/supply_chain/isa_manager.py +526 -0
- tools/supply_chain/scrm_assessor.py +531 -0
- tools/supply_chain/slsa_verifier.py +473 -0
- tools/testing/__init__.py +2 -0
- tools/testing/acceptance_validator.py +411 -0
- tools/testing/api_surface_extractor.py +749 -0
- tools/testing/claude_dir_validator.py +831 -0
- tools/testing/data_types.py +199 -0
- tools/testing/e2e_runner.py +715 -0
- tools/testing/fuzz_cli.py +306 -0
- tools/testing/health_check.py +483 -0
- tools/testing/platform_check.py +143 -0
- tools/testing/production_audit.py +1836 -0
- tools/testing/production_remediate.py +803 -0
- tools/testing/screenshot_validator.py +538 -0
- tools/testing/smoke_test.py +283 -0
- tools/testing/test_agent_models.py +117 -0
- tools/testing/test_orchestrator.py +957 -0
- tools/testing/utils.py +229 -0
- tools/writeguard/__init__.py +1 -0
- tools/writeguard/main.py +1 -0
- tools/writing/__init__.py +7 -0
- tools/writing/ai_content_detector.py +316 -0
- tools/writing/analysis_engine.py +454 -0
- tools/writing/batch_analyzer.py +276 -0
- tools/writing/coherence_analyzer.py +221 -0
- tools/writing/govcon_bridge.py +509 -0
- tools/writing/grammar_checker.py +270 -0
- tools/writing/plagiarism_detector.py +106 -0
- tools/writing/readability_scorer.py +201 -0
- tools/writing/rewriter.py +96 -0
- tools/writing/signal_registrar.py +167 -0
- tools/writing/snippet_manager.py +276 -0
- tools/writing/style_enforcer.py +220 -0
- tools/writing/style_guide_manager.py +438 -0
- tools/writing/tone_profiler.py +168 -0
|
@@ -0,0 +1,1792 @@
|
|
|
1
|
+
# CUI // SP-CTI
|
|
2
|
+
"""Deploy engine — multi-cloud IaC generation for Forge Studio apps.
|
|
3
|
+
|
|
4
|
+
Generates deployment artifacts for any cloud provider:
|
|
5
|
+
- AWS (ECS Fargate + RDS + S3 — standard and GovCloud regions)
|
|
6
|
+
- Azure (Container Apps + Azure Database for PostgreSQL + Blob Storage)
|
|
7
|
+
- GCP (Cloud Run + Cloud SQL + Cloud Storage)
|
|
8
|
+
- On-Prem / Docker Compose (existing, re-exported here for consistency)
|
|
9
|
+
|
|
10
|
+
Each provider generates:
|
|
11
|
+
1. Terraform HCL (main.tf, variables.tf, outputs.tf)
|
|
12
|
+
2. Environment-specific tfvars (dev, staging, prod)
|
|
13
|
+
3. CI/CD pipeline config (GitHub Actions, GitLab CI, Azure DevOps)
|
|
14
|
+
4. Kubernetes manifests (optional, for K8s-based targets)
|
|
15
|
+
|
|
16
|
+
Architecture decisions:
|
|
17
|
+
- D-FS-DEPLOY-1: Multi-cloud via provider-specific Terraform modules (not CDK/Pulumi — widest adoption)
|
|
18
|
+
- D-FS-DEPLOY-2: All IaC is deterministic template generation (no LLM in deployment path)
|
|
19
|
+
- D-FS-DEPLOY-3: Environment configs are layered: base + provider + env override
|
|
20
|
+
- D-FS-DEPLOY-4: GovCloud is a region variant of AWS, not a separate provider
|
|
21
|
+
|
|
22
|
+
CLI: python tools/forge_studio/deploy/deploy_engine.py --app-id "..." --provider aws --env prod --json
|
|
23
|
+
"""
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
import json
|
|
27
|
+
import logging
|
|
28
|
+
import os
|
|
29
|
+
import time
|
|
30
|
+
import uuid
|
|
31
|
+
from datetime import datetime, timezone
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
from typing import Any, Dict, List, Optional
|
|
34
|
+
|
|
35
|
+
from tools.forge_studio.audit import log_forge_event
|
|
36
|
+
|
|
37
|
+
logger = logging.getLogger("forge_studio.deploy")
|
|
38
|
+
|
|
39
|
+
# ---------------------------------------------------------------------------
|
|
40
|
+
# Supported providers and regions
|
|
41
|
+
# ---------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
PROVIDERS = {
|
|
44
|
+
"aws": {
|
|
45
|
+
"name": "Amazon Web Services",
|
|
46
|
+
"regions": [
|
|
47
|
+
"us-east-1", "us-east-2", "us-west-1", "us-west-2",
|
|
48
|
+
"eu-west-1", "eu-west-2", "eu-central-1",
|
|
49
|
+
"ap-southeast-1", "ap-northeast-1",
|
|
50
|
+
"us-gov-west-1", "us-gov-east-1", # GovCloud
|
|
51
|
+
],
|
|
52
|
+
"govcloud_regions": ["us-gov-west-1", "us-gov-east-1"],
|
|
53
|
+
},
|
|
54
|
+
"azure": {
|
|
55
|
+
"name": "Microsoft Azure",
|
|
56
|
+
"regions": [
|
|
57
|
+
"eastus", "eastus2", "westus2", "westus3",
|
|
58
|
+
"northeurope", "westeurope", "uksouth",
|
|
59
|
+
"southeastasia", "japaneast",
|
|
60
|
+
"usgovvirginia", "usgovarizona", # Azure Government
|
|
61
|
+
],
|
|
62
|
+
"govcloud_regions": ["usgovvirginia", "usgovarizona"],
|
|
63
|
+
},
|
|
64
|
+
"gcp": {
|
|
65
|
+
"name": "Google Cloud Platform",
|
|
66
|
+
"regions": [
|
|
67
|
+
"us-central1", "us-east1", "us-west1",
|
|
68
|
+
"europe-west1", "europe-west2",
|
|
69
|
+
"asia-southeast1", "asia-northeast1",
|
|
70
|
+
],
|
|
71
|
+
"govcloud_regions": [],
|
|
72
|
+
},
|
|
73
|
+
"onprem": {
|
|
74
|
+
"name": "On-Premises / Docker Compose",
|
|
75
|
+
"regions": ["local"],
|
|
76
|
+
"govcloud_regions": [],
|
|
77
|
+
},
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
ENVIRONMENTS = ["dev", "staging", "prod"]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# ---------------------------------------------------------------------------
|
|
84
|
+
# Main deploy generation entry point
|
|
85
|
+
# ---------------------------------------------------------------------------
|
|
86
|
+
|
|
87
|
+
def generate_deployment(
|
|
88
|
+
app_id: str = "",
|
|
89
|
+
app_name: str = "forge-app",
|
|
90
|
+
provider: str = "aws",
|
|
91
|
+
region: str = "",
|
|
92
|
+
environment: str = "prod",
|
|
93
|
+
output_dir: str = "",
|
|
94
|
+
project_id: str = "",
|
|
95
|
+
enable_k8s: bool = False,
|
|
96
|
+
enable_cicd: bool = True,
|
|
97
|
+
domain: str = "",
|
|
98
|
+
replicas: int = 2,
|
|
99
|
+
) -> Dict[str, Any]:
|
|
100
|
+
"""Generate deployment artifacts for a Forge Studio app.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
app_id: App ID (for audit trail)
|
|
104
|
+
app_name: App name for resource naming
|
|
105
|
+
provider: aws | azure | gcp | onprem
|
|
106
|
+
region: Cloud region (default per provider if empty)
|
|
107
|
+
environment: dev | staging | prod
|
|
108
|
+
output_dir: Where to write files (default: .tmp/deploy/{app_name})
|
|
109
|
+
enable_k8s: Generate K8s manifests in addition to provider-native
|
|
110
|
+
enable_cicd: Generate CI/CD pipeline configs
|
|
111
|
+
domain: Custom domain for the app
|
|
112
|
+
replicas: Number of app replicas
|
|
113
|
+
|
|
114
|
+
Returns: {status, provider, region, environment, output_dir, files_created}
|
|
115
|
+
"""
|
|
116
|
+
start = time.time()
|
|
117
|
+
|
|
118
|
+
if provider not in PROVIDERS:
|
|
119
|
+
return {"status": "error", "error": f"Unknown provider: {provider}. Valid: {list(PROVIDERS.keys())}"}
|
|
120
|
+
if environment not in ENVIRONMENTS:
|
|
121
|
+
return {"status": "error", "error": f"Unknown environment: {environment}. Valid: {ENVIRONMENTS}"}
|
|
122
|
+
|
|
123
|
+
safe_name = app_name.lower().replace(" ", "-").replace("_", "-")[:40]
|
|
124
|
+
|
|
125
|
+
# Default region
|
|
126
|
+
if not region:
|
|
127
|
+
region = PROVIDERS[provider]["regions"][0]
|
|
128
|
+
|
|
129
|
+
# Default output
|
|
130
|
+
if not output_dir:
|
|
131
|
+
output_dir = str(Path.cwd() / ".tmp" / "deploy" / safe_name / provider)
|
|
132
|
+
|
|
133
|
+
out = Path(output_dir)
|
|
134
|
+
out.mkdir(parents=True, exist_ok=True)
|
|
135
|
+
|
|
136
|
+
files_created: List[str] = []
|
|
137
|
+
is_govcloud = region in PROVIDERS[provider].get("govcloud_regions", [])
|
|
138
|
+
|
|
139
|
+
config = {
|
|
140
|
+
"app_name": safe_name,
|
|
141
|
+
"app_display_name": app_name,
|
|
142
|
+
"provider": provider,
|
|
143
|
+
"region": region,
|
|
144
|
+
"environment": environment,
|
|
145
|
+
"is_govcloud": is_govcloud,
|
|
146
|
+
"domain": domain or f"{safe_name}.example.com",
|
|
147
|
+
"replicas": replicas,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
# Generate provider-specific Terraform
|
|
151
|
+
if provider == "aws":
|
|
152
|
+
tf_files = _generate_aws_terraform(config)
|
|
153
|
+
elif provider == "azure":
|
|
154
|
+
tf_files = _generate_azure_terraform(config)
|
|
155
|
+
elif provider == "gcp":
|
|
156
|
+
tf_files = _generate_gcp_terraform(config)
|
|
157
|
+
elif provider == "onprem":
|
|
158
|
+
tf_files = _generate_onprem_files(config)
|
|
159
|
+
else:
|
|
160
|
+
tf_files = {}
|
|
161
|
+
|
|
162
|
+
for filepath, content in tf_files.items():
|
|
163
|
+
_write_file(out, filepath, content, files_created)
|
|
164
|
+
|
|
165
|
+
# Environment tfvars
|
|
166
|
+
tfvars = _generate_tfvars(config)
|
|
167
|
+
_write_file(out, f"envs/{environment}.tfvars", tfvars, files_created)
|
|
168
|
+
|
|
169
|
+
# K8s manifests (optional)
|
|
170
|
+
if enable_k8s and provider != "onprem":
|
|
171
|
+
k8s_files = _generate_k8s_manifests(config)
|
|
172
|
+
for filepath, content in k8s_files.items():
|
|
173
|
+
_write_file(out, filepath, content, files_created)
|
|
174
|
+
|
|
175
|
+
# CI/CD pipeline
|
|
176
|
+
if enable_cicd:
|
|
177
|
+
cicd_files = _generate_cicd_pipeline(config)
|
|
178
|
+
for filepath, content in cicd_files.items():
|
|
179
|
+
_write_file(out, filepath, content, files_created)
|
|
180
|
+
|
|
181
|
+
# Deploy record
|
|
182
|
+
deploy_id = f"deploy-{uuid.uuid4().hex[:12]}"
|
|
183
|
+
duration_ms = int((time.time() - start) * 1000)
|
|
184
|
+
|
|
185
|
+
_record_deployment(deploy_id, app_id, config, files_created, project_id)
|
|
186
|
+
|
|
187
|
+
log_forge_event("forge_studio_deploy_generated", {
|
|
188
|
+
"deploy_id": deploy_id,
|
|
189
|
+
"app_id": app_id,
|
|
190
|
+
"app_name": app_name,
|
|
191
|
+
"provider": provider,
|
|
192
|
+
"region": region,
|
|
193
|
+
"environment": environment,
|
|
194
|
+
"is_govcloud": is_govcloud,
|
|
195
|
+
"files_created": len(files_created),
|
|
196
|
+
"duration_ms": duration_ms,
|
|
197
|
+
}, project_id=project_id)
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
"status": "success",
|
|
201
|
+
"deploy_id": deploy_id,
|
|
202
|
+
"provider": PROVIDERS[provider]["name"],
|
|
203
|
+
"region": region,
|
|
204
|
+
"environment": environment,
|
|
205
|
+
"is_govcloud": is_govcloud,
|
|
206
|
+
"output_dir": str(out),
|
|
207
|
+
"files_created": files_created,
|
|
208
|
+
"file_count": len(files_created),
|
|
209
|
+
"duration_ms": duration_ms,
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def list_providers() -> List[Dict[str, Any]]:
|
|
214
|
+
"""List available cloud providers with their regions."""
|
|
215
|
+
return [
|
|
216
|
+
{
|
|
217
|
+
"id": pid,
|
|
218
|
+
"name": p["name"],
|
|
219
|
+
"regions": p["regions"],
|
|
220
|
+
"govcloud_regions": p["govcloud_regions"],
|
|
221
|
+
}
|
|
222
|
+
for pid, p in PROVIDERS.items()
|
|
223
|
+
]
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def get_deployments(app_id: str) -> List[Dict[str, Any]]:
|
|
227
|
+
"""Get deployment history for an app."""
|
|
228
|
+
from tools.db.storage import get_connection
|
|
229
|
+
|
|
230
|
+
with get_connection() as conn:
|
|
231
|
+
rows = conn.execute(
|
|
232
|
+
"SELECT id, app_id, provider, region, environment, status, "
|
|
233
|
+
"config_json, created_at FROM forge_studio_deployments "
|
|
234
|
+
"WHERE app_id = ? ORDER BY created_at DESC",
|
|
235
|
+
(app_id,),
|
|
236
|
+
).fetchall()
|
|
237
|
+
|
|
238
|
+
return [
|
|
239
|
+
{
|
|
240
|
+
"id": r[0], "app_id": r[1], "provider": r[2], "region": r[3],
|
|
241
|
+
"environment": r[4], "status": r[5],
|
|
242
|
+
"config": json.loads(r[6]) if r[6] else {},
|
|
243
|
+
"created_at": r[7],
|
|
244
|
+
}
|
|
245
|
+
for r in rows
|
|
246
|
+
]
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
# ---------------------------------------------------------------------------
|
|
250
|
+
# AWS Terraform
|
|
251
|
+
# ---------------------------------------------------------------------------
|
|
252
|
+
|
|
253
|
+
def _generate_aws_terraform(config: Dict[str, Any]) -> Dict[str, str]:
|
|
254
|
+
name = config["app_name"]
|
|
255
|
+
region = config["region"]
|
|
256
|
+
env = config["environment"]
|
|
257
|
+
is_gov = config["is_govcloud"]
|
|
258
|
+
domain = config["domain"]
|
|
259
|
+
replicas = config["replicas"]
|
|
260
|
+
|
|
261
|
+
partition = "aws-us-gov" if is_gov else "aws"
|
|
262
|
+
|
|
263
|
+
main_tf = f'''# CUI // SP-CTI
|
|
264
|
+
# Terraform — AWS deployment for {config["app_display_name"]}
|
|
265
|
+
# Provider: AWS {"GovCloud " if is_gov else ""}({region})
|
|
266
|
+
# Environment: {env}
|
|
267
|
+
# Generated by Forge Studio
|
|
268
|
+
|
|
269
|
+
terraform {{
|
|
270
|
+
required_version = ">= 1.5"
|
|
271
|
+
required_providers {{
|
|
272
|
+
aws = {{
|
|
273
|
+
source = "hashicorp/aws"
|
|
274
|
+
version = "~> 5.0"
|
|
275
|
+
}}
|
|
276
|
+
}}
|
|
277
|
+
backend "s3" {{
|
|
278
|
+
bucket = "{name}-terraform-state"
|
|
279
|
+
key = "{env}/terraform.tfstate"
|
|
280
|
+
region = "{region}"
|
|
281
|
+
encrypt = true
|
|
282
|
+
dynamodb_table = "{name}-terraform-locks"
|
|
283
|
+
}}
|
|
284
|
+
}}
|
|
285
|
+
|
|
286
|
+
provider "aws" {{
|
|
287
|
+
region = var.region
|
|
288
|
+
default_tags {{
|
|
289
|
+
tags = {{
|
|
290
|
+
Project = var.app_name
|
|
291
|
+
Environment = var.environment
|
|
292
|
+
ManagedBy = "terraform"
|
|
293
|
+
Generator = "forge-studio"
|
|
294
|
+
}}
|
|
295
|
+
}}
|
|
296
|
+
}}
|
|
297
|
+
|
|
298
|
+
# ── VPC ─────────────────────────────────────────────────────
|
|
299
|
+
module "vpc" {{
|
|
300
|
+
source = "terraform-aws-modules/vpc/aws"
|
|
301
|
+
version = "~> 5.0"
|
|
302
|
+
|
|
303
|
+
name = "${{var.app_name}}-${{var.environment}}"
|
|
304
|
+
cidr = var.vpc_cidr
|
|
305
|
+
|
|
306
|
+
azs = ["${{var.region}}a", "${{var.region}}b", "${{var.region}}c"]
|
|
307
|
+
private_subnets = var.private_subnets
|
|
308
|
+
public_subnets = var.public_subnets
|
|
309
|
+
|
|
310
|
+
enable_nat_gateway = true
|
|
311
|
+
single_nat_gateway = var.environment != "prod"
|
|
312
|
+
enable_dns_hostnames = true
|
|
313
|
+
enable_dns_support = true
|
|
314
|
+
}}
|
|
315
|
+
|
|
316
|
+
# ── RDS PostgreSQL (Supabase-compatible) ────────────────────
|
|
317
|
+
resource "aws_db_subnet_group" "main" {{
|
|
318
|
+
name = "${{var.app_name}}-${{var.environment}}"
|
|
319
|
+
subnet_ids = module.vpc.private_subnets
|
|
320
|
+
}}
|
|
321
|
+
|
|
322
|
+
resource "aws_security_group" "rds" {{
|
|
323
|
+
name_prefix = "${{var.app_name}}-rds-"
|
|
324
|
+
vpc_id = module.vpc.vpc_id
|
|
325
|
+
|
|
326
|
+
ingress {{
|
|
327
|
+
from_port = 5432
|
|
328
|
+
to_port = 5432
|
|
329
|
+
protocol = "tcp"
|
|
330
|
+
security_groups = [aws_security_group.app.id]
|
|
331
|
+
}}
|
|
332
|
+
}}
|
|
333
|
+
|
|
334
|
+
resource "aws_db_instance" "main" {{
|
|
335
|
+
identifier = "${{var.app_name}}-${{var.environment}}"
|
|
336
|
+
engine = "postgres"
|
|
337
|
+
engine_version = "15.6"
|
|
338
|
+
instance_class = var.db_instance_class
|
|
339
|
+
|
|
340
|
+
allocated_storage = var.db_storage_gb
|
|
341
|
+
max_allocated_storage = var.db_max_storage_gb
|
|
342
|
+
storage_encrypted = true
|
|
343
|
+
|
|
344
|
+
db_name = "app"
|
|
345
|
+
username = "supabase_admin"
|
|
346
|
+
password = var.db_password
|
|
347
|
+
|
|
348
|
+
db_subnet_group_name = aws_db_subnet_group.main.name
|
|
349
|
+
vpc_security_group_ids = [aws_security_group.rds.id]
|
|
350
|
+
|
|
351
|
+
backup_retention_period = var.environment == "prod" ? 30 : 7
|
|
352
|
+
multi_az = var.environment == "prod"
|
|
353
|
+
deletion_protection = var.environment == "prod"
|
|
354
|
+
skip_final_snapshot = var.environment != "prod"
|
|
355
|
+
|
|
356
|
+
performance_insights_enabled = true
|
|
357
|
+
}}
|
|
358
|
+
|
|
359
|
+
# ── ECS Fargate ─────────────────────────────────────────────
|
|
360
|
+
resource "aws_security_group" "app" {{
|
|
361
|
+
name_prefix = "${{var.app_name}}-app-"
|
|
362
|
+
vpc_id = module.vpc.vpc_id
|
|
363
|
+
|
|
364
|
+
ingress {{
|
|
365
|
+
from_port = 3000
|
|
366
|
+
to_port = 3000
|
|
367
|
+
protocol = "tcp"
|
|
368
|
+
security_groups = [aws_security_group.alb.id]
|
|
369
|
+
}}
|
|
370
|
+
|
|
371
|
+
egress {{
|
|
372
|
+
from_port = 0
|
|
373
|
+
to_port = 0
|
|
374
|
+
protocol = "-1"
|
|
375
|
+
cidr_blocks = ["0.0.0.0/0"]
|
|
376
|
+
}}
|
|
377
|
+
}}
|
|
378
|
+
|
|
379
|
+
resource "aws_ecs_cluster" "main" {{
|
|
380
|
+
name = "${{var.app_name}}-${{var.environment}}"
|
|
381
|
+
|
|
382
|
+
setting {{
|
|
383
|
+
name = "containerInsights"
|
|
384
|
+
value = "enabled"
|
|
385
|
+
}}
|
|
386
|
+
}}
|
|
387
|
+
|
|
388
|
+
resource "aws_ecs_task_definition" "app" {{
|
|
389
|
+
family = "${{var.app_name}}-${{var.environment}}"
|
|
390
|
+
requires_compatibilities = ["FARGATE"]
|
|
391
|
+
network_mode = "awsvpc"
|
|
392
|
+
cpu = var.app_cpu
|
|
393
|
+
memory = var.app_memory
|
|
394
|
+
execution_role_arn = aws_iam_role.ecs_execution.arn
|
|
395
|
+
task_role_arn = aws_iam_role.ecs_task.arn
|
|
396
|
+
|
|
397
|
+
container_definitions = jsonencode([
|
|
398
|
+
{{
|
|
399
|
+
name = "app"
|
|
400
|
+
image = "${{var.ecr_repository_url}}:${{var.image_tag}}"
|
|
401
|
+
portMappings = [{{ containerPort = 3000, protocol = "tcp" }}]
|
|
402
|
+
environment = [
|
|
403
|
+
{{ name = "NODE_ENV", value = var.environment }},
|
|
404
|
+
{{ name = "NEXT_PUBLIC_SUPABASE_URL", value = var.supabase_url }},
|
|
405
|
+
{{ name = "NEXT_PUBLIC_SUPABASE_ANON_KEY", value = var.supabase_anon_key }},
|
|
406
|
+
]
|
|
407
|
+
logConfiguration = {{
|
|
408
|
+
logDriver = "awslogs"
|
|
409
|
+
options = {{
|
|
410
|
+
"awslogs-group" = "/ecs/${{var.app_name}}-${{var.environment}}"
|
|
411
|
+
"awslogs-region" = var.region
|
|
412
|
+
"awslogs-stream-prefix" = "app"
|
|
413
|
+
}}
|
|
414
|
+
}}
|
|
415
|
+
healthCheck = {{
|
|
416
|
+
command = ["CMD-SHELL", "curl -f http://localhost:3000/ || exit 1"]
|
|
417
|
+
interval = 30
|
|
418
|
+
timeout = 5
|
|
419
|
+
retries = 3
|
|
420
|
+
startPeriod = 60
|
|
421
|
+
}}
|
|
422
|
+
}}
|
|
423
|
+
])
|
|
424
|
+
}}
|
|
425
|
+
|
|
426
|
+
resource "aws_ecs_service" "app" {{
|
|
427
|
+
name = "${{var.app_name}}-${{var.environment}}"
|
|
428
|
+
cluster = aws_ecs_cluster.main.id
|
|
429
|
+
task_definition = aws_ecs_task_definition.app.arn
|
|
430
|
+
desired_count = var.replicas
|
|
431
|
+
launch_type = "FARGATE"
|
|
432
|
+
|
|
433
|
+
network_configuration {{
|
|
434
|
+
subnets = module.vpc.private_subnets
|
|
435
|
+
security_groups = [aws_security_group.app.id]
|
|
436
|
+
}}
|
|
437
|
+
|
|
438
|
+
load_balancer {{
|
|
439
|
+
target_group_arn = aws_lb_target_group.app.arn
|
|
440
|
+
container_name = "app"
|
|
441
|
+
container_port = 3000
|
|
442
|
+
}}
|
|
443
|
+
|
|
444
|
+
deployment_circuit_breaker {{
|
|
445
|
+
enable = true
|
|
446
|
+
rollback = true
|
|
447
|
+
}}
|
|
448
|
+
}}
|
|
449
|
+
|
|
450
|
+
# ── ALB ─────────────────────────────────────────────────────
|
|
451
|
+
resource "aws_security_group" "alb" {{
|
|
452
|
+
name_prefix = "${{var.app_name}}-alb-"
|
|
453
|
+
vpc_id = module.vpc.vpc_id
|
|
454
|
+
|
|
455
|
+
ingress {{
|
|
456
|
+
from_port = 443
|
|
457
|
+
to_port = 443
|
|
458
|
+
protocol = "tcp"
|
|
459
|
+
cidr_blocks = ["0.0.0.0/0"]
|
|
460
|
+
}}
|
|
461
|
+
|
|
462
|
+
ingress {{
|
|
463
|
+
from_port = 80
|
|
464
|
+
to_port = 80
|
|
465
|
+
protocol = "tcp"
|
|
466
|
+
cidr_blocks = ["0.0.0.0/0"]
|
|
467
|
+
}}
|
|
468
|
+
|
|
469
|
+
egress {{
|
|
470
|
+
from_port = 0
|
|
471
|
+
to_port = 0
|
|
472
|
+
protocol = "-1"
|
|
473
|
+
cidr_blocks = ["0.0.0.0/0"]
|
|
474
|
+
}}
|
|
475
|
+
}}
|
|
476
|
+
|
|
477
|
+
resource "aws_lb" "main" {{
|
|
478
|
+
name = "${{var.app_name}}-${{var.environment}}"
|
|
479
|
+
internal = false
|
|
480
|
+
load_balancer_type = "application"
|
|
481
|
+
security_groups = [aws_security_group.alb.id]
|
|
482
|
+
subnets = module.vpc.public_subnets
|
|
483
|
+
|
|
484
|
+
enable_deletion_protection = var.environment == "prod"
|
|
485
|
+
}}
|
|
486
|
+
|
|
487
|
+
resource "aws_lb_target_group" "app" {{
|
|
488
|
+
name = "${{var.app_name}}-${{var.environment}}"
|
|
489
|
+
port = 3000
|
|
490
|
+
protocol = "HTTP"
|
|
491
|
+
vpc_id = module.vpc.vpc_id
|
|
492
|
+
target_type = "ip"
|
|
493
|
+
|
|
494
|
+
health_check {{
|
|
495
|
+
path = "/"
|
|
496
|
+
healthy_threshold = 2
|
|
497
|
+
unhealthy_threshold = 3
|
|
498
|
+
timeout = 5
|
|
499
|
+
interval = 30
|
|
500
|
+
}}
|
|
501
|
+
}}
|
|
502
|
+
|
|
503
|
+
resource "aws_lb_listener" "https" {{
|
|
504
|
+
load_balancer_arn = aws_lb.main.arn
|
|
505
|
+
port = "443"
|
|
506
|
+
protocol = "HTTPS"
|
|
507
|
+
ssl_policy = "ELBSecurityPolicy-TLS13-1-2-2021-06"
|
|
508
|
+
certificate_arn = var.acm_certificate_arn
|
|
509
|
+
|
|
510
|
+
default_action {{
|
|
511
|
+
type = "forward"
|
|
512
|
+
target_group_arn = aws_lb_target_group.app.arn
|
|
513
|
+
}}
|
|
514
|
+
}}
|
|
515
|
+
|
|
516
|
+
resource "aws_lb_listener" "http_redirect" {{
|
|
517
|
+
load_balancer_arn = aws_lb.main.arn
|
|
518
|
+
port = "80"
|
|
519
|
+
protocol = "HTTP"
|
|
520
|
+
|
|
521
|
+
default_action {{
|
|
522
|
+
type = "redirect"
|
|
523
|
+
redirect {{
|
|
524
|
+
port = "443"
|
|
525
|
+
protocol = "HTTPS"
|
|
526
|
+
status_code = "HTTP_301"
|
|
527
|
+
}}
|
|
528
|
+
}}
|
|
529
|
+
}}
|
|
530
|
+
|
|
531
|
+
# ── IAM Roles ───────────────────────────────────────────────
|
|
532
|
+
resource "aws_iam_role" "ecs_execution" {{
|
|
533
|
+
name = "${{var.app_name}}-${{var.environment}}-ecs-exec"
|
|
534
|
+
assume_role_policy = jsonencode({{
|
|
535
|
+
Version = "2012-10-17"
|
|
536
|
+
Statement = [{{
|
|
537
|
+
Action = "sts:AssumeRole"
|
|
538
|
+
Effect = "Allow"
|
|
539
|
+
Principal = {{ Service = "ecs-tasks.amazonaws.com" }}
|
|
540
|
+
}}]
|
|
541
|
+
}})
|
|
542
|
+
}}
|
|
543
|
+
|
|
544
|
+
resource "aws_iam_role_policy_attachment" "ecs_execution" {{
|
|
545
|
+
role = aws_iam_role.ecs_execution.name
|
|
546
|
+
policy_arn = "arn:{partition}:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
|
|
547
|
+
}}
|
|
548
|
+
|
|
549
|
+
resource "aws_iam_role" "ecs_task" {{
|
|
550
|
+
name = "${{var.app_name}}-${{var.environment}}-ecs-task"
|
|
551
|
+
assume_role_policy = jsonencode({{
|
|
552
|
+
Version = "2012-10-17"
|
|
553
|
+
Statement = [{{
|
|
554
|
+
Action = "sts:AssumeRole"
|
|
555
|
+
Effect = "Allow"
|
|
556
|
+
Principal = {{ Service = "ecs-tasks.amazonaws.com" }}
|
|
557
|
+
}}]
|
|
558
|
+
}})
|
|
559
|
+
}}
|
|
560
|
+
|
|
561
|
+
# ── S3 for static assets ───────────────────────────────────
|
|
562
|
+
resource "aws_s3_bucket" "assets" {{
|
|
563
|
+
bucket = "${{var.app_name}}-${{var.environment}}-assets"
|
|
564
|
+
}}
|
|
565
|
+
|
|
566
|
+
resource "aws_s3_bucket_server_side_encryption_configuration" "assets" {{
|
|
567
|
+
bucket = aws_s3_bucket.assets.id
|
|
568
|
+
rule {{
|
|
569
|
+
apply_server_side_encryption_by_default {{
|
|
570
|
+
sse_algorithm = "aws:kms"
|
|
571
|
+
}}
|
|
572
|
+
}}
|
|
573
|
+
}}
|
|
574
|
+
|
|
575
|
+
resource "aws_s3_bucket_public_access_block" "assets" {{
|
|
576
|
+
bucket = aws_s3_bucket.assets.id
|
|
577
|
+
block_public_acls = true
|
|
578
|
+
block_public_policy = true
|
|
579
|
+
ignore_public_acls = true
|
|
580
|
+
restrict_public_buckets = true
|
|
581
|
+
}}
|
|
582
|
+
|
|
583
|
+
# ── CloudWatch Logs ─────────────────────────────────────────
|
|
584
|
+
resource "aws_cloudwatch_log_group" "app" {{
|
|
585
|
+
name = "/ecs/${{var.app_name}}-${{var.environment}}"
|
|
586
|
+
retention_in_days = var.environment == "prod" ? 365 : 30
|
|
587
|
+
}}
|
|
588
|
+
'''
|
|
589
|
+
|
|
590
|
+
variables_tf = f'''# CUI // SP-CTI
|
|
591
|
+
# Variables for {config["app_display_name"]} AWS deployment
|
|
592
|
+
|
|
593
|
+
variable "app_name" {{
|
|
594
|
+
type = string
|
|
595
|
+
default = "{name}"
|
|
596
|
+
}}
|
|
597
|
+
|
|
598
|
+
variable "environment" {{
|
|
599
|
+
type = string
|
|
600
|
+
default = "{env}"
|
|
601
|
+
}}
|
|
602
|
+
|
|
603
|
+
variable "region" {{
|
|
604
|
+
type = string
|
|
605
|
+
default = "{region}"
|
|
606
|
+
}}
|
|
607
|
+
|
|
608
|
+
variable "vpc_cidr" {{
|
|
609
|
+
type = string
|
|
610
|
+
default = "10.0.0.0/16"
|
|
611
|
+
}}
|
|
612
|
+
|
|
613
|
+
variable "private_subnets" {{
|
|
614
|
+
type = list(string)
|
|
615
|
+
default = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
|
|
616
|
+
}}
|
|
617
|
+
|
|
618
|
+
variable "public_subnets" {{
|
|
619
|
+
type = list(string)
|
|
620
|
+
default = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
|
|
621
|
+
}}
|
|
622
|
+
|
|
623
|
+
variable "db_instance_class" {{
|
|
624
|
+
type = string
|
|
625
|
+
default = "db.t4g.medium"
|
|
626
|
+
}}
|
|
627
|
+
|
|
628
|
+
variable "db_storage_gb" {{
|
|
629
|
+
type = number
|
|
630
|
+
default = 20
|
|
631
|
+
}}
|
|
632
|
+
|
|
633
|
+
variable "db_max_storage_gb" {{
|
|
634
|
+
type = number
|
|
635
|
+
default = 100
|
|
636
|
+
}}
|
|
637
|
+
|
|
638
|
+
variable "db_password" {{
|
|
639
|
+
type = string
|
|
640
|
+
sensitive = true
|
|
641
|
+
}}
|
|
642
|
+
|
|
643
|
+
variable "app_cpu" {{
|
|
644
|
+
type = number
|
|
645
|
+
default = 512
|
|
646
|
+
}}
|
|
647
|
+
|
|
648
|
+
variable "app_memory" {{
|
|
649
|
+
type = number
|
|
650
|
+
default = 1024
|
|
651
|
+
}}
|
|
652
|
+
|
|
653
|
+
variable "replicas" {{
|
|
654
|
+
type = number
|
|
655
|
+
default = {replicas}
|
|
656
|
+
}}
|
|
657
|
+
|
|
658
|
+
variable "ecr_repository_url" {{
|
|
659
|
+
type = string
|
|
660
|
+
}}
|
|
661
|
+
|
|
662
|
+
variable "image_tag" {{
|
|
663
|
+
type = string
|
|
664
|
+
default = "latest"
|
|
665
|
+
}}
|
|
666
|
+
|
|
667
|
+
variable "supabase_url" {{
|
|
668
|
+
type = string
|
|
669
|
+
}}
|
|
670
|
+
|
|
671
|
+
variable "supabase_anon_key" {{
|
|
672
|
+
type = string
|
|
673
|
+
sensitive = true
|
|
674
|
+
}}
|
|
675
|
+
|
|
676
|
+
variable "acm_certificate_arn" {{
|
|
677
|
+
type = string
|
|
678
|
+
default = ""
|
|
679
|
+
}}
|
|
680
|
+
'''
|
|
681
|
+
|
|
682
|
+
outputs_tf = f'''# CUI // SP-CTI
|
|
683
|
+
# Outputs for {config["app_display_name"]} AWS deployment
|
|
684
|
+
|
|
685
|
+
output "app_url" {{
|
|
686
|
+
value = "https://${{aws_lb.main.dns_name}}"
|
|
687
|
+
}}
|
|
688
|
+
|
|
689
|
+
output "rds_endpoint" {{
|
|
690
|
+
value = aws_db_instance.main.endpoint
|
|
691
|
+
sensitive = true
|
|
692
|
+
}}
|
|
693
|
+
|
|
694
|
+
output "ecs_cluster_name" {{
|
|
695
|
+
value = aws_ecs_cluster.main.name
|
|
696
|
+
}}
|
|
697
|
+
|
|
698
|
+
output "alb_dns_name" {{
|
|
699
|
+
value = aws_lb.main.dns_name
|
|
700
|
+
}}
|
|
701
|
+
|
|
702
|
+
output "s3_bucket" {{
|
|
703
|
+
value = aws_s3_bucket.assets.bucket
|
|
704
|
+
}}
|
|
705
|
+
'''
|
|
706
|
+
|
|
707
|
+
return {
|
|
708
|
+
"terraform/main.tf": main_tf,
|
|
709
|
+
"terraform/variables.tf": variables_tf,
|
|
710
|
+
"terraform/outputs.tf": outputs_tf,
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
# ---------------------------------------------------------------------------
|
|
715
|
+
# Azure Terraform
|
|
716
|
+
# ---------------------------------------------------------------------------
|
|
717
|
+
|
|
718
|
+
def _generate_azure_terraform(config: Dict[str, Any]) -> Dict[str, str]:
|
|
719
|
+
name = config["app_name"]
|
|
720
|
+
region = config["region"]
|
|
721
|
+
env = config["environment"]
|
|
722
|
+
replicas = config["replicas"]
|
|
723
|
+
|
|
724
|
+
main_tf = f'''# CUI // SP-CTI
|
|
725
|
+
# Terraform — Azure deployment for {config["app_display_name"]}
|
|
726
|
+
# Provider: Azure ({region})
|
|
727
|
+
# Environment: {env}
|
|
728
|
+
# Generated by Forge Studio
|
|
729
|
+
|
|
730
|
+
terraform {{
|
|
731
|
+
required_version = ">= 1.5"
|
|
732
|
+
required_providers {{
|
|
733
|
+
azurerm = {{
|
|
734
|
+
source = "hashicorp/azurerm"
|
|
735
|
+
version = "~> 3.0"
|
|
736
|
+
}}
|
|
737
|
+
}}
|
|
738
|
+
backend "azurerm" {{
|
|
739
|
+
resource_group_name = "{name}-tfstate"
|
|
740
|
+
storage_account_name = "{name.replace('-', '')}tfstate"
|
|
741
|
+
container_name = "tfstate"
|
|
742
|
+
key = "{env}/terraform.tfstate"
|
|
743
|
+
}}
|
|
744
|
+
}}
|
|
745
|
+
|
|
746
|
+
provider "azurerm" {{
|
|
747
|
+
features {{}}
|
|
748
|
+
}}
|
|
749
|
+
|
|
750
|
+
# ── Resource Group ──────────────────────────────────────────
|
|
751
|
+
resource "azurerm_resource_group" "main" {{
|
|
752
|
+
name = "${{var.app_name}}-${{var.environment}}-rg"
|
|
753
|
+
location = var.region
|
|
754
|
+
|
|
755
|
+
tags = {{
|
|
756
|
+
Project = var.app_name
|
|
757
|
+
Environment = var.environment
|
|
758
|
+
ManagedBy = "terraform"
|
|
759
|
+
Generator = "forge-studio"
|
|
760
|
+
}}
|
|
761
|
+
}}
|
|
762
|
+
|
|
763
|
+
# ── Azure Database for PostgreSQL Flexible Server ───────────
|
|
764
|
+
resource "azurerm_postgresql_flexible_server" "main" {{
|
|
765
|
+
name = "${{var.app_name}}-${{var.environment}}-pg"
|
|
766
|
+
resource_group_name = azurerm_resource_group.main.name
|
|
767
|
+
location = azurerm_resource_group.main.location
|
|
768
|
+
version = "15"
|
|
769
|
+
administrator_login = "supabase_admin"
|
|
770
|
+
administrator_password = var.db_password
|
|
771
|
+
storage_mb = var.db_storage_mb
|
|
772
|
+
sku_name = var.db_sku
|
|
773
|
+
zone = "1"
|
|
774
|
+
|
|
775
|
+
backup_retention_days = var.environment == "prod" ? 30 : 7
|
|
776
|
+
}}
|
|
777
|
+
|
|
778
|
+
resource "azurerm_postgresql_flexible_server_database" "app" {{
|
|
779
|
+
name = "app"
|
|
780
|
+
server_id = azurerm_postgresql_flexible_server.main.id
|
|
781
|
+
charset = "UTF8"
|
|
782
|
+
collation = "en_US.utf8"
|
|
783
|
+
}}
|
|
784
|
+
|
|
785
|
+
resource "azurerm_postgresql_flexible_server_firewall_rule" "azure_services" {{
|
|
786
|
+
name = "AllowAzureServices"
|
|
787
|
+
server_id = azurerm_postgresql_flexible_server.main.id
|
|
788
|
+
start_ip_address = "0.0.0.0"
|
|
789
|
+
end_ip_address = "0.0.0.0"
|
|
790
|
+
}}
|
|
791
|
+
|
|
792
|
+
# ── Container Apps Environment ──────────────────────────────
|
|
793
|
+
resource "azurerm_log_analytics_workspace" "main" {{
|
|
794
|
+
name = "${{var.app_name}}-${{var.environment}}-logs"
|
|
795
|
+
resource_group_name = azurerm_resource_group.main.name
|
|
796
|
+
location = azurerm_resource_group.main.location
|
|
797
|
+
sku = "PerGB2018"
|
|
798
|
+
retention_in_days = var.environment == "prod" ? 365 : 30
|
|
799
|
+
}}
|
|
800
|
+
|
|
801
|
+
resource "azurerm_container_app_environment" "main" {{
|
|
802
|
+
name = "${{var.app_name}}-${{var.environment}}-env"
|
|
803
|
+
resource_group_name = azurerm_resource_group.main.name
|
|
804
|
+
location = azurerm_resource_group.main.location
|
|
805
|
+
log_analytics_workspace_id = azurerm_log_analytics_workspace.main.id
|
|
806
|
+
}}
|
|
807
|
+
|
|
808
|
+
# ── Container App ───────────────────────────────────────────
|
|
809
|
+
resource "azurerm_container_app" "app" {{
|
|
810
|
+
name = "${{var.app_name}}-${{var.environment}}"
|
|
811
|
+
container_app_environment_id = azurerm_container_app_environment.main.id
|
|
812
|
+
resource_group_name = azurerm_resource_group.main.name
|
|
813
|
+
revision_mode = "Single"
|
|
814
|
+
|
|
815
|
+
template {{
|
|
816
|
+
min_replicas = var.environment == "prod" ? {replicas} : 1
|
|
817
|
+
max_replicas = var.environment == "prod" ? {replicas * 2} : 2
|
|
818
|
+
|
|
819
|
+
container {{
|
|
820
|
+
name = "app"
|
|
821
|
+
image = "${{var.container_registry}}/${{var.app_name}}:${{var.image_tag}}"
|
|
822
|
+
cpu = var.app_cpu
|
|
823
|
+
memory = var.app_memory
|
|
824
|
+
|
|
825
|
+
env {{
|
|
826
|
+
name = "NODE_ENV"
|
|
827
|
+
value = var.environment
|
|
828
|
+
}}
|
|
829
|
+
env {{
|
|
830
|
+
name = "NEXT_PUBLIC_SUPABASE_URL"
|
|
831
|
+
value = var.supabase_url
|
|
832
|
+
}}
|
|
833
|
+
env {{
|
|
834
|
+
name = "NEXT_PUBLIC_SUPABASE_ANON_KEY"
|
|
835
|
+
secret_name = "supabase-anon-key"
|
|
836
|
+
}}
|
|
837
|
+
|
|
838
|
+
liveness_probe {{
|
|
839
|
+
transport = "HTTP"
|
|
840
|
+
port = 3000
|
|
841
|
+
path = "/"
|
|
842
|
+
}}
|
|
843
|
+
}}
|
|
844
|
+
}}
|
|
845
|
+
|
|
846
|
+
ingress {{
|
|
847
|
+
external_enabled = true
|
|
848
|
+
target_port = 3000
|
|
849
|
+
transport = "auto"
|
|
850
|
+
traffic_weight {{
|
|
851
|
+
percentage = 100
|
|
852
|
+
latest_revision = true
|
|
853
|
+
}}
|
|
854
|
+
}}
|
|
855
|
+
|
|
856
|
+
secret {{
|
|
857
|
+
name = "supabase-anon-key"
|
|
858
|
+
value = var.supabase_anon_key
|
|
859
|
+
}}
|
|
860
|
+
}}
|
|
861
|
+
|
|
862
|
+
# ── Storage Account ─────────────────────────────────────────
|
|
863
|
+
resource "azurerm_storage_account" "assets" {{
|
|
864
|
+
name = "${{replace(var.app_name, "-", "")}}${{var.environment}}"
|
|
865
|
+
resource_group_name = azurerm_resource_group.main.name
|
|
866
|
+
location = azurerm_resource_group.main.location
|
|
867
|
+
account_tier = "Standard"
|
|
868
|
+
account_replication_type = var.environment == "prod" ? "GRS" : "LRS"
|
|
869
|
+
min_tls_version = "TLS1_2"
|
|
870
|
+
|
|
871
|
+
blob_properties {{
|
|
872
|
+
delete_retention_policy {{
|
|
873
|
+
days = 30
|
|
874
|
+
}}
|
|
875
|
+
}}
|
|
876
|
+
}}
|
|
877
|
+
'''
|
|
878
|
+
|
|
879
|
+
variables_tf = f'''# CUI // SP-CTI
|
|
880
|
+
variable "app_name" {{
|
|
881
|
+
type = string
|
|
882
|
+
default = "{name}"
|
|
883
|
+
}}
|
|
884
|
+
variable "environment" {{
|
|
885
|
+
type = string
|
|
886
|
+
default = "{env}"
|
|
887
|
+
}}
|
|
888
|
+
variable "region" {{
|
|
889
|
+
type = string
|
|
890
|
+
default = "{region}"
|
|
891
|
+
}}
|
|
892
|
+
variable "db_password" {{
|
|
893
|
+
type = string
|
|
894
|
+
sensitive = true
|
|
895
|
+
}}
|
|
896
|
+
variable "db_storage_mb" {{
|
|
897
|
+
type = number
|
|
898
|
+
default = 32768
|
|
899
|
+
}}
|
|
900
|
+
variable "db_sku" {{
|
|
901
|
+
type = string
|
|
902
|
+
default = "B_Standard_B1ms"
|
|
903
|
+
}}
|
|
904
|
+
variable "app_cpu" {{
|
|
905
|
+
type = number
|
|
906
|
+
default = 0.5
|
|
907
|
+
}}
|
|
908
|
+
variable "app_memory" {{
|
|
909
|
+
type = string
|
|
910
|
+
default = "1Gi"
|
|
911
|
+
}}
|
|
912
|
+
variable "container_registry" {{
|
|
913
|
+
type = string
|
|
914
|
+
}}
|
|
915
|
+
variable "image_tag" {{
|
|
916
|
+
type = string
|
|
917
|
+
default = "latest"
|
|
918
|
+
}}
|
|
919
|
+
variable "supabase_url" {{
|
|
920
|
+
type = string
|
|
921
|
+
}}
|
|
922
|
+
variable "supabase_anon_key" {{
|
|
923
|
+
type = string
|
|
924
|
+
sensitive = true
|
|
925
|
+
}}
|
|
926
|
+
'''
|
|
927
|
+
|
|
928
|
+
outputs_tf = f'''# CUI // SP-CTI
|
|
929
|
+
output "app_url" {{
|
|
930
|
+
value = "https://${{azurerm_container_app.app.latest_revision_fqdn}}"
|
|
931
|
+
}}
|
|
932
|
+
output "db_fqdn" {{
|
|
933
|
+
value = azurerm_postgresql_flexible_server.main.fqdn
|
|
934
|
+
sensitive = true
|
|
935
|
+
}}
|
|
936
|
+
output "storage_account" {{
|
|
937
|
+
value = azurerm_storage_account.assets.name
|
|
938
|
+
}}
|
|
939
|
+
'''
|
|
940
|
+
|
|
941
|
+
return {
|
|
942
|
+
"terraform/main.tf": main_tf,
|
|
943
|
+
"terraform/variables.tf": variables_tf,
|
|
944
|
+
"terraform/outputs.tf": outputs_tf,
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
# ---------------------------------------------------------------------------
|
|
949
|
+
# GCP Terraform
|
|
950
|
+
# ---------------------------------------------------------------------------
|
|
951
|
+
|
|
952
|
+
def _generate_gcp_terraform(config: Dict[str, Any]) -> Dict[str, str]:
|
|
953
|
+
name = config["app_name"]
|
|
954
|
+
region = config["region"]
|
|
955
|
+
env = config["environment"]
|
|
956
|
+
replicas = config["replicas"]
|
|
957
|
+
|
|
958
|
+
main_tf = f'''# CUI // SP-CTI
|
|
959
|
+
# Terraform — GCP deployment for {config["app_display_name"]}
|
|
960
|
+
# Provider: Google Cloud ({region})
|
|
961
|
+
# Environment: {env}
|
|
962
|
+
# Generated by Forge Studio
|
|
963
|
+
|
|
964
|
+
terraform {{
|
|
965
|
+
required_version = ">= 1.5"
|
|
966
|
+
required_providers {{
|
|
967
|
+
google = {{
|
|
968
|
+
source = "hashicorp/google"
|
|
969
|
+
version = "~> 5.0"
|
|
970
|
+
}}
|
|
971
|
+
}}
|
|
972
|
+
backend "gcs" {{
|
|
973
|
+
bucket = "{name}-terraform-state"
|
|
974
|
+
prefix = "{env}"
|
|
975
|
+
}}
|
|
976
|
+
}}
|
|
977
|
+
|
|
978
|
+
provider "google" {{
|
|
979
|
+
project = var.project_id
|
|
980
|
+
region = var.region
|
|
981
|
+
}}
|
|
982
|
+
|
|
983
|
+
# ── Cloud SQL PostgreSQL ────────────────────────────────────
|
|
984
|
+
resource "google_sql_database_instance" "main" {{
|
|
985
|
+
name = "${{var.app_name}}-${{var.environment}}"
|
|
986
|
+
database_version = "POSTGRES_15"
|
|
987
|
+
region = var.region
|
|
988
|
+
|
|
989
|
+
settings {{
|
|
990
|
+
tier = var.db_tier
|
|
991
|
+
availability_type = var.environment == "prod" ? "REGIONAL" : "ZONAL"
|
|
992
|
+
disk_size = var.db_disk_gb
|
|
993
|
+
disk_autoresize = true
|
|
994
|
+
|
|
995
|
+
backup_configuration {{
|
|
996
|
+
enabled = true
|
|
997
|
+
point_in_time_recovery_enabled = var.environment == "prod"
|
|
998
|
+
backup_retention_settings {{
|
|
999
|
+
retained_backups = var.environment == "prod" ? 30 : 7
|
|
1000
|
+
}}
|
|
1001
|
+
}}
|
|
1002
|
+
|
|
1003
|
+
ip_configuration {{
|
|
1004
|
+
ipv4_enabled = false
|
|
1005
|
+
private_network = google_compute_network.main.id
|
|
1006
|
+
}}
|
|
1007
|
+
}}
|
|
1008
|
+
|
|
1009
|
+
deletion_protection = var.environment == "prod"
|
|
1010
|
+
}}
|
|
1011
|
+
|
|
1012
|
+
resource "google_sql_database" "app" {{
|
|
1013
|
+
name = "app"
|
|
1014
|
+
instance = google_sql_database_instance.main.name
|
|
1015
|
+
}}
|
|
1016
|
+
|
|
1017
|
+
resource "google_sql_user" "admin" {{
|
|
1018
|
+
name = "supabase_admin"
|
|
1019
|
+
instance = google_sql_database_instance.main.name
|
|
1020
|
+
password = var.db_password
|
|
1021
|
+
}}
|
|
1022
|
+
|
|
1023
|
+
# ── VPC ─────────────────────────────────────────────────────
|
|
1024
|
+
resource "google_compute_network" "main" {{
|
|
1025
|
+
name = "${{var.app_name}}-${{var.environment}}"
|
|
1026
|
+
auto_create_subnetworks = false
|
|
1027
|
+
}}
|
|
1028
|
+
|
|
1029
|
+
resource "google_compute_subnetwork" "main" {{
|
|
1030
|
+
name = "${{var.app_name}}-${{var.environment}}-subnet"
|
|
1031
|
+
ip_cidr_range = "10.0.0.0/24"
|
|
1032
|
+
region = var.region
|
|
1033
|
+
network = google_compute_network.main.id
|
|
1034
|
+
}}
|
|
1035
|
+
|
|
1036
|
+
resource "google_compute_global_address" "private_ip" {{
|
|
1037
|
+
name = "${{var.app_name}}-${{var.environment}}-private-ip"
|
|
1038
|
+
purpose = "VPC_PEERING"
|
|
1039
|
+
address_type = "INTERNAL"
|
|
1040
|
+
prefix_length = 16
|
|
1041
|
+
network = google_compute_network.main.id
|
|
1042
|
+
}}
|
|
1043
|
+
|
|
1044
|
+
resource "google_service_networking_connection" "main" {{
|
|
1045
|
+
network = google_compute_network.main.id
|
|
1046
|
+
service = "servicenetworking.googleapis.com"
|
|
1047
|
+
reserved_peering_ranges = [google_compute_global_address.private_ip.name]
|
|
1048
|
+
}}
|
|
1049
|
+
|
|
1050
|
+
# ── Cloud Run ───────────────────────────────────────────────
|
|
1051
|
+
resource "google_cloud_run_v2_service" "app" {{
|
|
1052
|
+
name = "${{var.app_name}}-${{var.environment}}"
|
|
1053
|
+
location = var.region
|
|
1054
|
+
|
|
1055
|
+
template {{
|
|
1056
|
+
scaling {{
|
|
1057
|
+
min_instance_count = var.environment == "prod" ? {replicas} : 0
|
|
1058
|
+
max_instance_count = var.environment == "prod" ? {replicas * 3} : 3
|
|
1059
|
+
}}
|
|
1060
|
+
|
|
1061
|
+
containers {{
|
|
1062
|
+
image = "${{var.artifact_registry}}/${{var.app_name}}:${{var.image_tag}}"
|
|
1063
|
+
ports {{
|
|
1064
|
+
container_port = 3000
|
|
1065
|
+
}}
|
|
1066
|
+
env {{
|
|
1067
|
+
name = "NODE_ENV"
|
|
1068
|
+
value = var.environment
|
|
1069
|
+
}}
|
|
1070
|
+
env {{
|
|
1071
|
+
name = "NEXT_PUBLIC_SUPABASE_URL"
|
|
1072
|
+
value = var.supabase_url
|
|
1073
|
+
}}
|
|
1074
|
+
env {{
|
|
1075
|
+
name = "NEXT_PUBLIC_SUPABASE_ANON_KEY"
|
|
1076
|
+
value_source {{
|
|
1077
|
+
secret_key_ref {{
|
|
1078
|
+
secret = google_secret_manager_secret.supabase_anon_key.secret_id
|
|
1079
|
+
version = "latest"
|
|
1080
|
+
}}
|
|
1081
|
+
}}
|
|
1082
|
+
}}
|
|
1083
|
+
resources {{
|
|
1084
|
+
limits = {{
|
|
1085
|
+
cpu = var.app_cpu
|
|
1086
|
+
memory = var.app_memory
|
|
1087
|
+
}}
|
|
1088
|
+
}}
|
|
1089
|
+
startup_probe {{
|
|
1090
|
+
http_get {{
|
|
1091
|
+
path = "/"
|
|
1092
|
+
port = 3000
|
|
1093
|
+
}}
|
|
1094
|
+
initial_delay_seconds = 10
|
|
1095
|
+
period_seconds = 3
|
|
1096
|
+
}}
|
|
1097
|
+
}}
|
|
1098
|
+
|
|
1099
|
+
vpc_access {{
|
|
1100
|
+
connector = google_vpc_access_connector.main.id
|
|
1101
|
+
egress = "PRIVATE_RANGES_ONLY"
|
|
1102
|
+
}}
|
|
1103
|
+
}}
|
|
1104
|
+
}}
|
|
1105
|
+
|
|
1106
|
+
resource "google_vpc_access_connector" "main" {{
|
|
1107
|
+
name = "${{var.app_name}}-${{var.environment}}"
|
|
1108
|
+
region = var.region
|
|
1109
|
+
ip_cidr_range = "10.8.0.0/28"
|
|
1110
|
+
network = google_compute_network.main.name
|
|
1111
|
+
}}
|
|
1112
|
+
|
|
1113
|
+
resource "google_cloud_run_v2_service_iam_member" "public" {{
|
|
1114
|
+
name = google_cloud_run_v2_service.app.name
|
|
1115
|
+
location = var.region
|
|
1116
|
+
role = "roles/run.invoker"
|
|
1117
|
+
member = "allUsers"
|
|
1118
|
+
}}
|
|
1119
|
+
|
|
1120
|
+
# ── Secret Manager ──────────────────────────────────────────
|
|
1121
|
+
resource "google_secret_manager_secret" "supabase_anon_key" {{
|
|
1122
|
+
secret_id = "${{var.app_name}}-${{var.environment}}-supabase-anon-key"
|
|
1123
|
+
replication {{
|
|
1124
|
+
auto {{}}
|
|
1125
|
+
}}
|
|
1126
|
+
}}
|
|
1127
|
+
|
|
1128
|
+
# ── Cloud Storage ───────────────────────────────────────────
|
|
1129
|
+
resource "google_storage_bucket" "assets" {{
|
|
1130
|
+
name = "${{var.app_name}}-${{var.environment}}-assets"
|
|
1131
|
+
location = var.region
|
|
1132
|
+
force_destroy = var.environment != "prod"
|
|
1133
|
+
|
|
1134
|
+
uniform_bucket_level_access = true
|
|
1135
|
+
|
|
1136
|
+
versioning {{
|
|
1137
|
+
enabled = var.environment == "prod"
|
|
1138
|
+
}}
|
|
1139
|
+
|
|
1140
|
+
lifecycle_rule {{
|
|
1141
|
+
condition {{
|
|
1142
|
+
age = 90
|
|
1143
|
+
}}
|
|
1144
|
+
action {{
|
|
1145
|
+
type = "Delete"
|
|
1146
|
+
}}
|
|
1147
|
+
}}
|
|
1148
|
+
}}
|
|
1149
|
+
'''
|
|
1150
|
+
|
|
1151
|
+
variables_tf = f'''# CUI // SP-CTI
|
|
1152
|
+
variable "app_name" {{
|
|
1153
|
+
type = string
|
|
1154
|
+
default = "{name}"
|
|
1155
|
+
}}
|
|
1156
|
+
variable "project_id" {{
|
|
1157
|
+
type = string
|
|
1158
|
+
}}
|
|
1159
|
+
variable "environment" {{
|
|
1160
|
+
type = string
|
|
1161
|
+
default = "{env}"
|
|
1162
|
+
}}
|
|
1163
|
+
variable "region" {{
|
|
1164
|
+
type = string
|
|
1165
|
+
default = "{region}"
|
|
1166
|
+
}}
|
|
1167
|
+
variable "db_password" {{
|
|
1168
|
+
type = string
|
|
1169
|
+
sensitive = true
|
|
1170
|
+
}}
|
|
1171
|
+
variable "db_tier" {{
|
|
1172
|
+
type = string
|
|
1173
|
+
default = "db-f1-micro"
|
|
1174
|
+
}}
|
|
1175
|
+
variable "db_disk_gb" {{
|
|
1176
|
+
type = number
|
|
1177
|
+
default = 10
|
|
1178
|
+
}}
|
|
1179
|
+
variable "app_cpu" {{
|
|
1180
|
+
type = string
|
|
1181
|
+
default = "1"
|
|
1182
|
+
}}
|
|
1183
|
+
variable "app_memory" {{
|
|
1184
|
+
type = string
|
|
1185
|
+
default = "512Mi"
|
|
1186
|
+
}}
|
|
1187
|
+
variable "artifact_registry" {{
|
|
1188
|
+
type = string
|
|
1189
|
+
}}
|
|
1190
|
+
variable "image_tag" {{
|
|
1191
|
+
type = string
|
|
1192
|
+
default = "latest"
|
|
1193
|
+
}}
|
|
1194
|
+
variable "supabase_url" {{
|
|
1195
|
+
type = string
|
|
1196
|
+
}}
|
|
1197
|
+
variable "supabase_anon_key" {{
|
|
1198
|
+
type = string
|
|
1199
|
+
sensitive = true
|
|
1200
|
+
}}
|
|
1201
|
+
'''
|
|
1202
|
+
|
|
1203
|
+
outputs_tf = f'''# CUI // SP-CTI
|
|
1204
|
+
output "app_url" {{
|
|
1205
|
+
value = google_cloud_run_v2_service.app.uri
|
|
1206
|
+
}}
|
|
1207
|
+
output "db_connection_name" {{
|
|
1208
|
+
value = google_sql_database_instance.main.connection_name
|
|
1209
|
+
sensitive = true
|
|
1210
|
+
}}
|
|
1211
|
+
output "storage_bucket" {{
|
|
1212
|
+
value = google_storage_bucket.assets.name
|
|
1213
|
+
}}
|
|
1214
|
+
'''
|
|
1215
|
+
|
|
1216
|
+
return {
|
|
1217
|
+
"terraform/main.tf": main_tf,
|
|
1218
|
+
"terraform/variables.tf": variables_tf,
|
|
1219
|
+
"terraform/outputs.tf": outputs_tf,
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
# ---------------------------------------------------------------------------
|
|
1224
|
+
# On-Prem (Docker Compose — wraps existing generator)
|
|
1225
|
+
# ---------------------------------------------------------------------------
|
|
1226
|
+
|
|
1227
|
+
def _generate_onprem_files(config: Dict[str, Any]) -> Dict[str, str]:
|
|
1228
|
+
from tools.forge_studio.eject.docker_compose_generator import (
|
|
1229
|
+
generate_docker_compose, generate_dockerfile, generate_env_file,
|
|
1230
|
+
)
|
|
1231
|
+
return {
|
|
1232
|
+
"docker-compose.yml": generate_docker_compose(config["app_name"]),
|
|
1233
|
+
"Dockerfile": generate_dockerfile(),
|
|
1234
|
+
".env.template": generate_env_file(),
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
|
|
1238
|
+
# ---------------------------------------------------------------------------
|
|
1239
|
+
# Environment-specific tfvars
|
|
1240
|
+
# ---------------------------------------------------------------------------
|
|
1241
|
+
|
|
1242
|
+
def _generate_tfvars(config: Dict[str, Any]) -> str:
|
|
1243
|
+
name = config["app_name"]
|
|
1244
|
+
env = config["environment"]
|
|
1245
|
+
region = config["region"]
|
|
1246
|
+
provider = config["provider"]
|
|
1247
|
+
replicas = config["replicas"]
|
|
1248
|
+
|
|
1249
|
+
if provider == "onprem":
|
|
1250
|
+
return f'# CUI // SP-CTI\n# On-prem deployment — no tfvars needed\n# Environment: {env}\n'
|
|
1251
|
+
|
|
1252
|
+
# Size presets per environment
|
|
1253
|
+
sizes = {
|
|
1254
|
+
"dev": {"cpu": 256, "memory": 512, "db": "small", "replicas": 1},
|
|
1255
|
+
"staging": {"cpu": 512, "memory": 1024, "db": "medium", "replicas": 1},
|
|
1256
|
+
"prod": {"cpu": 1024, "memory": 2048, "db": "large", "replicas": replicas},
|
|
1257
|
+
}
|
|
1258
|
+
s = sizes.get(env, sizes["prod"])
|
|
1259
|
+
|
|
1260
|
+
if provider == "aws":
|
|
1261
|
+
db_classes = {"small": "db.t4g.micro", "medium": "db.t4g.medium", "large": "db.r6g.large"}
|
|
1262
|
+
return f'''# CUI // SP-CTI
|
|
1263
|
+
# AWS {env} environment variables
|
|
1264
|
+
app_name = "{name}"
|
|
1265
|
+
environment = "{env}"
|
|
1266
|
+
region = "{region}"
|
|
1267
|
+
replicas = {s["replicas"]}
|
|
1268
|
+
app_cpu = {s["cpu"]}
|
|
1269
|
+
app_memory = {s["memory"]}
|
|
1270
|
+
db_instance_class = "{db_classes[s['db']]}"
|
|
1271
|
+
db_storage_gb = {20 if env == "dev" else 50 if env == "staging" else 100}
|
|
1272
|
+
db_max_storage_gb = {50 if env == "dev" else 100 if env == "staging" else 500}
|
|
1273
|
+
'''
|
|
1274
|
+
elif provider == "azure":
|
|
1275
|
+
db_skus = {"small": "B_Standard_B1ms", "medium": "GP_Standard_D2ds_v4", "large": "GP_Standard_D4ds_v4"}
|
|
1276
|
+
return f'''# CUI // SP-CTI
|
|
1277
|
+
# Azure {env} environment variables
|
|
1278
|
+
app_name = "{name}"
|
|
1279
|
+
environment = "{env}"
|
|
1280
|
+
region = "{region}"
|
|
1281
|
+
app_cpu = {0.25 if env == "dev" else 0.5 if env == "staging" else 1.0}
|
|
1282
|
+
app_memory = "{"0.5Gi" if env == "dev" else "1Gi" if env == "staging" else "2Gi"}"
|
|
1283
|
+
db_sku = "{db_skus[s['db']]}"
|
|
1284
|
+
db_storage_mb = {32768 if env == "dev" else 65536 if env == "staging" else 131072}
|
|
1285
|
+
'''
|
|
1286
|
+
elif provider == "gcp":
|
|
1287
|
+
db_tiers = {"small": "db-f1-micro", "medium": "db-custom-2-4096", "large": "db-custom-4-8192"}
|
|
1288
|
+
return f'''# CUI // SP-CTI
|
|
1289
|
+
# GCP {env} environment variables
|
|
1290
|
+
app_name = "{name}"
|
|
1291
|
+
environment = "{env}"
|
|
1292
|
+
region = "{region}"
|
|
1293
|
+
app_cpu = "{"1" if env == "dev" else "2" if env == "staging" else "4"}"
|
|
1294
|
+
app_memory = "{"512Mi" if env == "dev" else "1Gi" if env == "staging" else "2Gi"}"
|
|
1295
|
+
db_tier = "{db_tiers[s['db']]}"
|
|
1296
|
+
db_disk_gb = {10 if env == "dev" else 25 if env == "staging" else 50}
|
|
1297
|
+
'''
|
|
1298
|
+
return ""
|
|
1299
|
+
|
|
1300
|
+
|
|
1301
|
+
# ---------------------------------------------------------------------------
|
|
1302
|
+
# Kubernetes manifests
|
|
1303
|
+
# ---------------------------------------------------------------------------
|
|
1304
|
+
|
|
1305
|
+
def _generate_k8s_manifests(config: Dict[str, Any]) -> Dict[str, str]:
|
|
1306
|
+
name = config["app_name"]
|
|
1307
|
+
env = config["environment"]
|
|
1308
|
+
replicas = config["replicas"]
|
|
1309
|
+
|
|
1310
|
+
deployment = f'''# CUI // SP-CTI
|
|
1311
|
+
apiVersion: apps/v1
|
|
1312
|
+
kind: Deployment
|
|
1313
|
+
metadata:
|
|
1314
|
+
name: {name}
|
|
1315
|
+
namespace: {name}-{env}
|
|
1316
|
+
labels:
|
|
1317
|
+
app: {name}
|
|
1318
|
+
environment: {env}
|
|
1319
|
+
generator: forge-studio
|
|
1320
|
+
spec:
|
|
1321
|
+
replicas: {replicas}
|
|
1322
|
+
selector:
|
|
1323
|
+
matchLabels:
|
|
1324
|
+
app: {name}
|
|
1325
|
+
template:
|
|
1326
|
+
metadata:
|
|
1327
|
+
labels:
|
|
1328
|
+
app: {name}
|
|
1329
|
+
environment: {env}
|
|
1330
|
+
spec:
|
|
1331
|
+
securityContext:
|
|
1332
|
+
runAsNonRoot: true
|
|
1333
|
+
runAsUser: 1001
|
|
1334
|
+
fsGroup: 1001
|
|
1335
|
+
containers:
|
|
1336
|
+
- name: app
|
|
1337
|
+
image: IMAGE_PLACEHOLDER:latest
|
|
1338
|
+
ports:
|
|
1339
|
+
- containerPort: 3000
|
|
1340
|
+
protocol: TCP
|
|
1341
|
+
env:
|
|
1342
|
+
- name: NODE_ENV
|
|
1343
|
+
value: "{env}"
|
|
1344
|
+
- name: NEXT_PUBLIC_SUPABASE_URL
|
|
1345
|
+
valueFrom:
|
|
1346
|
+
secretKeyRef:
|
|
1347
|
+
name: {name}-secrets
|
|
1348
|
+
key: supabase-url
|
|
1349
|
+
- name: NEXT_PUBLIC_SUPABASE_ANON_KEY
|
|
1350
|
+
valueFrom:
|
|
1351
|
+
secretKeyRef:
|
|
1352
|
+
name: {name}-secrets
|
|
1353
|
+
key: supabase-anon-key
|
|
1354
|
+
resources:
|
|
1355
|
+
requests:
|
|
1356
|
+
cpu: "250m"
|
|
1357
|
+
memory: "256Mi"
|
|
1358
|
+
limits:
|
|
1359
|
+
cpu: "1000m"
|
|
1360
|
+
memory: "1Gi"
|
|
1361
|
+
livenessProbe:
|
|
1362
|
+
httpGet:
|
|
1363
|
+
path: /
|
|
1364
|
+
port: 3000
|
|
1365
|
+
initialDelaySeconds: 30
|
|
1366
|
+
periodSeconds: 10
|
|
1367
|
+
readinessProbe:
|
|
1368
|
+
httpGet:
|
|
1369
|
+
path: /
|
|
1370
|
+
port: 3000
|
|
1371
|
+
initialDelaySeconds: 5
|
|
1372
|
+
periodSeconds: 5
|
|
1373
|
+
securityContext:
|
|
1374
|
+
allowPrivilegeEscalation: false
|
|
1375
|
+
readOnlyRootFilesystem: true
|
|
1376
|
+
'''
|
|
1377
|
+
|
|
1378
|
+
service = f'''# CUI // SP-CTI
|
|
1379
|
+
apiVersion: v1
|
|
1380
|
+
kind: Service
|
|
1381
|
+
metadata:
|
|
1382
|
+
name: {name}
|
|
1383
|
+
namespace: {name}-{env}
|
|
1384
|
+
spec:
|
|
1385
|
+
selector:
|
|
1386
|
+
app: {name}
|
|
1387
|
+
ports:
|
|
1388
|
+
- port: 80
|
|
1389
|
+
targetPort: 3000
|
|
1390
|
+
protocol: TCP
|
|
1391
|
+
type: ClusterIP
|
|
1392
|
+
'''
|
|
1393
|
+
|
|
1394
|
+
ingress = f'''# CUI // SP-CTI
|
|
1395
|
+
apiVersion: networking.k8s.io/v1
|
|
1396
|
+
kind: Ingress
|
|
1397
|
+
metadata:
|
|
1398
|
+
name: {name}
|
|
1399
|
+
namespace: {name}-{env}
|
|
1400
|
+
annotations:
|
|
1401
|
+
cert-manager.io/cluster-issuer: letsencrypt-prod
|
|
1402
|
+
spec:
|
|
1403
|
+
ingressClassName: nginx
|
|
1404
|
+
tls:
|
|
1405
|
+
- hosts:
|
|
1406
|
+
- {config["domain"]}
|
|
1407
|
+
secretName: {name}-tls
|
|
1408
|
+
rules:
|
|
1409
|
+
- host: {config["domain"]}
|
|
1410
|
+
http:
|
|
1411
|
+
paths:
|
|
1412
|
+
- path: /
|
|
1413
|
+
pathType: Prefix
|
|
1414
|
+
backend:
|
|
1415
|
+
service:
|
|
1416
|
+
name: {name}
|
|
1417
|
+
port:
|
|
1418
|
+
number: 80
|
|
1419
|
+
'''
|
|
1420
|
+
|
|
1421
|
+
namespace = f'''# CUI // SP-CTI
|
|
1422
|
+
apiVersion: v1
|
|
1423
|
+
kind: Namespace
|
|
1424
|
+
metadata:
|
|
1425
|
+
name: {name}-{env}
|
|
1426
|
+
labels:
|
|
1427
|
+
app: {name}
|
|
1428
|
+
environment: {env}
|
|
1429
|
+
'''
|
|
1430
|
+
|
|
1431
|
+
network_policy = f'''# CUI // SP-CTI
|
|
1432
|
+
apiVersion: networking.k8s.io/v1
|
|
1433
|
+
kind: NetworkPolicy
|
|
1434
|
+
metadata:
|
|
1435
|
+
name: {name}-default-deny
|
|
1436
|
+
namespace: {name}-{env}
|
|
1437
|
+
spec:
|
|
1438
|
+
podSelector:
|
|
1439
|
+
matchLabels:
|
|
1440
|
+
app: {name}
|
|
1441
|
+
policyTypes:
|
|
1442
|
+
- Ingress
|
|
1443
|
+
- Egress
|
|
1444
|
+
ingress:
|
|
1445
|
+
- from:
|
|
1446
|
+
- namespaceSelector:
|
|
1447
|
+
matchLabels:
|
|
1448
|
+
kubernetes.io/metadata.name: ingress-nginx
|
|
1449
|
+
ports:
|
|
1450
|
+
- port: 3000
|
|
1451
|
+
egress:
|
|
1452
|
+
- to:
|
|
1453
|
+
- namespaceSelector: {{}}
|
|
1454
|
+
ports:
|
|
1455
|
+
- port: 5432
|
|
1456
|
+
- port: 443
|
|
1457
|
+
- to:
|
|
1458
|
+
- ipBlock:
|
|
1459
|
+
cidr: 0.0.0.0/0
|
|
1460
|
+
ports:
|
|
1461
|
+
- port: 443
|
|
1462
|
+
'''
|
|
1463
|
+
|
|
1464
|
+
return {
|
|
1465
|
+
"k8s/namespace.yaml": namespace,
|
|
1466
|
+
"k8s/deployment.yaml": deployment,
|
|
1467
|
+
"k8s/service.yaml": service,
|
|
1468
|
+
"k8s/ingress.yaml": ingress,
|
|
1469
|
+
"k8s/network-policy.yaml": network_policy,
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
|
|
1473
|
+
# ---------------------------------------------------------------------------
|
|
1474
|
+
# CI/CD pipeline generation
|
|
1475
|
+
# ---------------------------------------------------------------------------
|
|
1476
|
+
|
|
1477
|
+
def _generate_cicd_pipeline(config: Dict[str, Any]) -> Dict[str, str]:
|
|
1478
|
+
name = config["app_name"]
|
|
1479
|
+
env = config["environment"]
|
|
1480
|
+
provider = config["provider"]
|
|
1481
|
+
|
|
1482
|
+
# GitHub Actions (universal)
|
|
1483
|
+
gha = f'''# CUI // SP-CTI
|
|
1484
|
+
name: Deploy {config["app_display_name"]} ({env})
|
|
1485
|
+
|
|
1486
|
+
on:
|
|
1487
|
+
push:
|
|
1488
|
+
branches: [{'"main"' if env == "prod" else f'"deploy/{env}"'}]
|
|
1489
|
+
workflow_dispatch:
|
|
1490
|
+
|
|
1491
|
+
env:
|
|
1492
|
+
APP_NAME: {name}
|
|
1493
|
+
ENVIRONMENT: {env}
|
|
1494
|
+
|
|
1495
|
+
jobs:
|
|
1496
|
+
test:
|
|
1497
|
+
runs-on: ubuntu-latest
|
|
1498
|
+
steps:
|
|
1499
|
+
- uses: actions/checkout@v4
|
|
1500
|
+
- uses: actions/setup-node@v4
|
|
1501
|
+
with:
|
|
1502
|
+
node-version: "20"
|
|
1503
|
+
cache: "npm"
|
|
1504
|
+
- run: npm ci
|
|
1505
|
+
- run: npm run lint
|
|
1506
|
+
- run: npm run test
|
|
1507
|
+
- run: npm run build
|
|
1508
|
+
|
|
1509
|
+
security-scan:
|
|
1510
|
+
runs-on: ubuntu-latest
|
|
1511
|
+
needs: test
|
|
1512
|
+
steps:
|
|
1513
|
+
- uses: actions/checkout@v4
|
|
1514
|
+
- name: Run Trivy vulnerability scanner
|
|
1515
|
+
uses: aquasecurity/trivy-action@master
|
|
1516
|
+
with:
|
|
1517
|
+
scan-type: "fs"
|
|
1518
|
+
severity: "CRITICAL,HIGH"
|
|
1519
|
+
exit-code: "1"
|
|
1520
|
+
|
|
1521
|
+
build-push:
|
|
1522
|
+
runs-on: ubuntu-latest
|
|
1523
|
+
needs: [test, security-scan]
|
|
1524
|
+
permissions:
|
|
1525
|
+
contents: read
|
|
1526
|
+
id-token: write
|
|
1527
|
+
steps:
|
|
1528
|
+
- uses: actions/checkout@v4
|
|
1529
|
+
'''
|
|
1530
|
+
|
|
1531
|
+
if provider == "aws":
|
|
1532
|
+
gha += f'''
|
|
1533
|
+
- name: Configure AWS credentials
|
|
1534
|
+
uses: aws-actions/configure-aws-credentials@v4
|
|
1535
|
+
with:
|
|
1536
|
+
role-to-assume: ${{{{ secrets.AWS_ROLE_ARN }}}}
|
|
1537
|
+
aws-region: {config["region"]}
|
|
1538
|
+
|
|
1539
|
+
- name: Login to Amazon ECR
|
|
1540
|
+
id: login-ecr
|
|
1541
|
+
uses: aws-actions/amazon-ecr-login@v2
|
|
1542
|
+
|
|
1543
|
+
- name: Build and push Docker image
|
|
1544
|
+
env:
|
|
1545
|
+
ECR_REGISTRY: ${{{{ steps.login-ecr.outputs.registry }}}}
|
|
1546
|
+
IMAGE_TAG: ${{{{ github.sha }}}}
|
|
1547
|
+
run: |
|
|
1548
|
+
docker build -t $ECR_REGISTRY/{name}:$IMAGE_TAG .
|
|
1549
|
+
docker push $ECR_REGISTRY/{name}:$IMAGE_TAG
|
|
1550
|
+
|
|
1551
|
+
deploy:
|
|
1552
|
+
runs-on: ubuntu-latest
|
|
1553
|
+
needs: build-push
|
|
1554
|
+
environment: {env}
|
|
1555
|
+
steps:
|
|
1556
|
+
- uses: actions/checkout@v4
|
|
1557
|
+
- uses: hashicorp/setup-terraform@v3
|
|
1558
|
+
- name: Configure AWS credentials
|
|
1559
|
+
uses: aws-actions/configure-aws-credentials@v4
|
|
1560
|
+
with:
|
|
1561
|
+
role-to-assume: ${{{{ secrets.AWS_ROLE_ARN }}}}
|
|
1562
|
+
aws-region: {config["region"]}
|
|
1563
|
+
- name: Terraform Apply
|
|
1564
|
+
working-directory: terraform
|
|
1565
|
+
run: |
|
|
1566
|
+
terraform init
|
|
1567
|
+
terraform plan -var-file=../envs/{env}.tfvars -var="image_tag=${{{{ github.sha }}}}" -out=tfplan
|
|
1568
|
+
terraform apply tfplan
|
|
1569
|
+
'''
|
|
1570
|
+
elif provider == "azure":
|
|
1571
|
+
gha += f'''
|
|
1572
|
+
- name: Login to Azure
|
|
1573
|
+
uses: azure/login@v2
|
|
1574
|
+
with:
|
|
1575
|
+
client-id: ${{{{ secrets.AZURE_CLIENT_ID }}}}
|
|
1576
|
+
tenant-id: ${{{{ secrets.AZURE_TENANT_ID }}}}
|
|
1577
|
+
subscription-id: ${{{{ secrets.AZURE_SUBSCRIPTION_ID }}}}
|
|
1578
|
+
|
|
1579
|
+
- name: Login to ACR
|
|
1580
|
+
uses: azure/docker-login@v2
|
|
1581
|
+
with:
|
|
1582
|
+
login-server: ${{{{ secrets.ACR_LOGIN_SERVER }}}}
|
|
1583
|
+
|
|
1584
|
+
- name: Build and push Docker image
|
|
1585
|
+
run: |
|
|
1586
|
+
docker build -t ${{{{ secrets.ACR_LOGIN_SERVER }}}}/{name}:${{{{ github.sha }}}} .
|
|
1587
|
+
docker push ${{{{ secrets.ACR_LOGIN_SERVER }}}}/{name}:${{{{ github.sha }}}}
|
|
1588
|
+
|
|
1589
|
+
deploy:
|
|
1590
|
+
runs-on: ubuntu-latest
|
|
1591
|
+
needs: build-push
|
|
1592
|
+
environment: {env}
|
|
1593
|
+
steps:
|
|
1594
|
+
- uses: actions/checkout@v4
|
|
1595
|
+
- uses: hashicorp/setup-terraform@v3
|
|
1596
|
+
- name: Login to Azure
|
|
1597
|
+
uses: azure/login@v2
|
|
1598
|
+
with:
|
|
1599
|
+
client-id: ${{{{ secrets.AZURE_CLIENT_ID }}}}
|
|
1600
|
+
tenant-id: ${{{{ secrets.AZURE_TENANT_ID }}}}
|
|
1601
|
+
subscription-id: ${{{{ secrets.AZURE_SUBSCRIPTION_ID }}}}
|
|
1602
|
+
- name: Terraform Apply
|
|
1603
|
+
working-directory: terraform
|
|
1604
|
+
run: |
|
|
1605
|
+
terraform init
|
|
1606
|
+
terraform plan -var-file=../envs/{env}.tfvars -var="image_tag=${{{{ github.sha }}}}" -out=tfplan
|
|
1607
|
+
terraform apply tfplan
|
|
1608
|
+
'''
|
|
1609
|
+
elif provider == "gcp":
|
|
1610
|
+
gha += f'''
|
|
1611
|
+
- name: Authenticate to GCP
|
|
1612
|
+
uses: google-github-actions/auth@v2
|
|
1613
|
+
with:
|
|
1614
|
+
workload_identity_provider: ${{{{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}}}
|
|
1615
|
+
service_account: ${{{{ secrets.GCP_SERVICE_ACCOUNT }}}}
|
|
1616
|
+
|
|
1617
|
+
- name: Configure Docker for Artifact Registry
|
|
1618
|
+
run: gcloud auth configure-docker {config["region"]}-docker.pkg.dev
|
|
1619
|
+
|
|
1620
|
+
- name: Build and push Docker image
|
|
1621
|
+
run: |
|
|
1622
|
+
docker build -t {config["region"]}-docker.pkg.dev/${{{{ secrets.GCP_PROJECT_ID }}}}/{name}/{name}:${{{{ github.sha }}}} .
|
|
1623
|
+
docker push {config["region"]}-docker.pkg.dev/${{{{ secrets.GCP_PROJECT_ID }}}}/{name}/{name}:${{{{ github.sha }}}}
|
|
1624
|
+
|
|
1625
|
+
deploy:
|
|
1626
|
+
runs-on: ubuntu-latest
|
|
1627
|
+
needs: build-push
|
|
1628
|
+
environment: {env}
|
|
1629
|
+
steps:
|
|
1630
|
+
- uses: actions/checkout@v4
|
|
1631
|
+
- uses: hashicorp/setup-terraform@v3
|
|
1632
|
+
- name: Authenticate to GCP
|
|
1633
|
+
uses: google-github-actions/auth@v2
|
|
1634
|
+
with:
|
|
1635
|
+
workload_identity_provider: ${{{{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}}}
|
|
1636
|
+
service_account: ${{{{ secrets.GCP_SERVICE_ACCOUNT }}}}
|
|
1637
|
+
- name: Terraform Apply
|
|
1638
|
+
working-directory: terraform
|
|
1639
|
+
run: |
|
|
1640
|
+
terraform init
|
|
1641
|
+
terraform plan -var-file=../envs/{env}.tfvars -var="image_tag=${{{{ github.sha }}}}" -out=tfplan
|
|
1642
|
+
terraform apply tfplan
|
|
1643
|
+
'''
|
|
1644
|
+
elif provider == "onprem":
|
|
1645
|
+
gha += f'''
|
|
1646
|
+
- name: Build Docker image
|
|
1647
|
+
run: docker build -t {name}:${{{{ github.sha }}}} .
|
|
1648
|
+
|
|
1649
|
+
deploy:
|
|
1650
|
+
runs-on: ubuntu-latest
|
|
1651
|
+
needs: build-push
|
|
1652
|
+
environment: {env}
|
|
1653
|
+
steps:
|
|
1654
|
+
- uses: actions/checkout@v4
|
|
1655
|
+
- name: Deploy via Docker Compose
|
|
1656
|
+
run: |
|
|
1657
|
+
docker compose pull
|
|
1658
|
+
docker compose up -d --build
|
|
1659
|
+
'''
|
|
1660
|
+
|
|
1661
|
+
return {
|
|
1662
|
+
f".github/workflows/deploy-{env}.yml": gha,
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
|
|
1666
|
+
# ---------------------------------------------------------------------------
|
|
1667
|
+
# Deployment record (DB)
|
|
1668
|
+
# ---------------------------------------------------------------------------
|
|
1669
|
+
|
|
1670
|
+
def _record_deployment(
|
|
1671
|
+
deploy_id: str,
|
|
1672
|
+
app_id: str,
|
|
1673
|
+
config: Dict[str, Any],
|
|
1674
|
+
files_created: List[str],
|
|
1675
|
+
project_id: str,
|
|
1676
|
+
):
|
|
1677
|
+
"""Record deployment in DB."""
|
|
1678
|
+
from tools.db.storage import get_connection
|
|
1679
|
+
|
|
1680
|
+
now = datetime.now(timezone.utc).isoformat()
|
|
1681
|
+
with get_connection() as conn:
|
|
1682
|
+
conn.execute(
|
|
1683
|
+
"INSERT INTO forge_studio_deployments "
|
|
1684
|
+
"(id, app_id, provider, region, environment, status, config_json, "
|
|
1685
|
+
"files_json, classification, created_at) "
|
|
1686
|
+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
1687
|
+
(
|
|
1688
|
+
deploy_id, app_id, config["provider"], config["region"],
|
|
1689
|
+
config["environment"], "generated",
|
|
1690
|
+
json.dumps(config), json.dumps(files_created),
|
|
1691
|
+
"CUI // SP-CTI", now,
|
|
1692
|
+
),
|
|
1693
|
+
)
|
|
1694
|
+
|
|
1695
|
+
|
|
1696
|
+
DEPLOY_SCHEMA = """
|
|
1697
|
+
CREATE TABLE IF NOT EXISTS forge_studio_deployments (
|
|
1698
|
+
id TEXT PRIMARY KEY,
|
|
1699
|
+
app_id TEXT,
|
|
1700
|
+
provider TEXT NOT NULL,
|
|
1701
|
+
region TEXT,
|
|
1702
|
+
environment TEXT NOT NULL DEFAULT 'dev',
|
|
1703
|
+
status TEXT DEFAULT 'generated'
|
|
1704
|
+
CHECK(status IN ('generated','deploying','deployed','failed','rolled_back')),
|
|
1705
|
+
config_json TEXT,
|
|
1706
|
+
files_json TEXT,
|
|
1707
|
+
output_url TEXT,
|
|
1708
|
+
classification TEXT DEFAULT 'CUI // SP-CTI',
|
|
1709
|
+
created_at TEXT NOT NULL,
|
|
1710
|
+
deployed_at TEXT
|
|
1711
|
+
);
|
|
1712
|
+
"""
|
|
1713
|
+
|
|
1714
|
+
|
|
1715
|
+
def ensure_deploy_tables():
|
|
1716
|
+
"""Create deployment tables if they don't exist."""
|
|
1717
|
+
from tools.db.storage import get_connection
|
|
1718
|
+
|
|
1719
|
+
with get_connection() as conn:
|
|
1720
|
+
for stmt in DEPLOY_SCHEMA.split(";"):
|
|
1721
|
+
s = stmt.strip()
|
|
1722
|
+
if s and not s.startswith("--"):
|
|
1723
|
+
conn.execute(s)
|
|
1724
|
+
logger.info("Forge Studio deployment tables ensured")
|
|
1725
|
+
|
|
1726
|
+
|
|
1727
|
+
# ---------------------------------------------------------------------------
|
|
1728
|
+
# Helpers
|
|
1729
|
+
# ---------------------------------------------------------------------------
|
|
1730
|
+
|
|
1731
|
+
def _write_file(base: Path, filepath: str, content: str, tracker: List[str]):
|
|
1732
|
+
full_path = base / filepath
|
|
1733
|
+
full_path.parent.mkdir(parents=True, exist_ok=True)
|
|
1734
|
+
full_path.write_text(content, encoding="utf-8")
|
|
1735
|
+
tracker.append(filepath)
|
|
1736
|
+
|
|
1737
|
+
|
|
1738
|
+
# ---------------------------------------------------------------------------
|
|
1739
|
+
# CLI
|
|
1740
|
+
# ---------------------------------------------------------------------------
|
|
1741
|
+
|
|
1742
|
+
def main():
|
|
1743
|
+
import argparse
|
|
1744
|
+
import sys
|
|
1745
|
+
|
|
1746
|
+
parser = argparse.ArgumentParser(description="Forge Studio Multi-Cloud Deploy Engine")
|
|
1747
|
+
parser.add_argument("--generate", action="store_true", help="Generate deployment artifacts")
|
|
1748
|
+
parser.add_argument("--providers", action="store_true", help="List available providers")
|
|
1749
|
+
parser.add_argument("--deployments", type=str, help="List deployments for app ID")
|
|
1750
|
+
parser.add_argument("--app-id", type=str, default="", help="App ID")
|
|
1751
|
+
parser.add_argument("--app-name", type=str, default="forge-app", help="App name")
|
|
1752
|
+
parser.add_argument("--provider", type=str, default="aws", help="Cloud provider")
|
|
1753
|
+
parser.add_argument("--region", type=str, default="", help="Cloud region")
|
|
1754
|
+
parser.add_argument("--env", type=str, default="prod", help="Environment")
|
|
1755
|
+
parser.add_argument("--output-dir", type=str, default="", help="Output directory")
|
|
1756
|
+
parser.add_argument("--domain", type=str, default="", help="Custom domain")
|
|
1757
|
+
parser.add_argument("--replicas", type=int, default=2, help="App replicas")
|
|
1758
|
+
parser.add_argument("--k8s", action="store_true", help="Generate K8s manifests")
|
|
1759
|
+
parser.add_argument("--no-cicd", action="store_true", help="Skip CI/CD generation")
|
|
1760
|
+
parser.add_argument("--project-id", type=str, default="", help="Project ID")
|
|
1761
|
+
parser.add_argument("--json", action="store_true", help="JSON output")
|
|
1762
|
+
args = parser.parse_args()
|
|
1763
|
+
|
|
1764
|
+
ensure_deploy_tables()
|
|
1765
|
+
|
|
1766
|
+
if args.providers:
|
|
1767
|
+
result = list_providers()
|
|
1768
|
+
elif args.deployments:
|
|
1769
|
+
result = get_deployments(args.deployments)
|
|
1770
|
+
elif args.generate:
|
|
1771
|
+
result = generate_deployment(
|
|
1772
|
+
app_id=args.app_id,
|
|
1773
|
+
app_name=args.app_name,
|
|
1774
|
+
provider=args.provider,
|
|
1775
|
+
region=args.region,
|
|
1776
|
+
environment=args.env,
|
|
1777
|
+
output_dir=args.output_dir,
|
|
1778
|
+
project_id=args.project_id,
|
|
1779
|
+
enable_k8s=args.k8s,
|
|
1780
|
+
enable_cicd=not args.no_cicd,
|
|
1781
|
+
domain=args.domain,
|
|
1782
|
+
replicas=args.replicas,
|
|
1783
|
+
)
|
|
1784
|
+
else:
|
|
1785
|
+
parser.print_help()
|
|
1786
|
+
sys.exit(0)
|
|
1787
|
+
|
|
1788
|
+
print(json.dumps(result, indent=2, default=str))
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
if __name__ == "__main__":
|
|
1792
|
+
main()
|