blockmine 1.21.0 → 1.23.0
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.
- package/.claude/agents/README.md +469 -0
- package/.claude/agents/auth-route-debugger.md +118 -0
- package/.claude/agents/auth-route-tester.md +93 -0
- package/.claude/agents/auto-error-resolver.md +97 -0
- package/.claude/agents/build-optimizer.md +236 -0
- package/.claude/agents/code-architecture-reviewer.md +83 -0
- package/.claude/agents/code-refactor-master.md +94 -0
- package/.claude/agents/cost-optimizer.md +134 -0
- package/.claude/agents/deployment-orchestrator.md +113 -0
- package/.claude/agents/documentation-architect.md +82 -0
- package/.claude/agents/frontend-error-fixer.md +77 -0
- package/.claude/agents/iac-code-generator.md +71 -0
- package/.claude/agents/incident-responder.md +346 -0
- package/.claude/agents/infrastructure-architect.md +31 -0
- package/.claude/agents/kubernetes-specialist.md +56 -0
- package/.claude/agents/migration-planner.md +181 -0
- package/.claude/agents/network-architect.md +196 -0
- package/.claude/agents/plan-reviewer.md +52 -0
- package/.claude/agents/refactor-planner.md +63 -0
- package/.claude/agents/security-scanner.md +102 -0
- package/.claude/agents/web-research-specialist.md +78 -0
- package/.claude/commands/cost-analysis.md +315 -0
- package/.claude/commands/dev-docs-update.md +55 -0
- package/.claude/commands/dev-docs.md +51 -0
- package/.claude/commands/incident-debug.md +247 -0
- package/.claude/commands/infra-plan.md +81 -0
- package/.claude/commands/migration-plan.md +478 -0
- package/.claude/commands/route-research-for-testing.md +37 -0
- package/.claude/commands/security-review.md +66 -0
- package/.claude/hooks/CONFIG.md +448 -0
- package/.claude/hooks/README.md +163 -0
- package/.claude/hooks/SKILL_ACTIVATION_COMPLETE.md +226 -0
- package/.claude/hooks/WINDOWS_HOOKS_README.md +151 -0
- package/.claude/hooks/add-skill-activation-banners.ts +132 -0
- package/.claude/hooks/comprehensive-skill-test.ts +1315 -0
- package/.claude/hooks/error-handling-reminder.sh +12 -0
- package/.claude/hooks/error-handling-reminder.ts +222 -0
- package/.claude/hooks/k8s-manifest-validator.sh +56 -0
- package/.claude/hooks/package-lock.json +556 -0
- package/.claude/hooks/package.json +16 -0
- package/.claude/hooks/post-tool-use-tracker.ps1 +174 -0
- package/.claude/hooks/post-tool-use-tracker.sh +183 -0
- package/.claude/hooks/security-policy-check.sh +247 -0
- package/.claude/hooks/skill-activation-prompt.ps1 +10 -0
- package/.claude/hooks/skill-activation-prompt.sh +10 -0
- package/.claude/hooks/skill-activation-prompt.ts +141 -0
- package/.claude/hooks/stop-build-check-enhanced.sh +130 -0
- package/.claude/hooks/terraform-validator.sh +53 -0
- package/.claude/hooks/test-input.json +7 -0
- package/.claude/hooks/test-skill-activation.ts +427 -0
- package/.claude/hooks/trigger-build-resolver.sh +79 -0
- package/.claude/hooks/tsc-check.sh +173 -0
- package/.claude/hooks/tsconfig.json +19 -0
- package/.claude/settings.json +59 -0
- package/.claude/settings.local.json +36 -14
- package/.claude/skills/README.md +507 -0
- package/.claude/skills/api-engineering/SKILL.md +63 -0
- package/.claude/skills/api-engineering/resources/api-versioning.md +88 -0
- package/.claude/skills/api-engineering/resources/graphql-patterns.md +106 -0
- package/.claude/skills/api-engineering/resources/rate-limiting.md +118 -0
- package/.claude/skills/api-engineering/resources/rest-api-design.md +105 -0
- package/.claude/skills/backend-dev-guidelines/SKILL.md +306 -0
- package/.claude/skills/backend-dev-guidelines/resources/architecture-overview.md +451 -0
- package/.claude/skills/backend-dev-guidelines/resources/async-and-errors.md +307 -0
- package/.claude/skills/backend-dev-guidelines/resources/complete-examples.md +638 -0
- package/.claude/skills/backend-dev-guidelines/resources/configuration.md +275 -0
- package/.claude/skills/backend-dev-guidelines/resources/database-patterns.md +224 -0
- package/.claude/skills/backend-dev-guidelines/resources/middleware-guide.md +213 -0
- package/.claude/skills/backend-dev-guidelines/resources/routing-and-controllers.md +756 -0
- package/.claude/skills/backend-dev-guidelines/resources/sentry-and-monitoring.md +336 -0
- package/.claude/skills/backend-dev-guidelines/resources/services-and-repositories.md +789 -0
- package/.claude/skills/backend-dev-guidelines/resources/testing-guide.md +235 -0
- package/.claude/skills/backend-dev-guidelines/resources/validation-patterns.md +754 -0
- package/.claude/skills/budget-and-cost-management/SKILL.md +850 -0
- package/.claude/skills/build-engineering/SKILL.md +431 -0
- package/.claude/skills/build-engineering/resources/artifact-repositories.md +72 -0
- package/.claude/skills/build-engineering/resources/build-caching.md +96 -0
- package/.claude/skills/build-engineering/resources/build-pipelines.md +105 -0
- package/.claude/skills/build-engineering/resources/build-security.md +95 -0
- package/.claude/skills/build-engineering/resources/build-systems.md +389 -0
- package/.claude/skills/build-engineering/resources/compilation-optimization.md +201 -0
- package/.claude/skills/build-engineering/resources/dependency-management.md +73 -0
- package/.claude/skills/build-engineering/resources/monorepo-builds.md +110 -0
- package/.claude/skills/build-engineering/resources/performance-optimization.md +113 -0
- package/.claude/skills/build-engineering/resources/reproducible-builds.md +82 -0
- package/.claude/skills/cloud-engineering/SKILL.md +675 -0
- package/.claude/skills/cloud-engineering/resources/aws-patterns.md +742 -0
- package/.claude/skills/cloud-engineering/resources/azure-patterns.md +714 -0
- package/.claude/skills/cloud-engineering/resources/cleared-cloud-environments.md +987 -0
- package/.claude/skills/cloud-engineering/resources/cloud-cost-optimization.md +757 -0
- package/.claude/skills/cloud-engineering/resources/cloud-networking.md +1058 -0
- package/.claude/skills/cloud-engineering/resources/cloud-security-tools.md +1530 -0
- package/.claude/skills/cloud-engineering/resources/cloud-security.md +990 -0
- package/.claude/skills/cloud-engineering/resources/gcp-patterns.md +758 -0
- package/.claude/skills/cloud-engineering/resources/migration-strategies.md +820 -0
- package/.claude/skills/cloud-engineering/resources/multi-cloud-strategies.md +670 -0
- package/.claude/skills/cloud-engineering/resources/oci-patterns.md +1198 -0
- package/.claude/skills/cloud-engineering/resources/serverless-patterns.md +795 -0
- package/.claude/skills/cloud-engineering/resources/well-architected-frameworks.md +966 -0
- package/.claude/skills/cybersecurity/SKILL.md +409 -0
- package/.claude/skills/cybersecurity/resources/security-architecture.md +266 -0
- package/.claude/skills/database-engineering/SKILL.md +61 -0
- package/.claude/skills/database-engineering/resources/backup-and-recovery.md +72 -0
- package/.claude/skills/database-engineering/resources/database-replication.md +63 -0
- package/.claude/skills/database-engineering/resources/postgresql-fundamentals.md +70 -0
- package/.claude/skills/database-engineering/resources/query-optimization.md +68 -0
- package/.claude/skills/devsecops/SKILL.md +374 -0
- package/.claude/skills/devsecops/resources/ci-cd-security.md +204 -0
- package/.claude/skills/devsecops/resources/compliance-automation.md +530 -0
- package/.claude/skills/devsecops/resources/compliance-frameworks.md +2322 -0
- package/.claude/skills/devsecops/resources/container-security.md +915 -0
- package/.claude/skills/devsecops/resources/cspm-integration.md +1440 -0
- package/.claude/skills/devsecops/resources/policy-enforcement.md +619 -0
- package/.claude/skills/devsecops/resources/secrets-management.md +755 -0
- package/.claude/skills/devsecops/resources/security-monitoring.md +146 -0
- package/.claude/skills/devsecops/resources/security-scanning.md +887 -0
- package/.claude/skills/devsecops/resources/security-testing.md +203 -0
- package/.claude/skills/devsecops/resources/supply-chain-security.md +518 -0
- package/.claude/skills/devsecops/resources/vulnerability-management.md +481 -0
- package/.claude/skills/devsecops/resources/zero-trust-architecture.md +177 -0
- package/.claude/skills/documentation-as-code/SKILL.md +323 -0
- package/.claude/skills/documentation-as-code/resources/api-documentation.md +90 -0
- package/.claude/skills/documentation-as-code/resources/changelog-management.md +79 -0
- package/.claude/skills/documentation-as-code/resources/diagram-generation.md +44 -0
- package/.claude/skills/documentation-as-code/resources/docs-as-code-workflow.md +99 -0
- package/.claude/skills/documentation-as-code/resources/documentation-automation.md +68 -0
- package/.claude/skills/documentation-as-code/resources/documentation-sites.md +79 -0
- package/.claude/skills/documentation-as-code/resources/markdown-best-practices.md +162 -0
- package/.claude/skills/documentation-as-code/resources/openapi-specification.md +77 -0
- package/.claude/skills/documentation-as-code/resources/readme-engineering.md +60 -0
- package/.claude/skills/documentation-as-code/resources/technical-writing-guide.md +202 -0
- package/.claude/skills/engineering-management/SKILL.md +356 -0
- package/.claude/skills/engineering-management/resources/career-ladders.md +609 -0
- package/.claude/skills/engineering-management/resources/hiring-and-assessment.md +555 -0
- package/.claude/skills/engineering-management/resources/one-on-one-guides.md +609 -0
- package/.claude/skills/engineering-management/resources/resource-planning.md +557 -0
- package/.claude/skills/engineering-management/resources/team-organization-patterns.md +491 -0
- package/.claude/skills/engineering-management/resources/technical-interviews.md +474 -0
- package/.claude/skills/engineering-operations-management/SKILL.md +817 -0
- package/.claude/skills/error-tracking/SKILL.md +379 -0
- package/.claude/skills/frontend-dev-guidelines/SKILL.md +403 -0
- package/.claude/skills/frontend-dev-guidelines/resources/common-patterns.md +331 -0
- package/.claude/skills/frontend-dev-guidelines/resources/complete-examples.md +872 -0
- package/.claude/skills/frontend-dev-guidelines/resources/component-patterns.md +502 -0
- package/.claude/skills/frontend-dev-guidelines/resources/data-fetching.md +767 -0
- package/.claude/skills/frontend-dev-guidelines/resources/file-organization.md +502 -0
- package/.claude/skills/frontend-dev-guidelines/resources/loading-and-error-states.md +501 -0
- package/.claude/skills/frontend-dev-guidelines/resources/performance.md +406 -0
- package/.claude/skills/frontend-dev-guidelines/resources/routing-guide.md +364 -0
- package/.claude/skills/frontend-dev-guidelines/resources/styling-guide.md +428 -0
- package/.claude/skills/frontend-dev-guidelines/resources/typescript-standards.md +418 -0
- package/.claude/skills/general-it-engineering/SKILL.md +393 -0
- package/.claude/skills/general-it-engineering/resources/asset-management.md +712 -0
- package/.claude/skills/general-it-engineering/resources/automation-orchestration.md +817 -0
- package/.claude/skills/general-it-engineering/resources/business-continuity.md +786 -0
- package/.claude/skills/general-it-engineering/resources/change-management.md +715 -0
- package/.claude/skills/general-it-engineering/resources/enterprise-monitoring.md +729 -0
- package/.claude/skills/general-it-engineering/resources/help-desk-operations.md +738 -0
- package/.claude/skills/general-it-engineering/resources/incident-service-management.md +834 -0
- package/.claude/skills/general-it-engineering/resources/it-governance.md +753 -0
- package/.claude/skills/general-it-engineering/resources/itil-framework.md +503 -0
- package/.claude/skills/general-it-engineering/resources/service-management.md +669 -0
- package/.claude/skills/infrastructure-architecture/SKILL.md +328 -0
- package/.claude/skills/infrastructure-architecture/resources/architecture-decision-records.md +505 -0
- package/.claude/skills/infrastructure-architecture/resources/architecture-patterns.md +528 -0
- package/.claude/skills/infrastructure-architecture/resources/capacity-planning.md +453 -0
- package/.claude/skills/infrastructure-architecture/resources/cleared-environment-architecture.md +773 -0
- package/.claude/skills/infrastructure-architecture/resources/cost-architecture.md +499 -0
- package/.claude/skills/infrastructure-architecture/resources/data-architecture.md +501 -0
- package/.claude/skills/infrastructure-architecture/resources/disaster-recovery.md +535 -0
- package/.claude/skills/infrastructure-architecture/resources/migration-architecture.md +512 -0
- package/.claude/skills/infrastructure-architecture/resources/multi-region-design.md +608 -0
- package/.claude/skills/infrastructure-architecture/resources/reference-architectures.md +562 -0
- package/.claude/skills/infrastructure-architecture/resources/security-architecture.md +538 -0
- package/.claude/skills/infrastructure-architecture/resources/system-design-principles.md +489 -0
- package/.claude/skills/infrastructure-architecture/resources/workload-classification.md +1000 -0
- package/.claude/skills/infrastructure-strategy/SKILL.md +924 -0
- package/.claude/skills/network-engineering/SKILL.md +385 -0
- package/.claude/skills/network-engineering/resources/dns-management.md +738 -0
- package/.claude/skills/network-engineering/resources/load-balancing.md +820 -0
- package/.claude/skills/network-engineering/resources/network-architecture.md +546 -0
- package/.claude/skills/network-engineering/resources/network-security.md +921 -0
- package/.claude/skills/network-engineering/resources/network-troubleshooting.md +749 -0
- package/.claude/skills/network-engineering/resources/routing-switching.md +373 -0
- package/.claude/skills/network-engineering/resources/sdn-networking.md +695 -0
- package/.claude/skills/network-engineering/resources/service-mesh-networking.md +777 -0
- package/.claude/skills/network-engineering/resources/tcp-ip-protocols.md +444 -0
- package/.claude/skills/network-engineering/resources/vpn-connectivity.md +672 -0
- package/.claude/skills/observability-engineering/SKILL.md +101 -0
- package/.claude/skills/observability-engineering/resources/apm-tools.md +97 -0
- package/.claude/skills/observability-engineering/resources/correlation-strategies.md +87 -0
- package/.claude/skills/observability-engineering/resources/distributed-tracing.md +98 -0
- package/.claude/skills/observability-engineering/resources/logs-aggregation.md +118 -0
- package/.claude/skills/observability-engineering/resources/observability-cost-optimization.md +141 -0
- package/.claude/skills/observability-engineering/resources/opentelemetry.md +110 -0
- package/.claude/skills/platform-engineering/SKILL.md +555 -0
- package/.claude/skills/platform-engineering/resources/architecture-overview.md +600 -0
- package/.claude/skills/platform-engineering/resources/container-orchestration.md +916 -0
- package/.claude/skills/platform-engineering/resources/cost-optimization.md +634 -0
- package/.claude/skills/platform-engineering/resources/developer-platforms.md +670 -0
- package/.claude/skills/platform-engineering/resources/gitops-automation.md +650 -0
- package/.claude/skills/platform-engineering/resources/infrastructure-as-code.md +778 -0
- package/.claude/skills/platform-engineering/resources/infrastructure-standards.md +708 -0
- package/.claude/skills/platform-engineering/resources/multi-tenancy.md +602 -0
- package/.claude/skills/platform-engineering/resources/platform-security.md +711 -0
- package/.claude/skills/platform-engineering/resources/resource-management.md +592 -0
- package/.claude/skills/platform-engineering/resources/service-mesh.md +628 -0
- package/.claude/skills/release-engineering/SKILL.md +393 -0
- package/.claude/skills/release-engineering/resources/artifact-management.md +108 -0
- package/.claude/skills/release-engineering/resources/build-optimization.md +84 -0
- package/.claude/skills/release-engineering/resources/ci-cd-pipelines.md +411 -0
- package/.claude/skills/release-engineering/resources/deployment-strategies.md +197 -0
- package/.claude/skills/release-engineering/resources/pipeline-security.md +62 -0
- package/.claude/skills/release-engineering/resources/progressive-delivery.md +83 -0
- package/.claude/skills/release-engineering/resources/release-automation.md +68 -0
- package/.claude/skills/release-engineering/resources/release-orchestration.md +77 -0
- package/.claude/skills/release-engineering/resources/rollback-strategies.md +66 -0
- package/.claude/skills/release-engineering/resources/versioning-strategies.md +59 -0
- package/.claude/skills/route-tester/SKILL.md +392 -0
- package/.claude/skills/skill-developer/ADVANCED.md +197 -0
- package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +306 -0
- package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +152 -0
- package/.claude/skills/skill-developer/SKILL.md +430 -0
- package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +315 -0
- package/.claude/skills/skill-developer/TRIGGER_TYPES.md +305 -0
- package/.claude/skills/skill-developer/TROUBLESHOOTING.md +514 -0
- package/.claude/skills/skill-rules.json +2940 -0
- package/.claude/skills/sre/SKILL.md +464 -0
- package/.claude/skills/sre/resources/alerting-best-practices.md +282 -0
- package/.claude/skills/sre/resources/capacity-planning.md +226 -0
- package/.claude/skills/sre/resources/chaos-engineering.md +193 -0
- package/.claude/skills/sre/resources/disaster-recovery.md +232 -0
- package/.claude/skills/sre/resources/incident-management.md +436 -0
- package/.claude/skills/sre/resources/observability-stack.md +240 -0
- package/.claude/skills/sre/resources/on-call-runbooks.md +167 -0
- package/.claude/skills/sre/resources/performance-optimization.md +108 -0
- package/.claude/skills/sre/resources/reliability-patterns.md +183 -0
- package/.claude/skills/sre/resources/slo-sli-sla.md +464 -0
- package/.claude/skills/sre/resources/toil-reduction.md +145 -0
- package/.claude/skills/systems-engineering/SKILL.md +648 -0
- package/.claude/skills/systems-engineering/resources/automation-patterns.md +771 -0
- package/.claude/skills/systems-engineering/resources/configuration-management.md +998 -0
- package/.claude/skills/systems-engineering/resources/linux-administration.md +672 -0
- package/.claude/skills/systems-engineering/resources/networking-fundamentals.md +982 -0
- package/.claude/skills/systems-engineering/resources/performance-tuning.md +871 -0
- package/.claude/skills/systems-engineering/resources/powershell-scripting.md +482 -0
- package/.claude/skills/systems-engineering/resources/security-hardening.md +739 -0
- package/.claude/skills/systems-engineering/resources/shell-scripting.md +915 -0
- package/.claude/skills/systems-engineering/resources/storage-management.md +628 -0
- package/.claude/skills/systems-engineering/resources/system-monitoring.md +787 -0
- package/.claude/skills/systems-engineering/resources/troubleshooting-guide.md +753 -0
- package/.claude/skills/systems-engineering/resources/windows-administration.md +738 -0
- package/.claude/skills/technical-leadership/SKILL.md +728 -0
- package/CHANGELOG.md +102 -42
- package/CLAUDE.md +284 -0
- package/README.md +315 -71
- package/backend/docs/SECRETS_DOCUMENTATION.md +327 -0
- package/backend/jest.config.js +59 -0
- package/backend/package-lock.json +6801 -0
- package/backend/package.json +24 -4
- package/backend/prisma/migrations/20251026104609_add_websocket_api/migration.sql +33 -0
- package/backend/prisma/migrations/20251116111851_add_execution_trace/migration.sql +22 -0
- package/backend/prisma/migrations/20251120154914_add_panel_api_keys/migration.sql +21 -0
- package/backend/prisma/migrations/20251121110241_add_proxy_table/migration.sql +45 -0
- package/backend/prisma/migrations/migration_lock.toml +2 -2
- package/backend/prisma/schema.prisma +103 -1
- package/backend/src/__tests__/core/DependencyService.test.js +336 -0
- package/backend/src/__tests__/core/UserService.test.js +875 -0
- package/backend/src/__tests__/repositories/BaseRepository.test.js +146 -0
- package/backend/src/__tests__/repositories/BotRepository.test.js +118 -0
- package/backend/src/__tests__/repositories/CommandRepository.test.js +132 -0
- package/backend/src/__tests__/repositories/EventGraphRepository.test.js +93 -0
- package/backend/src/__tests__/repositories/GroupRepository.test.js +155 -0
- package/backend/src/__tests__/repositories/PermissionRepository.test.js +130 -0
- package/backend/src/__tests__/repositories/PluginRepository.test.js +107 -0
- package/backend/src/__tests__/repositories/ServerRepository.test.js +80 -0
- package/backend/src/__tests__/repositories/UserRepository.test.js +128 -0
- package/backend/src/__tests__/secretsFilter.test.js +425 -0
- package/backend/src/__tests__/services/BotLifecycleService.test.js +416 -0
- package/backend/src/__tests__/services/BotProcessManager.test.js +285 -0
- package/backend/src/__tests__/services/CacheManager.test.js +125 -0
- package/backend/src/__tests__/services/CommandExecutionService.test.js +460 -0
- package/backend/src/__tests__/services/ResourceMonitorService.test.js +207 -0
- package/backend/src/__tests__/services/TelemetryService.test.js +291 -0
- package/backend/src/__tests__/setup.js +25 -0
- package/backend/src/ai/plugin-assistant-system-prompt.md +788 -0
- package/backend/src/api/middleware/auth.js +27 -0
- package/backend/src/api/middleware/botAccess.js +7 -3
- package/backend/src/api/middleware/panelApiAuth.js +135 -0
- package/backend/src/api/routes/aiAssistant.js +995 -0
- package/backend/src/api/routes/apiKeys.js +181 -0
- package/backend/src/api/routes/auth.js +669 -633
- package/backend/src/api/routes/botCommands.js +107 -0
- package/backend/src/api/routes/botGroups.js +165 -0
- package/backend/src/api/routes/botHistory.js +108 -0
- package/backend/src/api/routes/botPermissions.js +99 -0
- package/backend/src/api/routes/botStatus.js +36 -0
- package/backend/src/api/routes/botUsers.js +162 -0
- package/backend/src/api/routes/bots.js +2451 -2360
- package/backend/src/api/routes/eventGraphs.js +4 -1
- package/backend/src/api/routes/logs.js +13 -3
- package/backend/src/api/routes/panel.js +66 -66
- package/backend/src/api/routes/panelApiKeys.js +179 -0
- package/backend/src/api/routes/pluginIde.js +1715 -135
- package/backend/src/api/routes/plugins.js +376 -218
- package/backend/src/api/routes/proxies.js +130 -0
- package/backend/src/api/routes/search.js +4 -0
- package/backend/src/api/routes/servers.js +20 -3
- package/backend/src/api/routes/settings.js +5 -0
- package/backend/src/api/routes/system.js +174 -0
- package/backend/src/api/routes/traces.js +131 -0
- package/backend/src/config/debug.config.js +36 -0
- package/backend/src/container.js +82 -0
- package/backend/src/core/BotHistoryStore.js +180 -0
- package/backend/src/core/BotManager.js +149 -868
- package/backend/src/core/BotManager.old.js +1093 -0
- package/backend/src/core/BotProcess.js +850 -191
- package/backend/src/core/EventGraphManager.js +194 -198
- package/backend/src/core/GraphExecutionEngine.js +709 -57
- package/backend/src/core/MessageQueue.js +39 -12
- package/backend/src/core/NodeRegistry.js +37 -1134
- package/backend/src/core/PluginLoader.js +99 -5
- package/backend/src/core/PluginManager.js +126 -15
- package/backend/src/core/PrismaService.js +32 -0
- package/backend/src/core/TaskScheduler.js +1 -1
- package/backend/src/core/UserService.js +3 -3
- package/backend/src/core/__tests__/PrismaService.test.js +24 -0
- package/backend/src/core/commands/README.md +305 -0
- package/backend/src/core/commands/dev.js +13 -7
- package/backend/src/core/commands/ping.js +10 -4
- package/backend/src/core/commands/whois.js +63 -0
- package/backend/src/core/config/validation.js +27 -0
- package/backend/src/core/constants/graphTypes.js +21 -0
- package/backend/src/core/node-registries/actions.js +202 -0
- package/backend/src/core/node-registries/arrays.js +155 -0
- package/backend/src/core/node-registries/bot.js +23 -0
- package/backend/src/core/node-registries/data.js +290 -0
- package/backend/src/core/node-registries/debug.js +26 -0
- package/backend/src/core/node-registries/events.js +201 -0
- package/backend/src/core/node-registries/flow.js +139 -0
- package/backend/src/core/node-registries/logic.js +62 -0
- package/backend/src/core/node-registries/math.js +42 -0
- package/backend/src/core/node-registries/objects.js +98 -0
- package/backend/src/core/node-registries/strings.js +187 -0
- package/backend/src/core/node-registries/time.js +113 -0
- package/backend/src/core/node-registries/type.js +25 -0
- package/backend/src/core/node-registries/users.js +79 -0
- package/backend/src/core/nodes/{action_bot_look_at.js → actions/bot_look_at.js} +36 -36
- package/backend/src/core/nodes/{action_bot_set_variable.js → actions/bot_set_variable.js} +32 -32
- package/backend/src/core/nodes/actions/create_command.js +189 -0
- package/backend/src/core/nodes/actions/delete_command.js +92 -0
- package/backend/src/core/nodes/{action_send_log.js → actions/send_log.js} +28 -23
- package/backend/src/core/nodes/{action_send_message.js → actions/send_message.js} +32 -32
- package/backend/src/core/nodes/actions/send_websocket_response.js +33 -0
- package/backend/src/core/nodes/actions/update_command.js +133 -0
- package/backend/src/core/nodes/arrays/get_next.js +35 -0
- package/backend/src/core/nodes/arrays/join.js +28 -0
- package/backend/src/core/nodes/{data_cast.js → data/cast.js} +10 -1
- package/backend/src/core/nodes/data/datetime_literal.js +27 -0
- package/backend/src/core/nodes/data/entity_info.js +69 -0
- package/backend/src/core/nodes/data/get_nearby_entities.js +32 -0
- package/backend/src/core/nodes/data/get_nearby_players.js +64 -0
- package/backend/src/core/nodes/{data_get_user_field.js → data/get_user_field.js} +1 -1
- package/backend/src/core/nodes/data/type_check.js +53 -0
- package/backend/src/core/nodes/{debug_log.js → debug/log.js} +16 -16
- package/backend/src/core/nodes/{flow_branch.js → flow/branch.js} +15 -15
- package/backend/src/core/nodes/{flow_break.js → flow/break.js} +14 -14
- package/backend/src/core/nodes/flow/delay.js +43 -0
- package/backend/src/core/nodes/{flow_for_each.js → flow/for_each.js} +39 -39
- package/backend/src/core/nodes/{flow_sequence.js → flow/sequence.js} +16 -16
- package/backend/src/core/nodes/{flow_switch.js → flow/switch.js} +47 -47
- package/backend/src/core/nodes/{flow_while.js → flow/while.js} +1 -1
- package/backend/src/core/nodes/logic/__tests__/compare.test.js +83 -0
- package/backend/src/core/nodes/logic/not.js +22 -0
- package/backend/src/core/nodes/math/__tests__/operation.test.js +65 -0
- package/backend/src/core/nodes/strings/__tests__/concat.test.js +89 -0
- package/backend/src/core/nodes/{string_starts_with.js → strings/starts_with.js} +1 -1
- package/backend/src/core/nodes/strings/to_lower.js +22 -0
- package/backend/src/core/nodes/strings/to_upper.js +22 -0
- package/backend/src/core/nodes/time/__tests__/now.test.js +24 -0
- package/backend/src/core/nodes/time/add.js +33 -0
- package/backend/src/core/nodes/time/compare.js +35 -0
- package/backend/src/core/nodes/time/diff.js +29 -0
- package/backend/src/core/nodes/time/format.js +32 -0
- package/backend/src/core/nodes/time/now.js +18 -0
- package/backend/src/core/nodes/type/to_string.js +32 -0
- package/backend/src/core/nodes/{user_check_blacklist.js → users/check_blacklist.js} +37 -37
- package/backend/src/core/nodes/{user_get_groups.js → users/get_groups.js} +36 -36
- package/backend/src/core/nodes/{user_get_permissions.js → users/get_permissions.js} +36 -36
- package/backend/src/core/nodes/{user_set_blacklist.js → users/set_blacklist.js} +37 -37
- package/backend/src/core/services/BotLifecycleService.js +835 -0
- package/backend/src/core/services/BotProcessManager.js +163 -0
- package/backend/src/core/services/CacheManager.js +111 -0
- package/backend/src/core/services/CommandExecutionService.js +430 -0
- package/backend/src/core/services/DebugSessionManager.js +347 -0
- package/backend/src/core/services/GraphCollaborationManager.js +501 -0
- package/backend/src/core/services/MinecraftBotManager.js +259 -0
- package/backend/src/core/services/MinecraftViewerService.js +216 -0
- package/backend/src/core/services/ResourceMonitorService.js +90 -0
- package/backend/src/core/services/TelemetryService.js +124 -0
- package/backend/src/core/services/TraceCollectorService.js +545 -0
- package/backend/src/core/services/ValidationService.js +132 -0
- package/backend/src/core/services/__tests__/ValidationService.test.js +148 -0
- package/backend/src/core/services.js +20 -5
- package/backend/src/core/system/CommandContext.js +84 -0
- package/backend/src/core/system/RuntimeCommandRegistry.js +116 -0
- package/backend/src/core/system/Transport.js +74 -0
- package/backend/src/core/utils/__tests__/jsonParser.test.js +44 -0
- package/backend/src/core/utils/jsonParser.js +18 -0
- package/backend/src/core/utils/secretsFilter.js +262 -0
- package/backend/src/core/utils/variableParser.js +89 -0
- package/backend/src/core/validation/__tests__/nodeSchemas.test.js +175 -0
- package/backend/src/core/validation/nodeSchemas.js +112 -0
- package/backend/src/lib/prisma.js +2 -4
- package/backend/src/real-time/botApi/handlers/commandHandlers.js +28 -0
- package/backend/src/real-time/botApi/handlers/graphHandlers.js +99 -0
- package/backend/src/real-time/botApi/handlers/graphWebSocketHandlers.js +147 -0
- package/backend/src/real-time/botApi/handlers/index.js +43 -0
- package/backend/src/real-time/botApi/handlers/messageHandlers.js +66 -0
- package/backend/src/real-time/botApi/handlers/statusHandlers.js +17 -0
- package/backend/src/real-time/botApi/handlers/userHandlers.js +141 -0
- package/backend/src/real-time/botApi/index.js +40 -0
- package/backend/src/real-time/botApi/middleware.js +79 -0
- package/backend/src/real-time/botApi/utils.js +65 -0
- package/backend/src/real-time/panelNamespace.js +387 -0
- package/backend/src/real-time/presence.js +7 -2
- package/backend/src/real-time/socketHandler.js +400 -5
- package/backend/src/repositories/BaseRepository.js +43 -0
- package/backend/src/repositories/BotRepository.js +42 -0
- package/backend/src/repositories/CommandRepository.js +53 -0
- package/backend/src/repositories/EventGraphRepository.js +40 -0
- package/backend/src/repositories/GroupRepository.js +69 -0
- package/backend/src/repositories/PermissionRepository.js +48 -0
- package/backend/src/repositories/PluginRepository.js +42 -0
- package/backend/src/repositories/ServerRepository.js +27 -0
- package/backend/src/repositories/UserRepository.js +48 -0
- package/backend/src/server.js +21 -0
- package/backend/src/test-refactor.js +85 -0
- package/frontend/dist/assets/index-B1serztM.js +11210 -0
- package/frontend/dist/assets/index-t6K1u4OV.css +32 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/package-lock.json +9437 -0
- package/frontend/package.json +8 -5
- package/package.json +3 -2
- package/screen/console.png +0 -0
- package/screen/dashboard.png +0 -0
- package/screen/graph_collabe.png +0 -0
- package/screen/graph_live_debug.png +0 -0
- package/screen/management_command.png +0 -0
- package/screen/node_debug_trace.png +0 -0
- package/screen/plugin_/320/276/320/261/320/267/320/276/321/200.png +0 -0
- package/screen/websocket.png +0 -0
- package/screen//320/275/320/260/321/201/321/202/321/200/320/276/320/271/320/272/320/270_/320/276/321/202/320/264/320/265/320/273/321/214/320/275/321/213/321/205_/320/272/320/276/320/274/320/260/320/275/320/264_/320/272/320/260/320/266/320/264/321/203_/320/272/320/276/320/274/320/260/320/275/320/273/320/264/321/203_/320/274/320/276/320/266/320/275/320/276_/320/275/320/260/321/201/321/202/321/200/320/260/320/270/320/262/320/260/321/202/321/214.png +0 -0
- package/screen//320/277/320/273/320/260/320/275/320/270/321/200/320/276/320/262/321/211/320/270/320/272_/320/274/320/276/320/266/320/275/320/276_/320/267/320/260/320/264/320/260/320/262/320/260/321/202/321/214_/320/264/320/265/320/271/321/201/321/202/320/262/320/270/321/217_/320/277/320/276_/320/262/321/200/320/265/320/274/320/265/320/275/320/270.png +0 -0
- package/frontend/dist/assets/index-B9GedHEa.js +0 -8352
- package/frontend/dist/assets/index-zLiy9MDx.css +0 -1
- package/nul +0 -0
- /package/backend/src/core/nodes/{action_http_request.js → actions/http_request.js} +0 -0
- /package/backend/src/core/nodes/{array_add_element.js → arrays/add_element.js} +0 -0
- /package/backend/src/core/nodes/{array_contains.js → arrays/contains.js} +0 -0
- /package/backend/src/core/nodes/{array_find_index.js → arrays/find_index.js} +0 -0
- /package/backend/src/core/nodes/{array_get_by_index.js → arrays/get_by_index.js} +0 -0
- /package/backend/src/core/nodes/{array_get_random_element.js → arrays/get_random_element.js} +0 -0
- /package/backend/src/core/nodes/{array_remove_by_index.js → arrays/remove_by_index.js} +0 -0
- /package/backend/src/core/nodes/{bot_get_position.js → bot/get_position.js} +0 -0
- /package/backend/src/core/nodes/{data_array_literal.js → data/array_literal.js} +0 -0
- /package/backend/src/core/nodes/{data_boolean_literal.js → data/boolean_literal.js} +0 -0
- /package/backend/src/core/nodes/{data_get_argument.js → data/get_argument.js} +0 -0
- /package/backend/src/core/nodes/{data_get_bot_look.js → data/get_bot_look.js} +0 -0
- /package/backend/src/core/nodes/{data_get_entity_field.js → data/get_entity_field.js} +0 -0
- /package/backend/src/core/nodes/{data_get_server_players.js → data/get_server_players.js} +0 -0
- /package/backend/src/core/nodes/{data_get_variable.js → data/get_variable.js} +0 -0
- /package/backend/src/core/nodes/{data_length.js → data/length.js} +0 -0
- /package/backend/src/core/nodes/{data_make_object.js → data/make_object.js} +0 -0
- /package/backend/src/core/nodes/{data_number_literal.js → data/number_literal.js} +0 -0
- /package/backend/src/core/nodes/{data_string_literal.js → data/string_literal.js} +0 -0
- /package/backend/src/core/nodes/{logic_compare.js → logic/compare.js} +0 -0
- /package/backend/src/core/nodes/{logic_operation.js → logic/operation.js} +0 -0
- /package/backend/src/core/nodes/{math_operation.js → math/operation.js} +0 -0
- /package/backend/src/core/nodes/{math_random_number.js → math/random_number.js} +0 -0
- /package/backend/src/core/nodes/{object_create.js → objects/create.js} +0 -0
- /package/backend/src/core/nodes/{object_delete.js → objects/delete.js} +0 -0
- /package/backend/src/core/nodes/{object_get.js → objects/get.js} +0 -0
- /package/backend/src/core/nodes/{object_has_key.js → objects/has_key.js} +0 -0
- /package/backend/src/core/nodes/{object_set.js → objects/set.js} +0 -0
- /package/backend/src/core/nodes/{string_concat.js → strings/concat.js} +0 -0
- /package/backend/src/core/nodes/{string_contains.js → strings/contains.js} +0 -0
- /package/backend/src/core/nodes/{string_ends_with.js → strings/ends_with.js} +0 -0
- /package/backend/src/core/nodes/{string_equals.js → strings/equals.js} +0 -0
- /package/backend/src/core/nodes/{string_length.js → strings/length.js} +0 -0
- /package/backend/src/core/nodes/{string_matches.js → strings/matches.js} +0 -0
- /package/backend/src/core/nodes/{string_split.js → strings/split.js} +0 -0
|
@@ -0,0 +1,1198 @@
|
|
|
1
|
+
# Oracle Cloud Infrastructure (OCI) Patterns
|
|
2
|
+
|
|
3
|
+
Comprehensive guide to Oracle Cloud Infrastructure covering core services, architectural patterns, and best practices for building scalable, reliable, and secure cloud infrastructure on OCI.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [OCI Service Overview](#oci-service-overview)
|
|
8
|
+
- [Compute Services](#compute-services)
|
|
9
|
+
- [Storage Services](#storage-services)
|
|
10
|
+
- [Database Services](#database-services)
|
|
11
|
+
- [Networking Services](#networking-services)
|
|
12
|
+
- [Container and Kubernetes Services](#container-and-kubernetes-services)
|
|
13
|
+
- [Serverless Services](#serverless-services)
|
|
14
|
+
- [Identity and Security](#identity-and-security)
|
|
15
|
+
- [Monitoring and Management](#monitoring-and-management)
|
|
16
|
+
- [Common Patterns](#common-patterns)
|
|
17
|
+
- [Best Practices](#best-practices)
|
|
18
|
+
- [Anti-Patterns](#anti-patterns)
|
|
19
|
+
|
|
20
|
+
## OCI Service Overview
|
|
21
|
+
|
|
22
|
+
### Service Categories
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Compute: Compute Instances, Bare Metal, Container Engine (OKE), Functions
|
|
26
|
+
Storage: Object Storage, Block Volumes, File Storage, Archive Storage
|
|
27
|
+
Database: Autonomous Database, Base Database, MySQL, PostgreSQL, NoSQL
|
|
28
|
+
Networking: VCN, Load Balancer, FastConnect, DNS, VPN, Service Gateway
|
|
29
|
+
Security: IAM, Vault, Bastion, WAF, Cloud Guard
|
|
30
|
+
Monitoring: Monitoring, Logging, Events, Notifications, APM
|
|
31
|
+
DevOps: DevOps Service, Resource Manager (Terraform), API Gateway
|
|
32
|
+
Analytics: Data Integration, Data Flow, Analytics Cloud
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### OCI Regions and Availability Domains
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
Region: Geographic area (e.g., us-ashburn-1, uk-london-1)
|
|
39
|
+
Availability Domain: Isolated data centers within region (AD-1, AD-2, AD-3)
|
|
40
|
+
Fault Domain: Logical grouping within AD for high availability
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Compute Services
|
|
44
|
+
|
|
45
|
+
### Compute Instances
|
|
46
|
+
|
|
47
|
+
**VM Shapes:**
|
|
48
|
+
```
|
|
49
|
+
Standard (VM.Standard): General purpose workloads
|
|
50
|
+
DenseIO (VM.DenseIO): High local NVMe storage
|
|
51
|
+
GPU (VM.GPU): ML training, graphics rendering
|
|
52
|
+
HPC (BM.HPC): High-performance computing
|
|
53
|
+
Bare Metal (BM.Standard): No virtualization overhead
|
|
54
|
+
Flexible (VM.Standard.E4.Flex): Custom CPU/memory ratio
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Example: Compute Instance with Terraform:**
|
|
58
|
+
```hcl
|
|
59
|
+
# compute_instance.tf
|
|
60
|
+
resource "oci_core_instance" "app_server" {
|
|
61
|
+
availability_domain = data.oci_identity_availability_domain.ad1.name
|
|
62
|
+
compartment_id = var.compartment_id
|
|
63
|
+
display_name = "app-server-${var.environment}"
|
|
64
|
+
shape = "VM.Standard.E4.Flex"
|
|
65
|
+
|
|
66
|
+
# Flexible shape configuration
|
|
67
|
+
shape_config {
|
|
68
|
+
ocpus = 2
|
|
69
|
+
memory_in_gbs = 16
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# Boot volume
|
|
73
|
+
create_vnic_details {
|
|
74
|
+
subnet_id = oci_core_subnet.private.id
|
|
75
|
+
assign_public_ip = false
|
|
76
|
+
hostname_label = "app-server"
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
source_details {
|
|
80
|
+
source_type = "image"
|
|
81
|
+
source_id = data.oci_core_images.oracle_linux.images[0].id
|
|
82
|
+
boot_volume_size_in_gbs = 100
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# Cloud-init configuration
|
|
86
|
+
metadata = {
|
|
87
|
+
ssh_authorized_keys = file("~/.ssh/id_rsa.pub")
|
|
88
|
+
user_data = base64encode(file("${path.module}/cloud-init.yaml"))
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# High availability
|
|
92
|
+
fault_domain = "FAULT-DOMAIN-1"
|
|
93
|
+
|
|
94
|
+
# Tags
|
|
95
|
+
freeform_tags = {
|
|
96
|
+
Environment = var.environment
|
|
97
|
+
ManagedBy = "terraform"
|
|
98
|
+
Application = "web-app"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# Instance pool for auto-scaling
|
|
103
|
+
resource "oci_core_instance_pool" "app_pool" {
|
|
104
|
+
compartment_id = var.compartment_id
|
|
105
|
+
display_name = "app-instance-pool"
|
|
106
|
+
|
|
107
|
+
instance_configuration_id = oci_core_instance_configuration.app.id
|
|
108
|
+
|
|
109
|
+
placement_configurations {
|
|
110
|
+
availability_domain = data.oci_identity_availability_domain.ad1.name
|
|
111
|
+
primary_subnet_id = oci_core_subnet.private.id
|
|
112
|
+
|
|
113
|
+
fault_domains = [
|
|
114
|
+
"FAULT-DOMAIN-1",
|
|
115
|
+
"FAULT-DOMAIN-2",
|
|
116
|
+
"FAULT-DOMAIN-3"
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
size = 3
|
|
121
|
+
|
|
122
|
+
load_balancers {
|
|
123
|
+
backend_set_name = oci_load_balancer_backend_set.app.name
|
|
124
|
+
load_balancer_id = oci_load_balancer_load_balancer.public.id
|
|
125
|
+
port = 8080
|
|
126
|
+
vnic_selection = "PrimaryVnic"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# Auto-scaling configuration
|
|
131
|
+
resource "oci_autoscaling_auto_scaling_configuration" "app" {
|
|
132
|
+
compartment_id = var.compartment_id
|
|
133
|
+
display_name = "app-autoscaling"
|
|
134
|
+
auto_scaling_resources {
|
|
135
|
+
id = oci_core_instance_pool.app_pool.id
|
|
136
|
+
type = "instancePool"
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
policies {
|
|
140
|
+
display_name = "cpu-based-autoscaling"
|
|
141
|
+
policy_type = "threshold"
|
|
142
|
+
capacity {
|
|
143
|
+
initial = 3
|
|
144
|
+
max = 10
|
|
145
|
+
min = 2
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
rules {
|
|
149
|
+
display_name = "scale-out-rule"
|
|
150
|
+
action {
|
|
151
|
+
type = "CHANGE_COUNT_BY"
|
|
152
|
+
value = 1
|
|
153
|
+
}
|
|
154
|
+
metric {
|
|
155
|
+
metric_type = "CPU_UTILIZATION"
|
|
156
|
+
threshold {
|
|
157
|
+
operator = "GT"
|
|
158
|
+
value = 75
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
rules {
|
|
164
|
+
display_name = "scale-in-rule"
|
|
165
|
+
action {
|
|
166
|
+
type = "CHANGE_COUNT_BY"
|
|
167
|
+
value = -1
|
|
168
|
+
}
|
|
169
|
+
metric {
|
|
170
|
+
metric_type = "CPU_UTILIZATION"
|
|
171
|
+
threshold {
|
|
172
|
+
operator = "LT"
|
|
173
|
+
value = 25
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Bare Metal Instances
|
|
182
|
+
|
|
183
|
+
**When to Use:**
|
|
184
|
+
- No virtualization overhead for maximum performance
|
|
185
|
+
- Oracle Database workloads
|
|
186
|
+
- Compliance requirements
|
|
187
|
+
- Large memory requirements (up to 2TB)
|
|
188
|
+
|
|
189
|
+
```hcl
|
|
190
|
+
resource "oci_core_instance" "bare_metal_db" {
|
|
191
|
+
availability_domain = data.oci_identity_availability_domain.ad1.name
|
|
192
|
+
compartment_id = var.compartment_id
|
|
193
|
+
display_name = "oracle-db-server"
|
|
194
|
+
shape = "BM.Standard2.52" # 52 OCPUs, 768 GB memory
|
|
195
|
+
|
|
196
|
+
create_vnic_details {
|
|
197
|
+
subnet_id = oci_core_subnet.database.id
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
source_details {
|
|
201
|
+
source_type = "image"
|
|
202
|
+
source_id = data.oci_database_db_system_shapes.db_shapes.db_system_shapes[0].id
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
# Local NVMe storage
|
|
206
|
+
launch_options {
|
|
207
|
+
boot_volume_type = "ISCSI"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Storage Services
|
|
213
|
+
|
|
214
|
+
### Object Storage
|
|
215
|
+
|
|
216
|
+
**Storage Tiers:**
|
|
217
|
+
```
|
|
218
|
+
Standard: Frequent access, immediate availability
|
|
219
|
+
Infrequent: Accessed less than once per month, 90-day retention
|
|
220
|
+
Archive: Long-term retention, restore time required
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Example: Object Storage Bucket:**
|
|
224
|
+
```hcl
|
|
225
|
+
# object_storage.tf
|
|
226
|
+
resource "oci_objectstorage_bucket" "application_data" {
|
|
227
|
+
compartment_id = var.compartment_id
|
|
228
|
+
namespace = data.oci_objectstorage_namespace.ns.namespace
|
|
229
|
+
name = "application-data-${var.environment}"
|
|
230
|
+
access_type = "NoPublicAccess"
|
|
231
|
+
|
|
232
|
+
# Versioning for data protection
|
|
233
|
+
versioning = "Enabled"
|
|
234
|
+
|
|
235
|
+
# Storage tier
|
|
236
|
+
storage_tier = "Standard"
|
|
237
|
+
|
|
238
|
+
# Object lifecycle policy
|
|
239
|
+
retention_rules {
|
|
240
|
+
display_name = "retention-policy"
|
|
241
|
+
duration {
|
|
242
|
+
time_amount = 90
|
|
243
|
+
time_unit = "DAYS"
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
# Automatic tiering
|
|
248
|
+
auto_tiering = "InfrequentAccess"
|
|
249
|
+
|
|
250
|
+
freeform_tags = {
|
|
251
|
+
Environment = var.environment
|
|
252
|
+
DataClass = "sensitive"
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
# Pre-authenticated request for temporary access
|
|
257
|
+
resource "oci_objectstorage_preauthrequest" "temporary_upload" {
|
|
258
|
+
namespace = data.oci_objectstorage_namespace.ns.namespace
|
|
259
|
+
bucket = oci_objectstorage_bucket.application_data.name
|
|
260
|
+
name = "temp-upload-link"
|
|
261
|
+
access_type = "ObjectWrite"
|
|
262
|
+
time_expires = timeadd(timestamp(), "24h")
|
|
263
|
+
object_name = "uploads/"
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Block Volumes
|
|
268
|
+
|
|
269
|
+
**Volume Types:**
|
|
270
|
+
```
|
|
271
|
+
Balanced: Baseline performance, cost-effective
|
|
272
|
+
Higher Performance: Increased IOPS and throughput
|
|
273
|
+
Ultra High: Maximum performance for critical workloads
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Example: Block Volume with Backup:**
|
|
277
|
+
```hcl
|
|
278
|
+
# block_volume.tf
|
|
279
|
+
resource "oci_core_volume" "application_data" {
|
|
280
|
+
availability_domain = data.oci_identity_availability_domain.ad1.name
|
|
281
|
+
compartment_id = var.compartment_id
|
|
282
|
+
display_name = "app-data-volume"
|
|
283
|
+
size_in_gbs = 500
|
|
284
|
+
|
|
285
|
+
# Performance tier
|
|
286
|
+
vpus_per_gb = 20 # Higher performance
|
|
287
|
+
|
|
288
|
+
# Encryption
|
|
289
|
+
is_auto_tune_enabled = true
|
|
290
|
+
|
|
291
|
+
# Volume groups for consistent backups
|
|
292
|
+
volume_group_id = oci_core_volume_group.app.id
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
# Attach to instance
|
|
296
|
+
resource "oci_core_volume_attachment" "app_data_attachment" {
|
|
297
|
+
attachment_type = "paravirtualized"
|
|
298
|
+
instance_id = oci_core_instance.app_server.id
|
|
299
|
+
volume_id = oci_core_volume.application_data.id
|
|
300
|
+
device = "/dev/oracleoci/oraclevdb"
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
# Backup policy
|
|
304
|
+
resource "oci_core_volume_backup_policy_assignment" "app_backup" {
|
|
305
|
+
asset_id = oci_core_volume.application_data.id
|
|
306
|
+
policy_id = data.oci_core_volume_backup_policies.default_policies.volume_backup_policies[0].id
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### File Storage Service (FSS)
|
|
311
|
+
|
|
312
|
+
**Example: NFS File System:**
|
|
313
|
+
```hcl
|
|
314
|
+
# file_storage.tf
|
|
315
|
+
resource "oci_file_storage_file_system" "shared_storage" {
|
|
316
|
+
availability_domain = data.oci_identity_availability_domain.ad1.name
|
|
317
|
+
compartment_id = var.compartment_id
|
|
318
|
+
display_name = "shared-application-storage"
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
resource "oci_file_storage_mount_target" "mount_target" {
|
|
322
|
+
availability_domain = data.oci_identity_availability_domain.ad1.name
|
|
323
|
+
compartment_id = var.compartment_id
|
|
324
|
+
subnet_id = oci_core_subnet.private.id
|
|
325
|
+
display_name = "mount-target-ad1"
|
|
326
|
+
|
|
327
|
+
hostname_label = "fss-mt"
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
resource "oci_file_storage_export" "export" {
|
|
331
|
+
export_set_id = oci_file_storage_mount_target.mount_target.export_set_id
|
|
332
|
+
file_system_id = oci_file_storage_file_system.shared_storage.id
|
|
333
|
+
path = "/shared"
|
|
334
|
+
|
|
335
|
+
export_options {
|
|
336
|
+
source = "10.0.0.0/16"
|
|
337
|
+
access = "READ_WRITE"
|
|
338
|
+
identity_squash = "NONE"
|
|
339
|
+
require_privileged_source_port = false
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## Database Services
|
|
345
|
+
|
|
346
|
+
### Autonomous Database
|
|
347
|
+
|
|
348
|
+
**Database Workload Types:**
|
|
349
|
+
```
|
|
350
|
+
ATP (Transaction Processing): OLTP workloads
|
|
351
|
+
ADW (Data Warehouse): Analytics and reporting
|
|
352
|
+
APEX: Low-code application development
|
|
353
|
+
AJD (JSON): JSON document store
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
**Example: Autonomous Database:**
|
|
357
|
+
```hcl
|
|
358
|
+
# autonomous_database.tf
|
|
359
|
+
resource "oci_database_autonomous_database" "app_db" {
|
|
360
|
+
compartment_id = var.compartment_id
|
|
361
|
+
db_name = "APPDB"
|
|
362
|
+
display_name = "application-database-${var.environment}"
|
|
363
|
+
admin_password = var.db_admin_password
|
|
364
|
+
db_workload = "OLTP" # ATP
|
|
365
|
+
cpu_core_count = 2
|
|
366
|
+
data_storage_size_in_tbs = 1
|
|
367
|
+
|
|
368
|
+
# Auto-scaling
|
|
369
|
+
is_auto_scaling_enabled = true
|
|
370
|
+
is_auto_scaling_for_storage_enabled = true
|
|
371
|
+
|
|
372
|
+
# High availability
|
|
373
|
+
is_dedicated = false
|
|
374
|
+
is_free_tier = false
|
|
375
|
+
|
|
376
|
+
# Network access
|
|
377
|
+
subnet_id = oci_core_subnet.database.id
|
|
378
|
+
nsg_ids = [oci_core_network_security_group.db.id]
|
|
379
|
+
is_mtls_connection_required = true
|
|
380
|
+
|
|
381
|
+
# Backup configuration
|
|
382
|
+
is_data_guard_enabled = true
|
|
383
|
+
db_version = "19c"
|
|
384
|
+
|
|
385
|
+
# License
|
|
386
|
+
license_model = "LICENSE_INCLUDED"
|
|
387
|
+
|
|
388
|
+
freeform_tags = {
|
|
389
|
+
Environment = var.environment
|
|
390
|
+
DatabaseType = "autonomous"
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
# Autonomous Database backup
|
|
395
|
+
resource "oci_database_autonomous_database_backup" "manual_backup" {
|
|
396
|
+
autonomous_database_id = oci_database_autonomous_database.app_db.id
|
|
397
|
+
display_name = "manual-backup-${formatdate("YYYY-MM-DD", timestamp())}"
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### MySQL Database Service
|
|
402
|
+
|
|
403
|
+
**Example: MySQL HeatWave:**
|
|
404
|
+
```hcl
|
|
405
|
+
# mysql_database.tf
|
|
406
|
+
resource "oci_mysql_mysql_db_system" "app_mysql" {
|
|
407
|
+
compartment_id = var.compartment_id
|
|
408
|
+
shape_name = "MySQL.VM.Standard.E4.4.64GB"
|
|
409
|
+
subnet_id = oci_core_subnet.database.id
|
|
410
|
+
availability_domain = data.oci_identity_availability_domain.ad1.name
|
|
411
|
+
|
|
412
|
+
admin_password = var.mysql_admin_password
|
|
413
|
+
admin_username = "admin"
|
|
414
|
+
|
|
415
|
+
# High availability
|
|
416
|
+
is_highly_available = true
|
|
417
|
+
|
|
418
|
+
# Data storage
|
|
419
|
+
data_storage_size_in_gb = 100
|
|
420
|
+
|
|
421
|
+
# Backup
|
|
422
|
+
backup_policy {
|
|
423
|
+
is_enabled = true
|
|
424
|
+
retention_in_days = 7
|
|
425
|
+
window_start_time = "02:00"
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
# HeatWave cluster for analytics
|
|
429
|
+
is_heat_wave_cluster_attached = true
|
|
430
|
+
heat_wave_cluster {
|
|
431
|
+
shape_name = "MySQL.HeatWave.VM.Standard.E3"
|
|
432
|
+
cluster_size = 2
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
display_name = "mysql-db-${var.environment}"
|
|
436
|
+
|
|
437
|
+
freeform_tags = {
|
|
438
|
+
Environment = var.environment
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
## Networking Services
|
|
444
|
+
|
|
445
|
+
### Virtual Cloud Network (VCN)
|
|
446
|
+
|
|
447
|
+
**Example: Production VCN with Multiple Tiers:**
|
|
448
|
+
```hcl
|
|
449
|
+
# vcn.tf
|
|
450
|
+
resource "oci_core_vcn" "production" {
|
|
451
|
+
compartment_id = var.compartment_id
|
|
452
|
+
cidr_blocks = ["10.0.0.0/16"]
|
|
453
|
+
display_name = "production-vcn"
|
|
454
|
+
dns_label = "prodvcn"
|
|
455
|
+
|
|
456
|
+
is_ipv6enabled = false
|
|
457
|
+
|
|
458
|
+
freeform_tags = {
|
|
459
|
+
Environment = "production"
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
# Internet Gateway for public subnets
|
|
464
|
+
resource "oci_core_internet_gateway" "public" {
|
|
465
|
+
compartment_id = var.compartment_id
|
|
466
|
+
vcn_id = oci_core_vcn.production.id
|
|
467
|
+
display_name = "internet-gateway"
|
|
468
|
+
enabled = true
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
# NAT Gateway for private subnets
|
|
472
|
+
resource "oci_core_nat_gateway" "private" {
|
|
473
|
+
compartment_id = var.compartment_id
|
|
474
|
+
vcn_id = oci_core_vcn.production.id
|
|
475
|
+
display_name = "nat-gateway"
|
|
476
|
+
block_traffic = false
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
# Service Gateway for OCI services
|
|
480
|
+
resource "oci_core_service_gateway" "oci_services" {
|
|
481
|
+
compartment_id = var.compartment_id
|
|
482
|
+
vcn_id = oci_core_vcn.production.id
|
|
483
|
+
display_name = "service-gateway"
|
|
484
|
+
|
|
485
|
+
services {
|
|
486
|
+
service_id = data.oci_core_services.all_services.services[0].id
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
# Public subnet
|
|
491
|
+
resource "oci_core_subnet" "public" {
|
|
492
|
+
compartment_id = var.compartment_id
|
|
493
|
+
vcn_id = oci_core_vcn.production.id
|
|
494
|
+
cidr_block = "10.0.1.0/24"
|
|
495
|
+
display_name = "public-subnet"
|
|
496
|
+
dns_label = "public"
|
|
497
|
+
route_table_id = oci_core_route_table.public.id
|
|
498
|
+
security_list_ids = [oci_core_security_list.public.id]
|
|
499
|
+
prohibit_public_ip_on_vnic = false
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
# Private subnet (application tier)
|
|
503
|
+
resource "oci_core_subnet" "private_app" {
|
|
504
|
+
compartment_id = var.compartment_id
|
|
505
|
+
vcn_id = oci_core_vcn.production.id
|
|
506
|
+
cidr_block = "10.0.10.0/24"
|
|
507
|
+
display_name = "private-app-subnet"
|
|
508
|
+
dns_label = "app"
|
|
509
|
+
route_table_id = oci_core_route_table.private.id
|
|
510
|
+
security_list_ids = [oci_core_security_list.private_app.id]
|
|
511
|
+
prohibit_public_ip_on_vnic = true
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
# Private subnet (database tier)
|
|
515
|
+
resource "oci_core_subnet" "private_db" {
|
|
516
|
+
compartment_id = var.compartment_id
|
|
517
|
+
vcn_id = oci_core_vcn.production.id
|
|
518
|
+
cidr_block = "10.0.20.0/24"
|
|
519
|
+
display_name = "private-db-subnet"
|
|
520
|
+
dns_label = "db"
|
|
521
|
+
route_table_id = oci_core_route_table.private.id
|
|
522
|
+
security_list_ids = [oci_core_security_list.private_db.id]
|
|
523
|
+
prohibit_public_ip_on_vnic = true
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
# Route tables
|
|
527
|
+
resource "oci_core_route_table" "public" {
|
|
528
|
+
compartment_id = var.compartment_id
|
|
529
|
+
vcn_id = oci_core_vcn.production.id
|
|
530
|
+
display_name = "public-route-table"
|
|
531
|
+
|
|
532
|
+
route_rules {
|
|
533
|
+
network_entity_id = oci_core_internet_gateway.public.id
|
|
534
|
+
destination = "0.0.0.0/0"
|
|
535
|
+
destination_type = "CIDR_BLOCK"
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
resource "oci_core_route_table" "private" {
|
|
540
|
+
compartment_id = var.compartment_id
|
|
541
|
+
vcn_id = oci_core_vcn.production.id
|
|
542
|
+
display_name = "private-route-table"
|
|
543
|
+
|
|
544
|
+
route_rules {
|
|
545
|
+
network_entity_id = oci_core_nat_gateway.private.id
|
|
546
|
+
destination = "0.0.0.0/0"
|
|
547
|
+
destination_type = "CIDR_BLOCK"
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
route_rules {
|
|
551
|
+
network_entity_id = oci_core_service_gateway.oci_services.id
|
|
552
|
+
destination = data.oci_core_services.all_services.services[0].cidr_block
|
|
553
|
+
destination_type = "SERVICE_CIDR_BLOCK"
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
### Load Balancer
|
|
559
|
+
|
|
560
|
+
**Example: Public Load Balancer with Health Checks:**
|
|
561
|
+
```hcl
|
|
562
|
+
# load_balancer.tf
|
|
563
|
+
resource "oci_load_balancer_load_balancer" "public" {
|
|
564
|
+
compartment_id = var.compartment_id
|
|
565
|
+
display_name = "public-load-balancer"
|
|
566
|
+
shape = "flexible"
|
|
567
|
+
|
|
568
|
+
shape_details {
|
|
569
|
+
minimum_bandwidth_in_mbps = 10
|
|
570
|
+
maximum_bandwidth_in_mbps = 100
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
subnet_ids = [
|
|
574
|
+
oci_core_subnet.public.id
|
|
575
|
+
]
|
|
576
|
+
|
|
577
|
+
is_private = false
|
|
578
|
+
|
|
579
|
+
freeform_tags = {
|
|
580
|
+
Environment = var.environment
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
# Backend set
|
|
585
|
+
resource "oci_load_balancer_backend_set" "app" {
|
|
586
|
+
load_balancer_id = oci_load_balancer_load_balancer.public.id
|
|
587
|
+
name = "app-backend-set"
|
|
588
|
+
policy = "ROUND_ROBIN"
|
|
589
|
+
|
|
590
|
+
health_checker {
|
|
591
|
+
protocol = "HTTP"
|
|
592
|
+
port = 8080
|
|
593
|
+
url_path = "/health"
|
|
594
|
+
return_code = 200
|
|
595
|
+
interval_ms = 10000
|
|
596
|
+
timeout_in_millis = 3000
|
|
597
|
+
retries = 3
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
session_persistence_configuration {
|
|
601
|
+
cookie_name = "APP_SESSION"
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
# SSL certificate
|
|
606
|
+
resource "oci_load_balancer_certificate" "ssl_cert" {
|
|
607
|
+
load_balancer_id = oci_load_balancer_load_balancer.public.id
|
|
608
|
+
certificate_name = "ssl-certificate"
|
|
609
|
+
|
|
610
|
+
ca_certificate = file("${path.module}/certs/ca.crt")
|
|
611
|
+
private_key = file("${path.module}/certs/server.key")
|
|
612
|
+
public_certificate = file("${path.module}/certs/server.crt")
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
# HTTPS listener
|
|
616
|
+
resource "oci_load_balancer_listener" "https" {
|
|
617
|
+
load_balancer_id = oci_load_balancer_load_balancer.public.id
|
|
618
|
+
name = "https-listener"
|
|
619
|
+
default_backend_set_name = oci_load_balancer_backend_set.app.name
|
|
620
|
+
port = 443
|
|
621
|
+
protocol = "HTTP"
|
|
622
|
+
|
|
623
|
+
ssl_configuration {
|
|
624
|
+
certificate_name = oci_load_balancer_certificate.ssl_cert.certificate_name
|
|
625
|
+
verify_peer_certificate = false
|
|
626
|
+
protocols = ["TLSv1.2", "TLSv1.3"]
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
connection_configuration {
|
|
630
|
+
idle_timeout_in_seconds = 300
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
## Container and Kubernetes Services
|
|
636
|
+
|
|
637
|
+
### Container Engine for Kubernetes (OKE)
|
|
638
|
+
|
|
639
|
+
**Example: Production OKE Cluster:**
|
|
640
|
+
```hcl
|
|
641
|
+
# oke_cluster.tf
|
|
642
|
+
resource "oci_containerengine_cluster" "app_cluster" {
|
|
643
|
+
compartment_id = var.compartment_id
|
|
644
|
+
kubernetes_version = "v1.27.2"
|
|
645
|
+
name = "app-cluster-${var.environment}"
|
|
646
|
+
vcn_id = oci_core_vcn.production.id
|
|
647
|
+
|
|
648
|
+
# Cluster endpoint configuration
|
|
649
|
+
endpoint_config {
|
|
650
|
+
is_public_ip_enabled = false
|
|
651
|
+
subnet_id = oci_core_subnet.kubernetes_api.id
|
|
652
|
+
nsg_ids = [oci_core_network_security_group.k8s_api.id]
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
# Options
|
|
656
|
+
options {
|
|
657
|
+
service_lb_subnet_ids = [oci_core_subnet.public.id]
|
|
658
|
+
|
|
659
|
+
# Add-ons
|
|
660
|
+
add_ons {
|
|
661
|
+
is_kubernetes_dashboard_enabled = false
|
|
662
|
+
is_tiller_enabled = false
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
# Admission controllers
|
|
666
|
+
admission_controller_options {
|
|
667
|
+
is_pod_security_policy_enabled = true
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
# Kubernetes network config
|
|
671
|
+
kubernetes_network_config {
|
|
672
|
+
pods_cidr = "10.244.0.0/16"
|
|
673
|
+
services_cidr = "10.96.0.0/16"
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
# Persistent volume config
|
|
677
|
+
persistent_volume_config {
|
|
678
|
+
freeform_tags = {
|
|
679
|
+
Environment = var.environment
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
freeform_tags = {
|
|
685
|
+
Environment = var.environment
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
# Node pool
|
|
690
|
+
resource "oci_containerengine_node_pool" "app_node_pool" {
|
|
691
|
+
cluster_id = oci_containerengine_cluster.app_cluster.id
|
|
692
|
+
compartment_id = var.compartment_id
|
|
693
|
+
kubernetes_version = "v1.27.2"
|
|
694
|
+
name = "app-node-pool"
|
|
695
|
+
node_shape = "VM.Standard.E4.Flex"
|
|
696
|
+
|
|
697
|
+
node_shape_config {
|
|
698
|
+
ocpus = 2
|
|
699
|
+
memory_in_gbs = 16
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
# Multi-AD placement
|
|
703
|
+
node_config_details {
|
|
704
|
+
placement_configs {
|
|
705
|
+
availability_domain = data.oci_identity_availability_domain.ad1.name
|
|
706
|
+
subnet_id = oci_core_subnet.kubernetes_workers.id
|
|
707
|
+
|
|
708
|
+
fault_domains = [
|
|
709
|
+
"FAULT-DOMAIN-1",
|
|
710
|
+
"FAULT-DOMAIN-2",
|
|
711
|
+
"FAULT-DOMAIN-3"
|
|
712
|
+
]
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
size = 3
|
|
716
|
+
|
|
717
|
+
# Node pool options
|
|
718
|
+
is_pv_encryption_in_transit_enabled = true
|
|
719
|
+
|
|
720
|
+
# Freeform tags for nodes
|
|
721
|
+
freeform_tags = {
|
|
722
|
+
Environment = var.environment
|
|
723
|
+
NodePool = "app"
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
node_pool_pod_network_option_details {
|
|
727
|
+
cni_type = "FLANNEL_OVERLAY"
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
# Image
|
|
732
|
+
node_source_details {
|
|
733
|
+
image_id = data.oci_containerengine_node_pool_option.oke_node_pool_option.sources[0].image_id
|
|
734
|
+
source_type = "IMAGE"
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
# SSH access
|
|
738
|
+
ssh_public_key = file("~/.ssh/id_rsa.pub")
|
|
739
|
+
|
|
740
|
+
# Initial node labels
|
|
741
|
+
initial_node_labels {
|
|
742
|
+
key = "environment"
|
|
743
|
+
value = var.environment
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
## Serverless Services
|
|
749
|
+
|
|
750
|
+
### Functions
|
|
751
|
+
|
|
752
|
+
**Example: OCI Function:**
|
|
753
|
+
```yaml
|
|
754
|
+
# func.yaml
|
|
755
|
+
schema_version: 20180708
|
|
756
|
+
name: process-image
|
|
757
|
+
version: 0.0.1
|
|
758
|
+
runtime: python
|
|
759
|
+
entrypoint: /python/bin/fdk /function/func.py handler
|
|
760
|
+
memory: 256
|
|
761
|
+
timeout: 120
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
```python
|
|
765
|
+
# func.py
|
|
766
|
+
import io
|
|
767
|
+
import json
|
|
768
|
+
import oci
|
|
769
|
+
from fdk import response
|
|
770
|
+
|
|
771
|
+
def handler(ctx, data: io.BytesIO = None):
|
|
772
|
+
signer = oci.auth.signers.get_resource_principals_signer()
|
|
773
|
+
object_storage = oci.object_storage.ObjectStorageClient(config={}, signer=signer)
|
|
774
|
+
|
|
775
|
+
try:
|
|
776
|
+
body = json.loads(data.getvalue())
|
|
777
|
+
bucket_name = body.get("bucketName")
|
|
778
|
+
object_name = body.get("objectName")
|
|
779
|
+
|
|
780
|
+
# Process object
|
|
781
|
+
namespace = object_storage.get_namespace().data
|
|
782
|
+
obj = object_storage.get_object(namespace, bucket_name, object_name)
|
|
783
|
+
|
|
784
|
+
# Your processing logic here
|
|
785
|
+
result = process_data(obj.data.content)
|
|
786
|
+
|
|
787
|
+
return response.Response(
|
|
788
|
+
ctx,
|
|
789
|
+
response_data=json.dumps({"status": "success", "result": result}),
|
|
790
|
+
headers={"Content-Type": "application/json"}
|
|
791
|
+
)
|
|
792
|
+
except Exception as e:
|
|
793
|
+
return response.Response(
|
|
794
|
+
ctx,
|
|
795
|
+
response_data=json.dumps({"status": "error", "message": str(e)}),
|
|
796
|
+
headers={"Content-Type": "application/json"},
|
|
797
|
+
status_code=500
|
|
798
|
+
)
|
|
799
|
+
|
|
800
|
+
def process_data(content):
|
|
801
|
+
# Your data processing logic
|
|
802
|
+
return {"processed": True}
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
**Terraform Configuration:**
|
|
806
|
+
```hcl
|
|
807
|
+
# functions.tf
|
|
808
|
+
resource "oci_functions_application" "app" {
|
|
809
|
+
compartment_id = var.compartment_id
|
|
810
|
+
display_name = "image-processing-app"
|
|
811
|
+
subnet_ids = [oci_core_subnet.private_app.id]
|
|
812
|
+
|
|
813
|
+
config = {
|
|
814
|
+
STORAGE_NAMESPACE = data.oci_objectstorage_namespace.ns.namespace
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
freeform_tags = {
|
|
818
|
+
Environment = var.environment
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
resource "oci_functions_function" "process_image" {
|
|
823
|
+
application_id = oci_functions_application.app.id
|
|
824
|
+
display_name = "process-image"
|
|
825
|
+
image = "${var.ocir_region}.ocir.io/${data.oci_objectstorage_namespace.ns.namespace}/process-image:0.0.1"
|
|
826
|
+
memory_in_mbs = 256
|
|
827
|
+
timeout_in_seconds = 120
|
|
828
|
+
|
|
829
|
+
config = {
|
|
830
|
+
BUCKET_NAME = oci_objectstorage_bucket.images.name
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
## Identity and Security
|
|
836
|
+
|
|
837
|
+
### Identity and Access Management (IAM)
|
|
838
|
+
|
|
839
|
+
**Example: Compartment Structure and Policies:**
|
|
840
|
+
```hcl
|
|
841
|
+
# iam.tf
|
|
842
|
+
# Root compartment structure
|
|
843
|
+
resource "oci_identity_compartment" "production" {
|
|
844
|
+
compartment_id = var.tenancy_ocid
|
|
845
|
+
description = "Production environment"
|
|
846
|
+
name = "production"
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
resource "oci_identity_compartment" "network" {
|
|
850
|
+
compartment_id = oci_identity_compartment.production.id
|
|
851
|
+
description = "Network resources"
|
|
852
|
+
name = "network"
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
resource "oci_identity_compartment" "compute" {
|
|
856
|
+
compartment_id = oci_identity_compartment.production.id
|
|
857
|
+
description = "Compute resources"
|
|
858
|
+
name = "compute"
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
# Dynamic group for instance principals
|
|
862
|
+
resource "oci_identity_dynamic_group" "app_instances" {
|
|
863
|
+
compartment_id = var.tenancy_ocid
|
|
864
|
+
description = "Application instances"
|
|
865
|
+
name = "app-instances"
|
|
866
|
+
matching_rule = "ALL {instance.compartment.id = '${oci_identity_compartment.compute.id}'}"
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
# Policy for instance principals
|
|
870
|
+
resource "oci_identity_policy" "app_instances_policy" {
|
|
871
|
+
compartment_id = oci_identity_compartment.production.id
|
|
872
|
+
description = "Policy for application instances"
|
|
873
|
+
name = "app-instances-policy"
|
|
874
|
+
|
|
875
|
+
statements = [
|
|
876
|
+
"Allow dynamic-group app-instances to manage objects in compartment production",
|
|
877
|
+
"Allow dynamic-group app-instances to read secret-bundles in compartment production",
|
|
878
|
+
"Allow dynamic-group app-instances to use metrics in compartment production"
|
|
879
|
+
]
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
# User group
|
|
883
|
+
resource "oci_identity_group" "developers" {
|
|
884
|
+
compartment_id = var.tenancy_ocid
|
|
885
|
+
description = "Developer group"
|
|
886
|
+
name = "developers"
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
# Policy for developers
|
|
890
|
+
resource "oci_identity_policy" "developers_policy" {
|
|
891
|
+
compartment_id = oci_identity_compartment.production.id
|
|
892
|
+
description = "Developer permissions"
|
|
893
|
+
name = "developers-policy"
|
|
894
|
+
|
|
895
|
+
statements = [
|
|
896
|
+
"Allow group developers to manage all-resources in compartment production where request.permission != 'COMPARTMENT_DELETE'",
|
|
897
|
+
"Allow group developers to read audit-events in compartment production",
|
|
898
|
+
"Allow group developers to use cloud-shell in tenancy"
|
|
899
|
+
]
|
|
900
|
+
}
|
|
901
|
+
```
|
|
902
|
+
|
|
903
|
+
### Vault and Key Management
|
|
904
|
+
|
|
905
|
+
**Example: Vault with Encryption Keys:**
|
|
906
|
+
```hcl
|
|
907
|
+
# vault.tf
|
|
908
|
+
resource "oci_kms_vault" "production_vault" {
|
|
909
|
+
compartment_id = var.compartment_id
|
|
910
|
+
display_name = "production-vault"
|
|
911
|
+
vault_type = "DEFAULT"
|
|
912
|
+
|
|
913
|
+
freeform_tags = {
|
|
914
|
+
Environment = "production"
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
# Master encryption key
|
|
919
|
+
resource "oci_kms_key" "database_encryption_key" {
|
|
920
|
+
compartment_id = var.compartment_id
|
|
921
|
+
display_name = "database-encryption-key"
|
|
922
|
+
|
|
923
|
+
key_shape {
|
|
924
|
+
algorithm = "AES"
|
|
925
|
+
length = 32
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
management_endpoint = oci_kms_vault.production_vault.management_endpoint
|
|
929
|
+
|
|
930
|
+
protection_mode = "HSM" # Hardware Security Module
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
# Secret for database password
|
|
934
|
+
resource "oci_vault_secret" "db_password" {
|
|
935
|
+
compartment_id = var.compartment_id
|
|
936
|
+
secret_name = "database-admin-password"
|
|
937
|
+
vault_id = oci_kms_vault.production_vault.id
|
|
938
|
+
key_id = oci_kms_key.database_encryption_key.id
|
|
939
|
+
|
|
940
|
+
secret_content {
|
|
941
|
+
content_type = "BASE64"
|
|
942
|
+
content = base64encode(var.db_admin_password)
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
```
|
|
946
|
+
|
|
947
|
+
## Monitoring and Management
|
|
948
|
+
|
|
949
|
+
### Monitoring and Alarms
|
|
950
|
+
|
|
951
|
+
**Example: Monitoring and Alerting:**
|
|
952
|
+
```hcl
|
|
953
|
+
# monitoring.tf
|
|
954
|
+
# Alarm for high CPU
|
|
955
|
+
resource "oci_monitoring_alarm" "high_cpu" {
|
|
956
|
+
compartment_id = var.compartment_id
|
|
957
|
+
display_name = "high-cpu-alarm"
|
|
958
|
+
is_enabled = true
|
|
959
|
+
metric_compartment_id = var.compartment_id
|
|
960
|
+
namespace = "oci_computeagent"
|
|
961
|
+
query = "CpuUtilization[1m].mean() > 80"
|
|
962
|
+
severity = "CRITICAL"
|
|
963
|
+
|
|
964
|
+
destinations = [oci_ons_notification_topic.alerts.id]
|
|
965
|
+
|
|
966
|
+
repeat_notification_duration = "PT2H"
|
|
967
|
+
|
|
968
|
+
body = "CPU utilization is above 80% for instances in production"
|
|
969
|
+
|
|
970
|
+
freeform_tags = {
|
|
971
|
+
Environment = "production"
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
# Notification topic
|
|
976
|
+
resource "oci_ons_notification_topic" "alerts" {
|
|
977
|
+
compartment_id = var.compartment_id
|
|
978
|
+
name = "production-alerts"
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
# Email subscription
|
|
982
|
+
resource "oci_ons_subscription" "email_alerts" {
|
|
983
|
+
compartment_id = var.compartment_id
|
|
984
|
+
endpoint = "ops-team@example.com"
|
|
985
|
+
protocol = "EMAIL"
|
|
986
|
+
topic_id = oci_ons_notification_topic.alerts.id
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
# Slack webhook subscription
|
|
990
|
+
resource "oci_ons_subscription" "slack_alerts" {
|
|
991
|
+
compartment_id = var.compartment_id
|
|
992
|
+
endpoint = var.slack_webhook_url
|
|
993
|
+
protocol = "HTTPS_CUSTOM"
|
|
994
|
+
topic_id = oci_ons_notification_topic.alerts.id
|
|
995
|
+
}
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
### Logging
|
|
999
|
+
|
|
1000
|
+
**Example: Log Groups and Logs:**
|
|
1001
|
+
```hcl
|
|
1002
|
+
# logging.tf
|
|
1003
|
+
resource "oci_logging_log_group" "application_logs" {
|
|
1004
|
+
compartment_id = var.compartment_id
|
|
1005
|
+
display_name = "application-log-group"
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
# VCN flow logs
|
|
1009
|
+
resource "oci_logging_log" "vcn_flow_logs" {
|
|
1010
|
+
display_name = "vcn-flow-logs"
|
|
1011
|
+
log_group_id = oci_logging_log_group.application_logs.id
|
|
1012
|
+
log_type = "SERVICE"
|
|
1013
|
+
|
|
1014
|
+
configuration {
|
|
1015
|
+
source {
|
|
1016
|
+
category = "all"
|
|
1017
|
+
resource = oci_core_vcn.production.id
|
|
1018
|
+
service = "flowlogs"
|
|
1019
|
+
source_type = "OCISERVICE"
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
compartment_id = var.compartment_id
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
is_enabled = true
|
|
1026
|
+
retention_duration = 30
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
# Load balancer access logs
|
|
1030
|
+
resource "oci_logging_log" "lb_access_logs" {
|
|
1031
|
+
display_name = "lb-access-logs"
|
|
1032
|
+
log_group_id = oci_logging_log_group.application_logs.id
|
|
1033
|
+
log_type = "SERVICE"
|
|
1034
|
+
|
|
1035
|
+
configuration {
|
|
1036
|
+
source {
|
|
1037
|
+
category = "access"
|
|
1038
|
+
resource = oci_load_balancer_load_balancer.public.id
|
|
1039
|
+
service = "loadbalancer"
|
|
1040
|
+
source_type = "OCISERVICE"
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
compartment_id = var.compartment_id
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
is_enabled = true
|
|
1047
|
+
retention_duration = 30
|
|
1048
|
+
}
|
|
1049
|
+
```
|
|
1050
|
+
|
|
1051
|
+
## Common Patterns
|
|
1052
|
+
|
|
1053
|
+
### Pattern 1: Multi-Tier Web Application
|
|
1054
|
+
|
|
1055
|
+
```
|
|
1056
|
+
┌─────────────────────────────────────────────────┐
|
|
1057
|
+
│ Internet Gateway │
|
|
1058
|
+
└────────────────┬────────────────────────────────┘
|
|
1059
|
+
│
|
|
1060
|
+
┌────────────────▼────────────────────────────────┐
|
|
1061
|
+
│ Public Subnet (Load Balancer) │
|
|
1062
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
1063
|
+
│ │ LB-1 │ │ LB-2 │ │ Bastion │ │
|
|
1064
|
+
│ └──────────┘ └──────────┘ └──────────┘ │
|
|
1065
|
+
└────────────────┬────────────────────────────────┘
|
|
1066
|
+
│
|
|
1067
|
+
┌────────────────▼────────────────────────────────┐
|
|
1068
|
+
│ Private Subnet (Application Tier) │
|
|
1069
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
1070
|
+
│ │ App-1 │ │ App-2 │ │ App-3 │ │
|
|
1071
|
+
│ └──────────┘ └──────────┘ └──────────┘ │
|
|
1072
|
+
└────────────────┬────────────────────────────────┘
|
|
1073
|
+
│
|
|
1074
|
+
┌────────────────▼────────────────────────────────┐
|
|
1075
|
+
│ Private Subnet (Database Tier) │
|
|
1076
|
+
│ ┌───────────────────┐ │
|
|
1077
|
+
│ │ Autonomous DB │ │
|
|
1078
|
+
│ │ (Multi-AD) │ │
|
|
1079
|
+
│ └───────────────────┘ │
|
|
1080
|
+
└─────────────────────────────────────────────────┘
|
|
1081
|
+
```
|
|
1082
|
+
|
|
1083
|
+
### Pattern 2: Disaster Recovery with Cross-Region Replication
|
|
1084
|
+
|
|
1085
|
+
```hcl
|
|
1086
|
+
# Primary region (Phoenix)
|
|
1087
|
+
provider "oci" {
|
|
1088
|
+
alias = "phoenix"
|
|
1089
|
+
region = "us-phoenix-1"
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
# DR region (Ashburn)
|
|
1093
|
+
provider "oci" {
|
|
1094
|
+
alias = "ashburn"
|
|
1095
|
+
region = "us-ashburn-1"
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
# Primary Autonomous Database
|
|
1099
|
+
resource "oci_database_autonomous_database" "primary" {
|
|
1100
|
+
provider = oci.phoenix
|
|
1101
|
+
# ... configuration
|
|
1102
|
+
|
|
1103
|
+
is_data_guard_enabled = true
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
# Object Storage replication
|
|
1107
|
+
resource "oci_objectstorage_replication_policy" "cross_region" {
|
|
1108
|
+
bucket = oci_objectstorage_bucket.primary.name
|
|
1109
|
+
namespace = data.oci_objectstorage_namespace.ns.namespace
|
|
1110
|
+
name = "cross-region-replication"
|
|
1111
|
+
destination_bucket_name = oci_objectstorage_bucket.dr.name
|
|
1112
|
+
destination_region_name = "us-ashburn-1"
|
|
1113
|
+
}
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
## Best Practices
|
|
1117
|
+
|
|
1118
|
+
### Compartment Design
|
|
1119
|
+
|
|
1120
|
+
1. **Hierarchical Structure:**
|
|
1121
|
+
- Root: Tenancy
|
|
1122
|
+
- Level 1: Environment (prod, staging, dev)
|
|
1123
|
+
- Level 2: Workload type (network, compute, database)
|
|
1124
|
+
- Level 3: Application or service
|
|
1125
|
+
|
|
1126
|
+
2. **Least Privilege:**
|
|
1127
|
+
- Use dynamic groups for instance principals
|
|
1128
|
+
- Separate compartments for different security zones
|
|
1129
|
+
- Regular policy reviews and audits
|
|
1130
|
+
|
|
1131
|
+
### High Availability
|
|
1132
|
+
|
|
1133
|
+
1. **Multi-AD Deployment:**
|
|
1134
|
+
- Distribute resources across all availability domains
|
|
1135
|
+
- Use fault domains within ADs
|
|
1136
|
+
- Regional subnets for automatic failover
|
|
1137
|
+
|
|
1138
|
+
2. **Backup and Recovery:**
|
|
1139
|
+
- Enable automatic backups for databases
|
|
1140
|
+
- Use volume groups for consistent snapshots
|
|
1141
|
+
- Test recovery procedures regularly
|
|
1142
|
+
|
|
1143
|
+
### Cost Optimization
|
|
1144
|
+
|
|
1145
|
+
1. **Right-Sizing:**
|
|
1146
|
+
- Use flexible shapes for variable workloads
|
|
1147
|
+
- Leverage auto-scaling
|
|
1148
|
+
- Monitor resource utilization
|
|
1149
|
+
|
|
1150
|
+
2. **Reserved Capacity:**
|
|
1151
|
+
- Purchase capacity reservations for steady workloads
|
|
1152
|
+
- Use burstable instances for development
|
|
1153
|
+
|
|
1154
|
+
3. **Storage Tiering:**
|
|
1155
|
+
- Move infrequently accessed data to lower tiers
|
|
1156
|
+
- Enable auto-tiering for Object Storage
|
|
1157
|
+
- Archive old backups
|
|
1158
|
+
|
|
1159
|
+
### Security
|
|
1160
|
+
|
|
1161
|
+
1. **Network Security:**
|
|
1162
|
+
- Use Network Security Groups (NSGs) instead of Security Lists
|
|
1163
|
+
- Implement micro-segmentation
|
|
1164
|
+
- Enable VCN flow logs
|
|
1165
|
+
|
|
1166
|
+
2. **Encryption:**
|
|
1167
|
+
- Enable encryption at rest for all data
|
|
1168
|
+
- Use customer-managed keys in Vault
|
|
1169
|
+
- Encrypt data in transit with TLS
|
|
1170
|
+
|
|
1171
|
+
3. **Identity Management:**
|
|
1172
|
+
- Enable MFA for all users
|
|
1173
|
+
- Use federation for SSO
|
|
1174
|
+
- Regular access reviews
|
|
1175
|
+
|
|
1176
|
+
## Anti-Patterns
|
|
1177
|
+
|
|
1178
|
+
❌ **Single AD deployment** - No fault tolerance
|
|
1179
|
+
❌ **Overprovisioning** - Wasting capacity and cost
|
|
1180
|
+
❌ **Using Security Lists only** - Less granular than NSGs
|
|
1181
|
+
❌ **No tagging strategy** - Can't track costs or resources
|
|
1182
|
+
❌ **Manual infrastructure** - Use Resource Manager (Terraform)
|
|
1183
|
+
❌ **Ignoring backup policies** - Risk of data loss
|
|
1184
|
+
❌ **Exposing databases publicly** - Security risk
|
|
1185
|
+
❌ **No monitoring** - Can't detect issues proactively
|
|
1186
|
+
❌ **Weak IAM policies** - Too permissive access
|
|
1187
|
+
❌ **Ignoring service limits** - Plan for growth
|
|
1188
|
+
|
|
1189
|
+
## Related Resources
|
|
1190
|
+
|
|
1191
|
+
- [OCI Documentation](https://docs.oracle.com/en-us/iaas/Content/home.htm)
|
|
1192
|
+
- [OCI Terraform Provider](https://registry.terraform.io/providers/oracle/oci/latest/docs)
|
|
1193
|
+
- [OCI Architecture Center](https://docs.oracle.com/solutions/)
|
|
1194
|
+
- [OCI CLI Reference](https://docs.oracle.com/en-us/iaas/tools/oci-cli/latest/oci_cli_docs/)
|
|
1195
|
+
|
|
1196
|
+
---
|
|
1197
|
+
|
|
1198
|
+
**Note:** This guide covers Oracle Cloud Infrastructure patterns and best practices. For multi-cloud strategies including OCI, see [multi-cloud-strategies.md](multi-cloud-strategies.md).
|