@friggframework/devtools 2.0.0-next.61 → 2.0.0-next.62
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/package.json +14 -7
- package/.eslintrc.json +0 -3
- package/CHANGELOG.md +0 -132
- package/infrastructure/ARCHITECTURE.md +0 -487
- package/infrastructure/CLAUDE.md +0 -481
- package/infrastructure/HEALTH.md +0 -468
- package/infrastructure/README.md +0 -522
- package/infrastructure/__tests__/fixtures/mock-aws-resources.js +0 -391
- package/infrastructure/__tests__/helpers/test-utils.js +0 -277
- package/infrastructure/__tests__/postgres-config.test.js +0 -914
- package/infrastructure/__tests__/template-generation.test.js +0 -687
- package/infrastructure/create-frigg-infrastructure.js +0 -147
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +0 -630
- package/infrastructure/docs/PRE-DEPLOYMENT-HEALTH-CHECK-SPEC.md +0 -1317
- package/infrastructure/docs/WEBSOCKET-CONFIGURATION.md +0 -105
- package/infrastructure/docs/deployment-instructions.md +0 -268
- package/infrastructure/docs/generate-iam-command.md +0 -278
- package/infrastructure/docs/iam-policy-templates.md +0 -193
- package/infrastructure/domains/database/aurora-builder.js +0 -809
- package/infrastructure/domains/database/aurora-builder.test.js +0 -950
- package/infrastructure/domains/database/aurora-discovery.js +0 -87
- package/infrastructure/domains/database/aurora-discovery.test.js +0 -188
- package/infrastructure/domains/database/aurora-resolver.js +0 -210
- package/infrastructure/domains/database/aurora-resolver.test.js +0 -347
- package/infrastructure/domains/database/migration-builder.js +0 -701
- package/infrastructure/domains/database/migration-builder.test.js +0 -321
- package/infrastructure/domains/database/migration-resolver.js +0 -163
- package/infrastructure/domains/database/migration-resolver.test.js +0 -337
- package/infrastructure/domains/health/application/ports/IPropertyReconciler.js +0 -164
- package/infrastructure/domains/health/application/ports/IResourceDetector.js +0 -129
- package/infrastructure/domains/health/application/ports/IResourceImporter.js +0 -142
- package/infrastructure/domains/health/application/ports/IStackRepository.js +0 -131
- package/infrastructure/domains/health/application/ports/index.js +0 -26
- package/infrastructure/domains/health/application/use-cases/__tests__/execute-resource-import-use-case.test.js +0 -679
- package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +0 -167
- package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +0 -1130
- package/infrastructure/domains/health/application/use-cases/execute-resource-import-use-case.js +0 -221
- package/infrastructure/domains/health/application/use-cases/reconcile-properties-use-case.js +0 -152
- package/infrastructure/domains/health/application/use-cases/reconcile-properties-use-case.test.js +0 -343
- package/infrastructure/domains/health/application/use-cases/repair-via-import-use-case.js +0 -535
- package/infrastructure/domains/health/application/use-cases/repair-via-import-use-case.test.js +0 -376
- package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.js +0 -213
- package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +0 -441
- package/infrastructure/domains/health/docs/ACME-DEV-DRIFT-ANALYSIS.md +0 -267
- package/infrastructure/domains/health/docs/BUILD-VS-DEPLOYED-TEMPLATE-ANALYSIS.md +0 -324
- package/infrastructure/domains/health/docs/ORPHAN-DETECTION-ANALYSIS.md +0 -386
- package/infrastructure/domains/health/docs/SPEC-CLEANUP-COMMAND.md +0 -1419
- package/infrastructure/domains/health/docs/TDD-IMPLEMENTATION-SUMMARY.md +0 -391
- package/infrastructure/domains/health/docs/TEMPLATE-COMPARISON-IMPLEMENTATION.md +0 -551
- package/infrastructure/domains/health/domain/entities/issue.js +0 -299
- package/infrastructure/domains/health/domain/entities/issue.test.js +0 -528
- package/infrastructure/domains/health/domain/entities/property-mismatch.js +0 -108
- package/infrastructure/domains/health/domain/entities/property-mismatch.test.js +0 -275
- package/infrastructure/domains/health/domain/entities/resource.js +0 -159
- package/infrastructure/domains/health/domain/entities/resource.test.js +0 -432
- package/infrastructure/domains/health/domain/entities/stack-health-report.js +0 -306
- package/infrastructure/domains/health/domain/entities/stack-health-report.test.js +0 -601
- package/infrastructure/domains/health/domain/services/__tests__/health-score-percentage-based.test.js +0 -380
- package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +0 -971
- package/infrastructure/domains/health/domain/services/__tests__/import-template-generator.test.js +0 -1150
- package/infrastructure/domains/health/domain/services/__tests__/logical-id-mapper.test.js +0 -672
- package/infrastructure/domains/health/domain/services/__tests__/template-parser.test.js +0 -496
- package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +0 -419
- package/infrastructure/domains/health/domain/services/health-score-calculator.js +0 -248
- package/infrastructure/domains/health/domain/services/health-score-calculator.test.js +0 -504
- package/infrastructure/domains/health/domain/services/import-progress-monitor.js +0 -195
- package/infrastructure/domains/health/domain/services/import-template-generator.js +0 -435
- package/infrastructure/domains/health/domain/services/logical-id-mapper.js +0 -345
- package/infrastructure/domains/health/domain/services/mismatch-analyzer.js +0 -234
- package/infrastructure/domains/health/domain/services/mismatch-analyzer.test.js +0 -431
- package/infrastructure/domains/health/domain/services/property-mutability-config.js +0 -382
- package/infrastructure/domains/health/domain/services/template-parser.js +0 -245
- package/infrastructure/domains/health/domain/services/update-progress-monitor.js +0 -192
- package/infrastructure/domains/health/domain/value-objects/health-score.js +0 -138
- package/infrastructure/domains/health/domain/value-objects/health-score.test.js +0 -267
- package/infrastructure/domains/health/domain/value-objects/property-mutability.js +0 -161
- package/infrastructure/domains/health/domain/value-objects/property-mutability.test.js +0 -198
- package/infrastructure/domains/health/domain/value-objects/resource-state.js +0 -167
- package/infrastructure/domains/health/domain/value-objects/resource-state.test.js +0 -196
- package/infrastructure/domains/health/domain/value-objects/stack-identifier.js +0 -192
- package/infrastructure/domains/health/domain/value-objects/stack-identifier.test.js +0 -262
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-cfn-tagged.test.js +0 -312
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-multi-stack.test.js +0 -367
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +0 -432
- package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.js +0 -784
- package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +0 -1133
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.js +0 -565
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +0 -554
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-importer.js +0 -318
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-importer.test.js +0 -398
- package/infrastructure/domains/health/infrastructure/adapters/aws-stack-repository.js +0 -777
- package/infrastructure/domains/health/infrastructure/adapters/aws-stack-repository.test.js +0 -580
- package/infrastructure/domains/integration/integration-builder.js +0 -404
- package/infrastructure/domains/integration/integration-builder.test.js +0 -690
- package/infrastructure/domains/integration/integration-resolver.js +0 -170
- package/infrastructure/domains/integration/integration-resolver.test.js +0 -369
- package/infrastructure/domains/integration/websocket-builder.js +0 -69
- package/infrastructure/domains/integration/websocket-builder.test.js +0 -195
- package/infrastructure/domains/networking/vpc-builder.js +0 -2051
- package/infrastructure/domains/networking/vpc-builder.test.js +0 -1960
- package/infrastructure/domains/networking/vpc-discovery.js +0 -177
- package/infrastructure/domains/networking/vpc-discovery.test.js +0 -350
- package/infrastructure/domains/networking/vpc-resolver.js +0 -505
- package/infrastructure/domains/networking/vpc-resolver.test.js +0 -801
- package/infrastructure/domains/parameters/ssm-builder.js +0 -79
- package/infrastructure/domains/parameters/ssm-builder.test.js +0 -189
- package/infrastructure/domains/parameters/ssm-discovery.js +0 -84
- package/infrastructure/domains/parameters/ssm-discovery.test.js +0 -210
- package/infrastructure/domains/security/iam-generator.js +0 -816
- package/infrastructure/domains/security/iam-generator.test.js +0 -204
- package/infrastructure/domains/security/kms-builder.js +0 -415
- package/infrastructure/domains/security/kms-builder.test.js +0 -392
- package/infrastructure/domains/security/kms-discovery.js +0 -80
- package/infrastructure/domains/security/kms-discovery.test.js +0 -177
- package/infrastructure/domains/security/kms-resolver.js +0 -96
- package/infrastructure/domains/security/kms-resolver.test.js +0 -216
- package/infrastructure/domains/security/templates/frigg-deployment-iam-stack.yaml +0 -401
- package/infrastructure/domains/security/templates/iam-policy-basic.json +0 -218
- package/infrastructure/domains/security/templates/iam-policy-full.json +0 -288
- package/infrastructure/domains/shared/base-builder.js +0 -112
- package/infrastructure/domains/shared/base-resolver.js +0 -186
- package/infrastructure/domains/shared/base-resolver.test.js +0 -305
- package/infrastructure/domains/shared/builder-orchestrator.js +0 -212
- package/infrastructure/domains/shared/builder-orchestrator.test.js +0 -213
- package/infrastructure/domains/shared/cloudformation-discovery-v2.js +0 -334
- package/infrastructure/domains/shared/cloudformation-discovery.js +0 -672
- package/infrastructure/domains/shared/cloudformation-discovery.test.js +0 -985
- package/infrastructure/domains/shared/environment-builder.js +0 -119
- package/infrastructure/domains/shared/environment-builder.test.js +0 -247
- package/infrastructure/domains/shared/providers/aws-provider-adapter.js +0 -579
- package/infrastructure/domains/shared/providers/aws-provider-adapter.test.js +0 -416
- package/infrastructure/domains/shared/providers/azure-provider-adapter.stub.js +0 -93
- package/infrastructure/domains/shared/providers/cloud-provider-adapter.js +0 -136
- package/infrastructure/domains/shared/providers/gcp-provider-adapter.stub.js +0 -82
- package/infrastructure/domains/shared/providers/provider-factory.js +0 -108
- package/infrastructure/domains/shared/providers/provider-factory.test.js +0 -170
- package/infrastructure/domains/shared/resource-discovery.enhanced.test.js +0 -306
- package/infrastructure/domains/shared/resource-discovery.js +0 -233
- package/infrastructure/domains/shared/resource-discovery.test.js +0 -588
- package/infrastructure/domains/shared/types/app-definition.js +0 -205
- package/infrastructure/domains/shared/types/discovery-result.js +0 -106
- package/infrastructure/domains/shared/types/discovery-result.test.js +0 -258
- package/infrastructure/domains/shared/types/index.js +0 -46
- package/infrastructure/domains/shared/types/resource-ownership.js +0 -108
- package/infrastructure/domains/shared/types/resource-ownership.test.js +0 -101
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +0 -394
- package/infrastructure/domains/shared/utilities/base-definition-factory.js.bak +0 -338
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +0 -291
- package/infrastructure/domains/shared/utilities/handler-path-resolver.js +0 -134
- package/infrastructure/domains/shared/utilities/handler-path-resolver.test.js +0 -268
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +0 -159
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +0 -444
- package/infrastructure/domains/shared/validation/env-validator.js +0 -78
- package/infrastructure/domains/shared/validation/env-validator.test.js +0 -173
- package/infrastructure/domains/shared/validation/plugin-validator.js +0 -187
- package/infrastructure/domains/shared/validation/plugin-validator.test.js +0 -323
- package/infrastructure/esbuild.config.js +0 -53
- package/infrastructure/index.js +0 -4
- package/infrastructure/infrastructure-composer.js +0 -117
- package/infrastructure/infrastructure-composer.test.js +0 -1895
- package/infrastructure/integration.test.js +0 -383
- package/infrastructure/scripts/build-prisma-layer.js +0 -701
- package/infrastructure/scripts/build-prisma-layer.test.js +0 -170
- package/infrastructure/scripts/build-time-discovery.js +0 -238
- package/infrastructure/scripts/build-time-discovery.test.js +0 -379
- package/infrastructure/scripts/run-discovery.js +0 -110
- package/infrastructure/scripts/verify-prisma-layer.js +0 -72
- package/layers/prisma/.build-complete +0 -3
- package/layers/prisma/nodejs/package.json +0 -8
- package/management-ui/.eslintrc.js +0 -22
- package/management-ui/components.json +0 -21
- package/management-ui/docs/phase2-integration-guide.md +0 -320
- package/management-ui/index.html +0 -13
- package/management-ui/package.json +0 -76
- package/management-ui/packages/devtools/frigg-cli/ui-command/index.js +0 -302
- package/management-ui/postcss.config.js +0 -6
- package/management-ui/server/api/backend.js +0 -256
- package/management-ui/server/api/cli.js +0 -315
- package/management-ui/server/api/codegen.js +0 -663
- package/management-ui/server/api/connections.js +0 -857
- package/management-ui/server/api/discovery.js +0 -185
- package/management-ui/server/api/environment/index.js +0 -1
- package/management-ui/server/api/environment/router.js +0 -378
- package/management-ui/server/api/environment.js +0 -328
- package/management-ui/server/api/integrations.js +0 -876
- package/management-ui/server/api/logs.js +0 -248
- package/management-ui/server/api/monitoring.js +0 -282
- package/management-ui/server/api/open-ide.js +0 -31
- package/management-ui/server/api/project.js +0 -1029
- package/management-ui/server/api/users/sessions.js +0 -371
- package/management-ui/server/api/users/simulation.js +0 -254
- package/management-ui/server/api/users.js +0 -362
- package/management-ui/server/api-contract.md +0 -275
- package/management-ui/server/index.js +0 -873
- package/management-ui/server/middleware/errorHandler.js +0 -93
- package/management-ui/server/middleware/security.js +0 -32
- package/management-ui/server/processManager.js +0 -296
- package/management-ui/server/server.js +0 -346
- package/management-ui/server/services/aws-monitor.js +0 -413
- package/management-ui/server/services/npm-registry.js +0 -347
- package/management-ui/server/services/template-engine.js +0 -538
- package/management-ui/server/utils/cliIntegration.js +0 -220
- package/management-ui/server/utils/environment/auditLogger.js +0 -471
- package/management-ui/server/utils/environment/awsParameterStore.js +0 -275
- package/management-ui/server/utils/environment/encryption.js +0 -278
- package/management-ui/server/utils/environment/envFileManager.js +0 -286
- package/management-ui/server/utils/import-commonjs.js +0 -28
- package/management-ui/server/utils/response.js +0 -83
- package/management-ui/server/websocket/handler.js +0 -325
- package/management-ui/src/App.jsx +0 -25
- package/management-ui/src/assets/FriggLogo.svg +0 -1
- package/management-ui/src/components/AppRouter.jsx +0 -65
- package/management-ui/src/components/Button.jsx +0 -70
- package/management-ui/src/components/Card.jsx +0 -97
- package/management-ui/src/components/EnvironmentCompare.jsx +0 -400
- package/management-ui/src/components/EnvironmentEditor.jsx +0 -372
- package/management-ui/src/components/EnvironmentImportExport.jsx +0 -469
- package/management-ui/src/components/EnvironmentSchema.jsx +0 -491
- package/management-ui/src/components/EnvironmentSecurity.jsx +0 -463
- package/management-ui/src/components/ErrorBoundary.jsx +0 -73
- package/management-ui/src/components/IntegrationCard.jsx +0 -481
- package/management-ui/src/components/IntegrationCardEnhanced.jsx +0 -770
- package/management-ui/src/components/IntegrationExplorer.jsx +0 -379
- package/management-ui/src/components/IntegrationStatus.jsx +0 -336
- package/management-ui/src/components/Layout.jsx +0 -716
- package/management-ui/src/components/LoadingSpinner.jsx +0 -113
- package/management-ui/src/components/RepositoryPicker.jsx +0 -248
- package/management-ui/src/components/SessionMonitor.jsx +0 -350
- package/management-ui/src/components/StatusBadge.jsx +0 -208
- package/management-ui/src/components/UserContextSwitcher.jsx +0 -212
- package/management-ui/src/components/UserSimulation.jsx +0 -327
- package/management-ui/src/components/Welcome.jsx +0 -434
- package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +0 -637
- package/management-ui/src/components/codegen/APIModuleSelector.jsx +0 -227
- package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +0 -247
- package/management-ui/src/components/codegen/CodePreviewEditor.jsx +0 -316
- package/management-ui/src/components/codegen/DynamicModuleForm.jsx +0 -271
- package/management-ui/src/components/codegen/FormBuilder.jsx +0 -737
- package/management-ui/src/components/codegen/IntegrationGenerator.jsx +0 -855
- package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +0 -797
- package/management-ui/src/components/codegen/SchemaBuilder.jsx +0 -303
- package/management-ui/src/components/codegen/TemplateSelector.jsx +0 -586
- package/management-ui/src/components/codegen/index.js +0 -10
- package/management-ui/src/components/connections/ConnectionConfigForm.jsx +0 -362
- package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +0 -182
- package/management-ui/src/components/connections/ConnectionTester.jsx +0 -200
- package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +0 -292
- package/management-ui/src/components/connections/OAuthFlow.jsx +0 -204
- package/management-ui/src/components/connections/index.js +0 -5
- package/management-ui/src/components/index.js +0 -21
- package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +0 -222
- package/management-ui/src/components/monitoring/LambdaMetrics.jsx +0 -169
- package/management-ui/src/components/monitoring/MetricsChart.jsx +0 -197
- package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +0 -393
- package/management-ui/src/components/monitoring/SQSMetrics.jsx +0 -246
- package/management-ui/src/components/monitoring/index.js +0 -6
- package/management-ui/src/components/monitoring/monitoring.css +0 -218
- package/management-ui/src/components/theme-provider.jsx +0 -52
- package/management-ui/src/components/theme-toggle.jsx +0 -39
- package/management-ui/src/components/ui/badge.tsx +0 -36
- package/management-ui/src/components/ui/button.test.jsx +0 -56
- package/management-ui/src/components/ui/button.tsx +0 -57
- package/management-ui/src/components/ui/card.tsx +0 -76
- package/management-ui/src/components/ui/dropdown-menu.tsx +0 -199
- package/management-ui/src/components/ui/select.tsx +0 -157
- package/management-ui/src/components/ui/skeleton.jsx +0 -15
- package/management-ui/src/hooks/useFrigg.jsx +0 -387
- package/management-ui/src/hooks/useSocket.jsx +0 -58
- package/management-ui/src/index.css +0 -193
- package/management-ui/src/lib/utils.ts +0 -6
- package/management-ui/src/main.jsx +0 -10
- package/management-ui/src/pages/CodeGeneration.jsx +0 -14
- package/management-ui/src/pages/Connections.jsx +0 -252
- package/management-ui/src/pages/ConnectionsEnhanced.jsx +0 -633
- package/management-ui/src/pages/Dashboard.jsx +0 -311
- package/management-ui/src/pages/Environment.jsx +0 -314
- package/management-ui/src/pages/IntegrationConfigure.jsx +0 -669
- package/management-ui/src/pages/IntegrationDiscovery.jsx +0 -567
- package/management-ui/src/pages/IntegrationTest.jsx +0 -742
- package/management-ui/src/pages/Integrations.jsx +0 -253
- package/management-ui/src/pages/Monitoring.jsx +0 -17
- package/management-ui/src/pages/Simulation.jsx +0 -155
- package/management-ui/src/pages/Users.jsx +0 -492
- package/management-ui/src/services/api.js +0 -41
- package/management-ui/src/services/apiModuleService.js +0 -193
- package/management-ui/src/services/websocket-handlers.js +0 -120
- package/management-ui/src/test/api/project.test.js +0 -273
- package/management-ui/src/test/components/Welcome.test.jsx +0 -378
- package/management-ui/src/test/mocks/server.js +0 -178
- package/management-ui/src/test/setup.js +0 -61
- package/management-ui/src/test/utils/test-utils.jsx +0 -134
- package/management-ui/src/utils/repository.js +0 -98
- package/management-ui/src/utils/repository.test.js +0 -118
- package/management-ui/src/workflows/phase2-integration-workflows.js +0 -884
- package/management-ui/tailwind.config.js +0 -63
- package/management-ui/tsconfig.json +0 -37
- package/management-ui/tsconfig.node.json +0 -10
- package/management-ui/vite.config.js +0 -26
- package/management-ui/vitest.config.js +0 -38
- package/test/auther-definition-method-tester.js +0 -45
- package/test/index.js +0 -9
- package/test/integration-validator.js +0 -2
- package/test/mock-api-readme.md +0 -102
- package/test/mock-api.js +0 -284
- package/test/mock-integration.js +0 -78
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VPC Discovery Service
|
|
3
|
-
*
|
|
4
|
-
* Domain Service - Hexagonal Architecture
|
|
5
|
-
*
|
|
6
|
-
* Discovers VPC and networking resources using the cloud provider adapter.
|
|
7
|
-
* Adds domain-specific validation and transformation logic.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
class VpcDiscovery {
|
|
11
|
-
/**
|
|
12
|
-
* @param {CloudProviderAdapter} provider - Cloud provider adapter instance
|
|
13
|
-
*/
|
|
14
|
-
constructor(provider) {
|
|
15
|
-
this.provider = provider;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Discover VPC and networking resources
|
|
20
|
-
*
|
|
21
|
-
* @param {Object} config - Discovery configuration
|
|
22
|
-
* @param {string} [config.vpcId] - Specific VPC ID to discover
|
|
23
|
-
* @param {string} [config.serviceName] - Service name for tagging/filtering
|
|
24
|
-
* @param {string} [config.stage] - Deployment stage
|
|
25
|
-
* @returns {Promise<Object>} Discovered VPC resources with friendly property names
|
|
26
|
-
*/
|
|
27
|
-
async discover(config) {
|
|
28
|
-
console.log('🔍 Discovering VPC resources...');
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
const rawResources = await this.provider.discoverVpc(config);
|
|
32
|
-
|
|
33
|
-
// Transform to Frigg-friendly format
|
|
34
|
-
const result = {
|
|
35
|
-
defaultVpcId: rawResources.vpcId,
|
|
36
|
-
vpcCidr: rawResources.vpcCidr,
|
|
37
|
-
subnets: rawResources.subnets,
|
|
38
|
-
securityGroups: rawResources.securityGroups,
|
|
39
|
-
routeTables: rawResources.routeTables,
|
|
40
|
-
natGateways: rawResources.natGateways,
|
|
41
|
-
internetGateways: rawResources.internetGateways,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// Extract specific subnet types
|
|
45
|
-
const privateSubnets = rawResources.subnets.filter(
|
|
46
|
-
s => !s.MapPublicIpOnLaunch
|
|
47
|
-
);
|
|
48
|
-
const publicSubnets = rawResources.subnets.filter(
|
|
49
|
-
s => s.MapPublicIpOnLaunch
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
// Set subnet IDs for Frigg infrastructure
|
|
53
|
-
if (privateSubnets.length >= 1) {
|
|
54
|
-
result.privateSubnetId1 = privateSubnets[0].SubnetId;
|
|
55
|
-
}
|
|
56
|
-
if (privateSubnets.length >= 2) {
|
|
57
|
-
result.privateSubnetId2 = privateSubnets[1].SubnetId;
|
|
58
|
-
}
|
|
59
|
-
if (publicSubnets.length >= 1) {
|
|
60
|
-
result.publicSubnetId = publicSubnets[0].SubnetId;
|
|
61
|
-
result.publicSubnetId1 = publicSubnets[0].SubnetId;
|
|
62
|
-
}
|
|
63
|
-
if (publicSubnets.length >= 2) {
|
|
64
|
-
result.publicSubnetId2 = publicSubnets[1].SubnetId;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Find default security group
|
|
68
|
-
const defaultSg = rawResources.securityGroups.find(
|
|
69
|
-
sg => sg.GroupName === 'default'
|
|
70
|
-
);
|
|
71
|
-
if (defaultSg) {
|
|
72
|
-
result.defaultSecurityGroupId = defaultSg.GroupId;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Find default route table
|
|
76
|
-
const defaultRt = rawResources.routeTables.find(
|
|
77
|
-
rt => rt.Associations?.some(a => a.Main)
|
|
78
|
-
);
|
|
79
|
-
if (defaultRt) {
|
|
80
|
-
result.defaultRouteTableId = defaultRt.RouteTableId;
|
|
81
|
-
result.privateRouteTableId = defaultRt.RouteTableId;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Find NAT gateway
|
|
85
|
-
const activeNat = rawResources.natGateways.find(
|
|
86
|
-
nat => nat.State === 'available'
|
|
87
|
-
);
|
|
88
|
-
if (activeNat) {
|
|
89
|
-
result.existingNatGatewayId = activeNat.NatGatewayId;
|
|
90
|
-
|
|
91
|
-
// Check if NAT is in private subnet (configuration error)
|
|
92
|
-
const natSubnet = rawResources.subnets.find(
|
|
93
|
-
s => s.SubnetId === activeNat.SubnetId
|
|
94
|
-
);
|
|
95
|
-
result.natGatewayInPrivateSubnet = natSubnet && !natSubnet.MapPublicIpOnLaunch;
|
|
96
|
-
|
|
97
|
-
// Get elastic IP allocation
|
|
98
|
-
if (activeNat.NatGatewayAddresses && activeNat.NatGatewayAddresses.length > 0) {
|
|
99
|
-
result.existingElasticIpAllocationId =
|
|
100
|
-
activeNat.NatGatewayAddresses[0].AllocationId;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Find Internet Gateway
|
|
105
|
-
if (rawResources.internetGateways.length > 0) {
|
|
106
|
-
result.internetGatewayId = rawResources.internetGateways[0].InternetGatewayId;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Find VPC Endpoints
|
|
110
|
-
if (rawResources.vpcEndpoints) {
|
|
111
|
-
const s3Endpoint = rawResources.vpcEndpoints.find(
|
|
112
|
-
ep => ep.ServiceName && ep.ServiceName.includes('.s3')
|
|
113
|
-
);
|
|
114
|
-
const dynamodbEndpoint = rawResources.vpcEndpoints.find(
|
|
115
|
-
ep => ep.ServiceName && ep.ServiceName.includes('.dynamodb')
|
|
116
|
-
);
|
|
117
|
-
const kmsEndpoint = rawResources.vpcEndpoints.find(
|
|
118
|
-
ep => ep.ServiceName && ep.ServiceName.includes('.kms')
|
|
119
|
-
);
|
|
120
|
-
const secretsManagerEndpoint = rawResources.vpcEndpoints.find(
|
|
121
|
-
ep => ep.ServiceName && ep.ServiceName.includes('.secretsmanager')
|
|
122
|
-
);
|
|
123
|
-
const sqsEndpoint = rawResources.vpcEndpoints.find(
|
|
124
|
-
ep => ep.ServiceName && ep.ServiceName.includes('.sqs')
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
if (s3Endpoint) {
|
|
128
|
-
result.s3VpcEndpointId = s3Endpoint.VpcEndpointId;
|
|
129
|
-
}
|
|
130
|
-
if (dynamodbEndpoint) {
|
|
131
|
-
result.dynamodbVpcEndpointId = dynamodbEndpoint.VpcEndpointId;
|
|
132
|
-
}
|
|
133
|
-
if (kmsEndpoint) {
|
|
134
|
-
result.kmsVpcEndpointId = kmsEndpoint.VpcEndpointId;
|
|
135
|
-
}
|
|
136
|
-
if (secretsManagerEndpoint) {
|
|
137
|
-
result.secretsManagerVpcEndpointId = secretsManagerEndpoint.VpcEndpointId;
|
|
138
|
-
}
|
|
139
|
-
if (sqsEndpoint) {
|
|
140
|
-
result.sqsVpcEndpointId = sqsEndpoint.VpcEndpointId;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
console.log(` ✓ Found VPC: ${result.defaultVpcId}`);
|
|
145
|
-
if (result.privateSubnetId1) {
|
|
146
|
-
console.log(` ✓ Found private subnets: ${result.privateSubnetId1}, ${result.privateSubnetId2 || 'N/A'}`);
|
|
147
|
-
}
|
|
148
|
-
if (result.publicSubnetId) {
|
|
149
|
-
console.log(` ✓ Found public subnet: ${result.publicSubnetId}`);
|
|
150
|
-
}
|
|
151
|
-
if (result.existingNatGatewayId) {
|
|
152
|
-
console.log(` ✓ Found NAT Gateway: ${result.existingNatGatewayId}`);
|
|
153
|
-
}
|
|
154
|
-
if (result.s3VpcEndpointId || result.dynamodbVpcEndpointId || result.kmsVpcEndpointId || result.secretsManagerVpcEndpointId || result.sqsVpcEndpointId) {
|
|
155
|
-
console.log(` ✓ Found VPC Endpoints: S3=${result.s3VpcEndpointId ? 'Yes' : 'No'}, DynamoDB=${result.dynamodbVpcEndpointId ? 'Yes' : 'No'}, KMS=${result.kmsVpcEndpointId ? 'Yes' : 'No'}, SecretsManager=${result.secretsManagerVpcEndpointId ? 'Yes' : 'No'}, SQS=${result.sqsVpcEndpointId ? 'Yes' : 'No'}`);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return result;
|
|
159
|
-
} catch (error) {
|
|
160
|
-
console.error(' ✗ VPC discovery failed:', error.message);
|
|
161
|
-
return {
|
|
162
|
-
defaultVpcId: null,
|
|
163
|
-
vpcCidr: null,
|
|
164
|
-
privateSubnetId1: null,
|
|
165
|
-
privateSubnetId2: null,
|
|
166
|
-
publicSubnetId: null,
|
|
167
|
-
defaultSecurityGroupId: null,
|
|
168
|
-
defaultRouteTableId: null,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
module.exports = {
|
|
175
|
-
VpcDiscovery,
|
|
176
|
-
};
|
|
177
|
-
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for VPC Discovery Service
|
|
3
|
-
*
|
|
4
|
-
* Tests VPC resource discovery with mocked cloud provider
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const { VpcDiscovery } = require('./vpc-discovery');
|
|
8
|
-
|
|
9
|
-
describe('VpcDiscovery', () => {
|
|
10
|
-
let mockProvider;
|
|
11
|
-
let vpcDiscovery;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
mockProvider = {
|
|
15
|
-
discoverVpc: jest.fn(),
|
|
16
|
-
getName: jest.fn().mockReturnValue('aws'),
|
|
17
|
-
};
|
|
18
|
-
vpcDiscovery = new VpcDiscovery(mockProvider);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe('discover()', () => {
|
|
22
|
-
it('should delegate to provider and transform results', async () => {
|
|
23
|
-
const mockProviderResponse = {
|
|
24
|
-
vpcId: 'vpc-123456',
|
|
25
|
-
vpcCidr: '172.31.0.0/16',
|
|
26
|
-
subnets: [
|
|
27
|
-
{
|
|
28
|
-
SubnetId: 'subnet-private1',
|
|
29
|
-
MapPublicIpOnLaunch: false,
|
|
30
|
-
AvailabilityZone: 'us-east-1a',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
SubnetId: 'subnet-private2',
|
|
34
|
-
MapPublicIpOnLaunch: false,
|
|
35
|
-
AvailabilityZone: 'us-east-1b',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
SubnetId: 'subnet-public1',
|
|
39
|
-
MapPublicIpOnLaunch: true,
|
|
40
|
-
AvailabilityZone: 'us-east-1a',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
securityGroups: [
|
|
44
|
-
{ GroupId: 'sg-default', GroupName: 'default' },
|
|
45
|
-
{ GroupId: 'sg-custom', GroupName: 'custom' },
|
|
46
|
-
],
|
|
47
|
-
routeTables: [
|
|
48
|
-
{
|
|
49
|
-
RouteTableId: 'rtb-123',
|
|
50
|
-
Associations: [{ Main: true }],
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
natGateways: [],
|
|
54
|
-
internetGateways: [
|
|
55
|
-
{ InternetGatewayId: 'igw-123' },
|
|
56
|
-
],
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
mockProvider.discoverVpc.mockResolvedValue(mockProviderResponse);
|
|
60
|
-
|
|
61
|
-
const result = await vpcDiscovery.discover({ vpcId: 'vpc-123456' });
|
|
62
|
-
|
|
63
|
-
expect(mockProvider.discoverVpc).toHaveBeenCalledWith({ vpcId: 'vpc-123456' });
|
|
64
|
-
expect(result.defaultVpcId).toBe('vpc-123456');
|
|
65
|
-
expect(result.vpcCidr).toBe('172.31.0.0/16');
|
|
66
|
-
expect(result.privateSubnetId1).toBe('subnet-private1');
|
|
67
|
-
expect(result.privateSubnetId2).toBe('subnet-private2');
|
|
68
|
-
expect(result.publicSubnetId).toBe('subnet-public1');
|
|
69
|
-
expect(result.publicSubnetId1).toBe('subnet-public1');
|
|
70
|
-
expect(result.defaultSecurityGroupId).toBe('sg-default');
|
|
71
|
-
expect(result.defaultRouteTableId).toBe('rtb-123');
|
|
72
|
-
expect(result.internetGatewayId).toBe('igw-123');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should handle VPC with only private subnets', async () => {
|
|
76
|
-
mockProvider.discoverVpc.mockResolvedValue({
|
|
77
|
-
vpcId: 'vpc-123',
|
|
78
|
-
vpcCidr: '10.0.0.0/16',
|
|
79
|
-
subnets: [
|
|
80
|
-
{ SubnetId: 'subnet-1', MapPublicIpOnLaunch: false },
|
|
81
|
-
],
|
|
82
|
-
securityGroups: [],
|
|
83
|
-
routeTables: [],
|
|
84
|
-
natGateways: [],
|
|
85
|
-
internetGateways: [],
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const result = await vpcDiscovery.discover({});
|
|
89
|
-
|
|
90
|
-
expect(result.privateSubnetId1).toBe('subnet-1');
|
|
91
|
-
expect(result.privateSubnetId2).toBeUndefined();
|
|
92
|
-
expect(result.publicSubnetId).toBeUndefined();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should handle NAT gateway discovery', async () => {
|
|
96
|
-
mockProvider.discoverVpc.mockResolvedValue({
|
|
97
|
-
vpcId: 'vpc-123',
|
|
98
|
-
vpcCidr: '10.0.0.0/16',
|
|
99
|
-
subnets: [
|
|
100
|
-
{ SubnetId: 'subnet-public', MapPublicIpOnLaunch: true },
|
|
101
|
-
{ SubnetId: 'subnet-private', MapPublicIpOnLaunch: false },
|
|
102
|
-
],
|
|
103
|
-
securityGroups: [],
|
|
104
|
-
routeTables: [],
|
|
105
|
-
natGateways: [
|
|
106
|
-
{
|
|
107
|
-
NatGatewayId: 'nat-123',
|
|
108
|
-
State: 'available',
|
|
109
|
-
SubnetId: 'subnet-public',
|
|
110
|
-
NatGatewayAddresses: [
|
|
111
|
-
{ AllocationId: 'eipalloc-456' },
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
internetGateways: [],
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
const result = await vpcDiscovery.discover({});
|
|
119
|
-
|
|
120
|
-
expect(result.existingNatGatewayId).toBe('nat-123');
|
|
121
|
-
expect(result.natGatewayInPrivateSubnet).toBe(false);
|
|
122
|
-
expect(result.existingElasticIpAllocationId).toBe('eipalloc-456');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('should detect NAT gateway in private subnet (configuration error)', async () => {
|
|
126
|
-
mockProvider.discoverVpc.mockResolvedValue({
|
|
127
|
-
vpcId: 'vpc-123',
|
|
128
|
-
vpcCidr: '10.0.0.0/16',
|
|
129
|
-
subnets: [
|
|
130
|
-
{ SubnetId: 'subnet-private', MapPublicIpOnLaunch: false },
|
|
131
|
-
],
|
|
132
|
-
securityGroups: [],
|
|
133
|
-
routeTables: [],
|
|
134
|
-
natGateways: [
|
|
135
|
-
{
|
|
136
|
-
NatGatewayId: 'nat-misplaced',
|
|
137
|
-
State: 'available',
|
|
138
|
-
SubnetId: 'subnet-private',
|
|
139
|
-
NatGatewayAddresses: [],
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
internetGateways: [],
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const result = await vpcDiscovery.discover({});
|
|
146
|
-
|
|
147
|
-
expect(result.existingNatGatewayId).toBe('nat-misplaced');
|
|
148
|
-
expect(result.natGatewayInPrivateSubnet).toBe(true);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('should ignore NAT gateways that are not available', async () => {
|
|
152
|
-
mockProvider.discoverVpc.mockResolvedValue({
|
|
153
|
-
vpcId: 'vpc-123',
|
|
154
|
-
vpcCidr: '10.0.0.0/16',
|
|
155
|
-
subnets: [],
|
|
156
|
-
securityGroups: [],
|
|
157
|
-
routeTables: [],
|
|
158
|
-
natGateways: [
|
|
159
|
-
{
|
|
160
|
-
NatGatewayId: 'nat-pending',
|
|
161
|
-
State: 'pending',
|
|
162
|
-
SubnetId: 'subnet-public',
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
NatGatewayId: 'nat-failed',
|
|
166
|
-
State: 'failed',
|
|
167
|
-
SubnetId: 'subnet-public',
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
internetGateways: [],
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
const result = await vpcDiscovery.discover({});
|
|
174
|
-
|
|
175
|
-
expect(result.existingNatGatewayId).toBeUndefined();
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('should handle discovery errors gracefully', async () => {
|
|
179
|
-
mockProvider.discoverVpc.mockRejectedValue(new Error('AWS API Error'));
|
|
180
|
-
|
|
181
|
-
const result = await vpcDiscovery.discover({});
|
|
182
|
-
|
|
183
|
-
expect(result.defaultVpcId).toBeNull();
|
|
184
|
-
expect(result.vpcCidr).toBeNull();
|
|
185
|
-
expect(result.privateSubnetId1).toBeNull();
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('should find default route table from main association', async () => {
|
|
189
|
-
mockProvider.discoverVpc.mockResolvedValue({
|
|
190
|
-
vpcId: 'vpc-123',
|
|
191
|
-
vpcCidr: '10.0.0.0/16',
|
|
192
|
-
subnets: [],
|
|
193
|
-
securityGroups: [],
|
|
194
|
-
routeTables: [
|
|
195
|
-
{
|
|
196
|
-
RouteTableId: 'rtb-custom',
|
|
197
|
-
Associations: [{ Main: false }],
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
RouteTableId: 'rtb-main',
|
|
201
|
-
Associations: [{ Main: true }],
|
|
202
|
-
},
|
|
203
|
-
],
|
|
204
|
-
natGateways: [],
|
|
205
|
-
internetGateways: [],
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
const result = await vpcDiscovery.discover({});
|
|
209
|
-
|
|
210
|
-
expect(result.defaultRouteTableId).toBe('rtb-main');
|
|
211
|
-
expect(result.privateRouteTableId).toBe('rtb-main');
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it('should handle multiple public subnets', async () => {
|
|
215
|
-
mockProvider.discoverVpc.mockResolvedValue({
|
|
216
|
-
vpcId: 'vpc-123',
|
|
217
|
-
vpcCidr: '10.0.0.0/16',
|
|
218
|
-
subnets: [
|
|
219
|
-
{ SubnetId: 'subnet-public-1', MapPublicIpOnLaunch: true },
|
|
220
|
-
{ SubnetId: 'subnet-public-2', MapPublicIpOnLaunch: true },
|
|
221
|
-
],
|
|
222
|
-
securityGroups: [],
|
|
223
|
-
routeTables: [],
|
|
224
|
-
natGateways: [],
|
|
225
|
-
internetGateways: [],
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
const result = await vpcDiscovery.discover({});
|
|
229
|
-
|
|
230
|
-
expect(result.publicSubnetId).toBe('subnet-public-1');
|
|
231
|
-
expect(result.publicSubnetId1).toBe('subnet-public-1');
|
|
232
|
-
expect(result.publicSubnetId2).toBe('subnet-public-2');
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it('should pass config to provider', async () => {
|
|
236
|
-
mockProvider.discoverVpc.mockResolvedValue({
|
|
237
|
-
vpcId: 'vpc-custom',
|
|
238
|
-
subnets: [],
|
|
239
|
-
securityGroups: [],
|
|
240
|
-
routeTables: [],
|
|
241
|
-
natGateways: [],
|
|
242
|
-
internetGateways: [],
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
const config = {
|
|
246
|
-
vpcId: 'vpc-custom',
|
|
247
|
-
serviceName: 'test-service',
|
|
248
|
-
stage: 'prod',
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
await vpcDiscovery.discover(config);
|
|
252
|
-
|
|
253
|
-
expect(mockProvider.discoverVpc).toHaveBeenCalledWith(config);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('should discover all VPC endpoints (S3, DynamoDB, KMS, Secrets Manager)', async () => {
|
|
257
|
-
mockProvider.discoverVpc.mockResolvedValue({
|
|
258
|
-
vpcId: 'vpc-123',
|
|
259
|
-
vpcCidr: '10.0.0.0/16',
|
|
260
|
-
subnets: [],
|
|
261
|
-
securityGroups: [],
|
|
262
|
-
routeTables: [],
|
|
263
|
-
natGateways: [],
|
|
264
|
-
internetGateways: [],
|
|
265
|
-
vpcEndpoints: [
|
|
266
|
-
{
|
|
267
|
-
VpcEndpointId: 'vpce-s3-123',
|
|
268
|
-
ServiceName: 'com.amazonaws.us-east-1.s3',
|
|
269
|
-
State: 'available',
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
VpcEndpointId: 'vpce-ddb-456',
|
|
273
|
-
ServiceName: 'com.amazonaws.us-east-1.dynamodb',
|
|
274
|
-
State: 'available',
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
VpcEndpointId: 'vpce-kms-789',
|
|
278
|
-
ServiceName: 'com.amazonaws.us-east-1.kms',
|
|
279
|
-
State: 'available',
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
VpcEndpointId: 'vpce-sm-abc',
|
|
283
|
-
ServiceName: 'com.amazonaws.us-east-1.secretsmanager',
|
|
284
|
-
State: 'available',
|
|
285
|
-
},
|
|
286
|
-
],
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
const result = await vpcDiscovery.discover({});
|
|
290
|
-
|
|
291
|
-
expect(result.s3VpcEndpointId).toBe('vpce-s3-123');
|
|
292
|
-
expect(result.dynamodbVpcEndpointId).toBe('vpce-ddb-456');
|
|
293
|
-
expect(result.kmsVpcEndpointId).toBe('vpce-kms-789');
|
|
294
|
-
expect(result.secretsManagerVpcEndpointId).toBe('vpce-sm-abc');
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it('should handle partial VPC endpoint discovery', async () => {
|
|
298
|
-
mockProvider.discoverVpc.mockResolvedValue({
|
|
299
|
-
vpcId: 'vpc-123',
|
|
300
|
-
vpcCidr: '10.0.0.0/16',
|
|
301
|
-
subnets: [],
|
|
302
|
-
securityGroups: [],
|
|
303
|
-
routeTables: [],
|
|
304
|
-
natGateways: [],
|
|
305
|
-
internetGateways: [],
|
|
306
|
-
vpcEndpoints: [
|
|
307
|
-
{
|
|
308
|
-
VpcEndpointId: 'vpce-s3-123',
|
|
309
|
-
ServiceName: 'com.amazonaws.us-east-1.s3',
|
|
310
|
-
State: 'available',
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
VpcEndpointId: 'vpce-ddb-456',
|
|
314
|
-
ServiceName: 'com.amazonaws.us-east-1.dynamodb',
|
|
315
|
-
State: 'available',
|
|
316
|
-
},
|
|
317
|
-
// KMS and Secrets Manager are missing
|
|
318
|
-
],
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
const result = await vpcDiscovery.discover({});
|
|
322
|
-
|
|
323
|
-
expect(result.s3VpcEndpointId).toBe('vpce-s3-123');
|
|
324
|
-
expect(result.dynamodbVpcEndpointId).toBe('vpce-ddb-456');
|
|
325
|
-
expect(result.kmsVpcEndpointId).toBeUndefined();
|
|
326
|
-
expect(result.secretsManagerVpcEndpointId).toBeUndefined();
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
it('should handle no VPC endpoints', async () => {
|
|
330
|
-
mockProvider.discoverVpc.mockResolvedValue({
|
|
331
|
-
vpcId: 'vpc-123',
|
|
332
|
-
vpcCidr: '10.0.0.0/16',
|
|
333
|
-
subnets: [],
|
|
334
|
-
securityGroups: [],
|
|
335
|
-
routeTables: [],
|
|
336
|
-
natGateways: [],
|
|
337
|
-
internetGateways: [],
|
|
338
|
-
vpcEndpoints: [],
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
const result = await vpcDiscovery.discover({});
|
|
342
|
-
|
|
343
|
-
expect(result.s3VpcEndpointId).toBeUndefined();
|
|
344
|
-
expect(result.dynamodbVpcEndpointId).toBeUndefined();
|
|
345
|
-
expect(result.kmsVpcEndpointId).toBeUndefined();
|
|
346
|
-
expect(result.secretsManagerVpcEndpointId).toBeUndefined();
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
|