terruvim-core-test 0.0.1

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.
Files changed (199) hide show
  1. package/dist/src/core/config.js +2 -0
  2. package/dist/src/core/configMerge.js +266 -0
  3. package/dist/src/core/configUtils.js +72 -0
  4. package/dist/src/core/dependencyResolver.js +17 -0
  5. package/dist/src/core/deployUtils.js +73 -0
  6. package/dist/src/core/dynamicResourceManager.js +709 -0
  7. package/dist/src/core/entrypoint.js +56 -0
  8. package/dist/src/core/generateFinalConfig.js +45 -0
  9. package/dist/src/core/index.js +24 -0
  10. package/dist/src/core/resourceMap.js +99 -0
  11. package/dist/src/factories/accountPermissions.js +134 -0
  12. package/dist/src/factories/acmFactory.js +30 -0
  13. package/dist/src/factories/albFactory.js +331 -0
  14. package/dist/src/factories/attachSecretAccessPolicy.js +56 -0
  15. package/dist/src/factories/auroraFactory.js +619 -0
  16. package/dist/src/factories/backupPolicy.js +152 -0
  17. package/dist/src/factories/bastionFactory.js +91 -0
  18. package/dist/src/factories/bedrockFactory.js +334 -0
  19. package/dist/src/factories/budgetFactory.js +64 -0
  20. package/dist/src/factories/buildAlbCloudWatchAlarmsHelper.js +79 -0
  21. package/dist/src/factories/buildAlbCloudWatchDashboardHelper.js +106 -0
  22. package/dist/src/factories/buildAlbListenerRulesHelper.js +45 -0
  23. package/dist/src/factories/buildAlbListenersHelper.js +64 -0
  24. package/dist/src/factories/buildAlbResourceHelper.js +54 -0
  25. package/dist/src/factories/buildAlbRoute53RecordHelper.js +49 -0
  26. package/dist/src/factories/buildAlbTargetGroupsHelper.js +47 -0
  27. package/dist/src/factories/buildAlbWafAssociationHelper.js +43 -0
  28. package/dist/src/factories/buildAndPushDockerImage.js +57 -0
  29. package/dist/src/factories/buildAwsCloudWatchAlarmsHelper.js +118 -0
  30. package/dist/src/factories/buildCloudFrontRoute53RecordHelper.js +49 -0
  31. package/dist/src/factories/buildEcsClusterArgs.js +32 -0
  32. package/dist/src/factories/buildEcsSecrets.js +48 -0
  33. package/dist/src/factories/buildForceRedeployEnv.js +8 -0
  34. package/dist/src/factories/buildResourceOptions.js +11 -0
  35. package/dist/src/factories/buildS3StaticHostingCicdHelper.js +142 -0
  36. package/dist/src/factories/buildS3StaticHostingCloudWatchDashboardHelper.js +122 -0
  37. package/dist/src/factories/cloudTrailFactory.js +22 -0
  38. package/dist/src/factories/cloudWatchCompositeAlarmFactory.js +91 -0
  39. package/dist/src/factories/cloudWatchInsightsQueryFactory.js +83 -0
  40. package/dist/src/factories/cloudWatchLogGroupFactory.js +84 -0
  41. package/dist/src/factories/cloudfrontCodePipelineFactory.js +357 -0
  42. package/dist/src/factories/cloudwatchAlarmsFactory.js +121 -0
  43. package/dist/src/factories/codePipelineNotificationFactory.js +193 -0
  44. package/dist/src/factories/codePipelineNotificationRulesFactory.js +117 -0
  45. package/dist/src/factories/codeStarConnectionFactory.js +56 -0
  46. package/dist/src/factories/collectSecretKeys.js +18 -0
  47. package/dist/src/factories/comprehensiveNotificationFactory.js +250 -0
  48. package/dist/src/factories/costAndUsageReportFactory.js +32 -0
  49. package/dist/src/factories/createAwsAcmCertificate.js +40 -0
  50. package/dist/src/factories/createAwsBudget.js +40 -0
  51. package/dist/src/factories/createAwsCloudTrail.js +59 -0
  52. package/dist/src/factories/createAwsCloudwatchDashboard.js +59 -0
  53. package/dist/src/factories/createAwsEc2Instance.js +40 -0
  54. package/dist/src/factories/createAwsEventBridgeEventBus.js +40 -0
  55. package/dist/src/factories/createAwsGuardDutyDetector.js +40 -0
  56. package/dist/src/factories/createAwsGuardDutyDetectorFeature.js +45 -0
  57. package/dist/src/factories/createAwsGuardDutyFilter.js +46 -0
  58. package/dist/src/factories/createAwsGuardDutyPublishingDestination.js +50 -0
  59. package/dist/src/factories/createAwsHostedZone.js +40 -0
  60. package/dist/src/factories/createAwsIamRole.js +49 -0
  61. package/dist/src/factories/createAwsIamRoleInlinePolicies.js +48 -0
  62. package/dist/src/factories/createAwsIdentitystoreGroup.js +44 -0
  63. package/dist/src/factories/createAwsIdentitystoreGroupMembership.js +56 -0
  64. package/dist/src/factories/createAwsIdentitystoreUser.js +47 -0
  65. package/dist/src/factories/createAwsInspectorAssessmentTarget.js +47 -0
  66. package/dist/src/factories/createAwsInspectorDelegatedAdminAccount.js +47 -0
  67. package/dist/src/factories/createAwsInspectorEnabler.js +49 -0
  68. package/dist/src/factories/createAwsInspectorOrganizationConfiguration.js +55 -0
  69. package/dist/src/factories/createAwsKmsAliases.js +47 -0
  70. package/dist/src/factories/createAwsKmsKey.js +51 -0
  71. package/dist/src/factories/createAwsMacieAccount.js +45 -0
  72. package/dist/src/factories/createAwsMacieClassificationJob.js +53 -0
  73. package/dist/src/factories/createAwsMacieMember.js +49 -0
  74. package/dist/src/factories/createAwsMacieOrganizationConfiguration.js +44 -0
  75. package/dist/src/factories/createAwsRdsCluster.js +40 -0
  76. package/dist/src/factories/createAwsRdsClusterInstance.js +40 -0
  77. package/dist/src/factories/createAwsRdsInstance.js +40 -0
  78. package/dist/src/factories/createAwsRdsSubnetGroup.js +40 -0
  79. package/dist/src/factories/createAwsRoute53Record.js +40 -0
  80. package/dist/src/factories/createAwsSecret.js +40 -0
  81. package/dist/src/factories/createAwsSecretRotation.js +40 -0
  82. package/dist/src/factories/createAwsSecretVersion.js +40 -0
  83. package/dist/src/factories/createAwsSecurityGroup.js +40 -0
  84. package/dist/src/factories/createAwsSecurityGroupRule.js +40 -0
  85. package/dist/src/factories/createAwsSecurityHubAccount.js +40 -0
  86. package/dist/src/factories/createAwsSecurityHubAutomationRule.js +48 -0
  87. package/dist/src/factories/createAwsSecurityHubStandardsControl.js +44 -0
  88. package/dist/src/factories/createAwsSecurityHubStandardsSubscription.js +42 -0
  89. package/dist/src/factories/createAwsSesDomainDkim.js +40 -0
  90. package/dist/src/factories/createAwsSesDomainIdentity.js +40 -0
  91. package/dist/src/factories/createAwsSesEmailIdentity.js +40 -0
  92. package/dist/src/factories/createAwsSnsSubscription.js +62 -0
  93. package/dist/src/factories/createAwsSnsTopic.js +41 -0
  94. package/dist/src/factories/createAwsSqsQueue.js +40 -0
  95. package/dist/src/factories/createAwsSsmParameters.js +66 -0
  96. package/dist/src/factories/createAwsSsoAccountAssignment.js +66 -0
  97. package/dist/src/factories/createAwsSsoPermissionSet.js +64 -0
  98. package/dist/src/factories/createAwsStepFunctionsStateMachine.js +40 -0
  99. package/dist/src/factories/createBudget.js +56 -0
  100. package/dist/src/factories/createBudgetWithSnsAlert.js +79 -0
  101. package/dist/src/factories/createCostAndUsageReport.js +40 -0
  102. package/dist/src/factories/createEcrRepo.js +69 -0
  103. package/dist/src/factories/createEcsRolesAndPolicies.js +84 -0
  104. package/dist/src/factories/createEcsService.js +71 -0
  105. package/dist/src/factories/createEnvSecret.js +60 -0
  106. package/dist/src/factories/createGithubCodeStarConnection.js +44 -0
  107. package/dist/src/factories/createIamUserWithAccessKey.js +44 -0
  108. package/dist/src/factories/createLambdaFunction.js +89 -0
  109. package/dist/src/factories/createLambdaPermission.js +57 -0
  110. package/dist/src/factories/createListenerRule.js +68 -0
  111. package/dist/src/factories/createLogGroup.js +44 -0
  112. package/dist/src/factories/createSlackChannelConfiguration.js +49 -0
  113. package/dist/src/factories/createTargetGroup.js +50 -0
  114. package/dist/src/factories/createTaskDefinition.js +49 -0
  115. package/dist/src/factories/createVpcEndpoint.js +49 -0
  116. package/dist/src/factories/dashboardFactory.js +94 -0
  117. package/dist/src/factories/dataProtectionPolicyBuilder.js +103 -0
  118. package/dist/src/factories/ec2Factory.js +67 -0
  119. package/dist/src/factories/ecsClusterFactory.js +90 -0
  120. package/dist/src/factories/ecsCodePipelineFactory.js +308 -0
  121. package/dist/src/factories/ecsServiceFactory.js +350 -0
  122. package/dist/src/factories/enhancedCloudFrontCodePipelineFactory.js +205 -0
  123. package/dist/src/factories/enhancedEcsCodePipelineFactory.js +189 -0
  124. package/dist/src/factories/eventBridgeBusFactory.js +84 -0
  125. package/dist/src/factories/eventBridgeFactory.js +26 -0
  126. package/dist/src/factories/eventBridgeRuleFactory.js +114 -0
  127. package/dist/src/factories/fetchAllSecrets.js +51 -0
  128. package/dist/src/factories/getDeterministicPriority.js +13 -0
  129. package/dist/src/factories/getOrCreateSshKeyPair.js +57 -0
  130. package/dist/src/factories/guardDutyFactory.js +151 -0
  131. package/dist/src/factories/hostedZoneFactory.js +30 -0
  132. package/dist/src/factories/iamRoleFactory.js +29 -0
  133. package/dist/src/factories/inspectorFactory.js +109 -0
  134. package/dist/src/factories/kmsKeyFactory.js +32 -0
  135. package/dist/src/factories/lambdaFactory.js +133 -0
  136. package/dist/src/factories/lambdaPermissionFactory.js +32 -0
  137. package/dist/src/factories/logDataProtectionPolicyFactory.js +81 -0
  138. package/dist/src/factories/macieFactory.js +85 -0
  139. package/dist/src/factories/networkingFactory.js +429 -0
  140. package/dist/src/factories/opensearchCollectionFactory.js +109 -0
  141. package/dist/src/factories/organizationFactory.js +221 -0
  142. package/dist/src/factories/processReservedInstances.js +6 -0
  143. package/dist/src/factories/processSavingsPlans.js +43 -0
  144. package/dist/src/factories/rdsFactory.js +40 -0
  145. package/dist/src/factories/recordFactory.js +36 -0
  146. package/dist/src/factories/resolveEnvSecrets.js +14 -0
  147. package/dist/src/factories/resourceFactory.js +12 -0
  148. package/dist/src/factories/s3Factory.js +262 -0
  149. package/dist/src/factories/s3StaticHostingFactory.backup.js +424 -0
  150. package/dist/src/factories/s3StaticHostingFactory.js +348 -0
  151. package/dist/src/factories/s3StaticHostingFactory.refactored.js +334 -0
  152. package/dist/src/factories/savingsPlanFactory.js +26 -0
  153. package/dist/src/factories/secretsManagerFactory.js +107 -0
  154. package/dist/src/factories/securityGroupFactory.js +28 -0
  155. package/dist/src/factories/securityGroupRuleFactory.js +43 -0
  156. package/dist/src/factories/securityHubFactory.js +96 -0
  157. package/dist/src/factories/sesDomainDkimFactory.js +25 -0
  158. package/dist/src/factories/sesFactory.js +25 -0
  159. package/dist/src/factories/sesIdentitiesFactory.js +134 -0
  160. package/dist/src/factories/simpleNotificationFactory.js +112 -0
  161. package/dist/src/factories/smtpUserFactory.js +108 -0
  162. package/dist/src/factories/snsFactory.js +87 -0
  163. package/dist/src/factories/sqsFactory.js +41 -0
  164. package/dist/src/factories/ssmParameterFactory.js +67 -0
  165. package/dist/src/factories/ssoFactory.js +32 -0
  166. package/dist/src/factories/ssoGroupFactory.js +41 -0
  167. package/dist/src/factories/ssoPermissionSetFactory.js +29 -0
  168. package/dist/src/factories/ssoUserFactory.js +30 -0
  169. package/dist/src/factories/stepFunctionsFactory.js +32 -0
  170. package/dist/src/factories/tagPolicies.js +99 -0
  171. package/dist/src/factories/transformBudgetCostFilters.js +8 -0
  172. package/dist/src/factories/transformBudgetNotifications.js +12 -0
  173. package/dist/src/factories/transformBudgetPlannedLimits.js +8 -0
  174. package/dist/src/factories/types.js +2 -0
  175. package/dist/src/factories/validateAcmConfig.js +26 -0
  176. package/dist/src/factories/validateAuroraConfig.js +8 -0
  177. package/dist/src/factories/validateBedrockConfig.js +124 -0
  178. package/dist/src/factories/validateDashboardConfig.js +28 -0
  179. package/dist/src/factories/validateEventBridgeConfig.js +14 -0
  180. package/dist/src/factories/validateHostedZoneConfig.js +26 -0
  181. package/dist/src/factories/validateIamRoleConfig.js +8 -0
  182. package/dist/src/factories/validateKmsKeyConfig.js +8 -0
  183. package/dist/src/factories/validateRdsConfig.js +17 -0
  184. package/dist/src/factories/validateRoute53RecordConfig.js +41 -0
  185. package/dist/src/factories/validateS3Config.js +8 -0
  186. package/dist/src/factories/validateSecretsManagerConfig.js +8 -0
  187. package/dist/src/factories/validateSecurityGroupConfig.js +8 -0
  188. package/dist/src/factories/validateSecurityGroupRuleConfig.js +8 -0
  189. package/dist/src/factories/validateSesDomainDkimConfig.js +8 -0
  190. package/dist/src/factories/validateSesDomainIdentityConfig.js +8 -0
  191. package/dist/src/factories/validateSesIdentitiesConfig.js +40 -0
  192. package/dist/src/factories/validateSnsConfig.js +11 -0
  193. package/dist/src/factories/validateSqsConfig.js +11 -0
  194. package/dist/src/factories/validateSsmParameterFactoryConfig.js +9 -0
  195. package/dist/src/factories/validateStepFunctionsConfig.js +8 -0
  196. package/dist/src/factories/vpcEndpointFactory.js +98 -0
  197. package/dist/src/factories/wafFactory.js +499 -0
  198. package/package.json +71 -0
  199. package/scripts/copy-assets.js +136 -0
@@ -0,0 +1,709 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.DynamicResourceManager = void 0;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const pulumi = __importStar(require("@pulumi/pulumi"));
40
+ const aws = __importStar(require("@pulumi/aws"));
41
+ const resourceMap_1 = require("./resourceMap");
42
+ const budgetFactory_1 = require("../factories/budgetFactory");
43
+ const cloudTrailFactory_1 = require("../factories/cloudTrailFactory");
44
+ const costAndUsageReportFactory_1 = require("../factories/costAndUsageReportFactory");
45
+ const macieFactory_1 = require("../factories/macieFactory");
46
+ const organizationFactory_1 = require("../factories/organizationFactory");
47
+ const savingsPlanFactory_1 = require("../factories/savingsPlanFactory");
48
+ const securityHubFactory_1 = require("../factories/securityHubFactory");
49
+ const inspectorFactory_1 = require("../factories/inspectorFactory");
50
+ const guardDutyFactory_1 = require("../factories/guardDutyFactory");
51
+ const ssoFactory_1 = require("../factories/ssoFactory");
52
+ const ssoPermissionSetFactory_1 = require("../factories/ssoPermissionSetFactory");
53
+ const ssoUserFactory_1 = require("../factories/ssoUserFactory");
54
+ const ssoGroupFactory_1 = require("../factories/ssoGroupFactory");
55
+ const rdsFactory_1 = require("../factories/rdsFactory");
56
+ const auroraFactory_1 = require("../factories/auroraFactory");
57
+ const s3Factory_1 = require("../factories/s3Factory");
58
+ const snsFactory_1 = require("../factories/snsFactory");
59
+ const sqsFactory_1 = require("../factories/sqsFactory");
60
+ const stepFunctionsFactory_1 = require("../factories/stepFunctionsFactory");
61
+ const eventBridgeFactory_1 = require("../factories/eventBridgeFactory");
62
+ const eventBridgeRuleFactory_1 = require("../factories/eventBridgeRuleFactory");
63
+ const sesFactory_1 = require("../factories/sesFactory");
64
+ const sesDomainDkimFactory_1 = require("../factories/sesDomainDkimFactory");
65
+ const sesIdentitiesFactory_1 = require("../factories/sesIdentitiesFactory");
66
+ const hostedZoneFactory_1 = require("../factories/hostedZoneFactory");
67
+ const recordFactory_1 = require("../factories/recordFactory");
68
+ const acmFactory_1 = require("../factories/acmFactory");
69
+ const securityGroupRuleFactory_1 = require("../factories/securityGroupRuleFactory");
70
+ const securityGroupFactory_1 = require("../factories/securityGroupFactory");
71
+ const iamRoleFactory_1 = require("../factories/iamRoleFactory");
72
+ const kmsKeyFactory_1 = require("../factories/kmsKeyFactory");
73
+ const secretsManagerFactory_1 = require("../factories/secretsManagerFactory");
74
+ const ec2Factory_1 = require("../factories/ec2Factory");
75
+ const lambdaFactory_1 = require("../factories/lambdaFactory");
76
+ const lambdaPermissionFactory_1 = require("../factories/lambdaPermissionFactory");
77
+ const vpcEndpointFactory_1 = require("../factories/vpcEndpointFactory");
78
+ const smtpUserFactory_1 = require("../factories/smtpUserFactory");
79
+ const codeStarConnectionFactory_1 = require("../factories/codeStarConnectionFactory");
80
+ const cloudwatchAlarmsFactory_1 = require("../factories/cloudwatchAlarmsFactory");
81
+ const dashboardFactory_1 = require("../factories/dashboardFactory");
82
+ const cloudWatchCompositeAlarmFactory_1 = require("../factories/cloudWatchCompositeAlarmFactory");
83
+ const cloudWatchInsightsQueryFactory_1 = require("../factories/cloudWatchInsightsQueryFactory");
84
+ const cloudWatchLogGroupFactory_1 = require("../factories/cloudWatchLogGroupFactory");
85
+ const logDataProtectionPolicyFactory_1 = require("../factories/logDataProtectionPolicyFactory");
86
+ const ssmParameterFactory_1 = require("../factories/ssmParameterFactory");
87
+ const bastionFactory_1 = require("../factories/bastionFactory");
88
+ const ecsCodePipelineFactory_1 = require("../factories/ecsCodePipelineFactory");
89
+ const cloudfrontCodePipelineFactory_1 = require("../factories/cloudfrontCodePipelineFactory");
90
+ const ecsServiceFactory_1 = require("../factories/ecsServiceFactory");
91
+ const ecsClusterFactory_1 = require("../factories/ecsClusterFactory");
92
+ const s3StaticHostingFactory_1 = require("../factories/s3StaticHostingFactory");
93
+ const albFactory_1 = require("../factories/albFactory");
94
+ const networkingFactory_1 = require("../factories/networkingFactory");
95
+ const enhancedEcsCodePipelineFactory_1 = require("../factories/enhancedEcsCodePipelineFactory");
96
+ const enhancedCloudFrontCodePipelineFactory_1 = require("../factories/enhancedCloudFrontCodePipelineFactory");
97
+ const simpleNotificationFactory_1 = require("../factories/simpleNotificationFactory");
98
+ const codePipelineNotificationRulesFactory_1 = require("../factories/codePipelineNotificationRulesFactory");
99
+ const bedrockFactory_1 = require("../factories/bedrockFactory");
100
+ const opensearchCollectionFactory_1 = require("../factories/opensearchCollectionFactory");
101
+ const lambdaFactory_2 = require("../factories/lambdaFactory");
102
+ const eventBridgeBusFactory_1 = require("../factories/eventBridgeBusFactory");
103
+ const globalResourceRegistry = new Set();
104
+ function loadProviders(config) {
105
+ const providers = {};
106
+ let providerConfigs = {};
107
+ if (config.providers && Object.keys(config.providers).length > 0) {
108
+ providerConfigs = config.providers;
109
+ }
110
+ else if (config.meta && config.meta.providers) {
111
+ providerConfigs = config.meta.providers;
112
+ }
113
+ for (const [name, provCfg] of Object.entries(providerConfigs)) {
114
+ if (name === "default")
115
+ continue;
116
+ providers[name] = new aws.Provider(name, {
117
+ region: provCfg.region,
118
+ profile: provCfg.profile,
119
+ assumeRole: provCfg.assumeRole,
120
+ });
121
+ }
122
+ return providers;
123
+ }
124
+ class DynamicResourceManager {
125
+ config;
126
+ deployedResources = {};
127
+ resourceOutputs = {};
128
+ factories = new Map();
129
+ providers = {};
130
+ constructor(configPath) {
131
+ const resolvedPath = path.resolve(configPath);
132
+ this.config = JSON.parse(fs.readFileSync(resolvedPath, "utf-8"));
133
+ this.factories.set("l2_organizationFactory", new organizationFactory_1.OrganizationFactory());
134
+ this.factories.set("l2_budgetFactory", new budgetFactory_1.BudgetFactory());
135
+ this.factories.set("l2_cloudTrailFactory", new cloudTrailFactory_1.CloudTrailFactory());
136
+ this.factories.set("l2_curFactory", new costAndUsageReportFactory_1.CostAndUsageReportFactory());
137
+ this.factories.set("l2_guardDutyFactory", new guardDutyFactory_1.GuardDutyFactory());
138
+ this.factories.set("l2_macieFactory", new macieFactory_1.MacieFactory());
139
+ this.factories.set("l2_savingsPlanFactory", new savingsPlanFactory_1.SavingsPlanFactory());
140
+ this.factories.set("l2_billingFactory", new budgetFactory_1.BudgetFactory());
141
+ this.factories.set("l2_securityHubFactory", new securityHubFactory_1.SecurityHubFactory());
142
+ this.factories.set("l2_inspectorFactory", new inspectorFactory_1.InspectorFactory());
143
+ this.factories.set("l2_ssoFactory", new ssoFactory_1.SSOFactory());
144
+ this.factories.set("l2_ssoPermissionSetFactory", new ssoPermissionSetFactory_1.SSOPermissionSetFactory());
145
+ this.factories.set("l2_ssoUserFactory", new ssoUserFactory_1.SsoUserFactory());
146
+ this.factories.set("l2_ssoGroupFactory", new ssoGroupFactory_1.SsoGroupFactory());
147
+ this.factories.set("l3_rdsFactory", new rdsFactory_1.RdsFactory());
148
+ this.factories.set("l3_auroraFactory", new auroraFactory_1.AuroraFactory());
149
+ this.factories.set("l3_snsFactory", new snsFactory_1.SnsFactory());
150
+ this.factories.set("l3_sqsFactory", new sqsFactory_1.SqsFactory());
151
+ this.factories.set("l3_eventBridgeFactory", new eventBridgeFactory_1.EventBridgeFactory());
152
+ this.factories.set("l3_eventBridgeRuleFactory", new eventBridgeRuleFactory_1.EventBridgeRuleFactory());
153
+ this.factories.set("l3_eventBridgeCustomBusFactory", new eventBridgeBusFactory_1.EventBridgeBusFactory());
154
+ this.factories.set("l3_stepFunctionsFactory", new stepFunctionsFactory_1.StepFunctionsFactory());
155
+ this.factories.set("l3_smtpUserFactory", new smtpUserFactory_1.SmtpUserFactory());
156
+ this.factories.set("l3_sesFactory", new sesFactory_1.SesFactory());
157
+ this.factories.set("l3_sesDomainDkimFactory", new sesDomainDkimFactory_1.SesDomainDkimFactory());
158
+ this.factories.set("l3_sesIdentitiesFactory", new sesIdentitiesFactory_1.SesIdentitiesFactory());
159
+ this.factories.set("l3_s3Factory", new s3Factory_1.S3Factory());
160
+ this.factories.set("l3_hostedZonesFactory", new hostedZoneFactory_1.HostedZoneFactory());
161
+ this.factories.set("l3_recordsFactory", new recordFactory_1.RecordFactory());
162
+ this.factories.set("l3_acmFactory", new acmFactory_1.AcmFactory());
163
+ this.factories.set("l3_iamRolesFactory", new iamRoleFactory_1.IamRoleFactory());
164
+ this.factories.set("l3_kmsKeysFactory", new kmsKeyFactory_1.KmsKeyFactory());
165
+ this.factories.set("l3_secretsManagerFactory", new secretsManagerFactory_1.SecretsManagerFactory());
166
+ this.factories.set("l3_ec2Factory", new ec2Factory_1.Ec2Factory());
167
+ this.factories.set("l3_lambdaFactory", new lambdaFactory_1.LambdaFactory());
168
+ this.factories.set("l3_lambdaPermissionFactory", new lambdaPermissionFactory_1.LambdaPermissionFactory());
169
+ this.factories.set("l3_vpcEndpointFactory", new vpcEndpointFactory_1.VpcEndpointFactory());
170
+ this.factories.set("l3_securityGroupsFactory", new securityGroupFactory_1.SecurityGroupFactory());
171
+ this.factories.set("l3_securityGroupRulesFactory", new securityGroupRuleFactory_1.SecurityGroupRuleFactory());
172
+ this.factories.set("l3_codeStarConnectionFactory", new codeStarConnectionFactory_1.CodeStarConnectionFactory());
173
+ this.factories.set("l3_cloudWatchAlarmsFactory", new cloudwatchAlarmsFactory_1.CloudWatchAlarmsFactory());
174
+ this.factories.set("l3_cloudWatchDashboardFactory", new dashboardFactory_1.DashboardFactory());
175
+ this.factories.set("l3_cloudWatchCompositeAlarmFactory", new cloudWatchCompositeAlarmFactory_1.CloudWatchCompositeAlarmFactory());
176
+ this.factories.set("l3_cloudWatchInsightsQueryFactory", new cloudWatchInsightsQueryFactory_1.CloudWatchInsightsQueryFactory());
177
+ this.factories.set("l3_cloudWatchLogGroupFactory", new cloudWatchLogGroupFactory_1.CloudWatchLogGroupFactory());
178
+ this.factories.set("l3_logDataProtectionPolicyFactory", new logDataProtectionPolicyFactory_1.LogDataProtectionPolicyFactory());
179
+ this.factories.set("l3_ssmParameterFactory", new ssmParameterFactory_1.SSMParameterFactory());
180
+ this.factories.set("l4_basicNetworkingFactory", new networkingFactory_1.AdvancedNetworkingFactory());
181
+ this.factories.set("l4_albFactory", new albFactory_1.AlbFactory());
182
+ this.factories.set("l4_bastionFactory", new bastionFactory_1.BastionFactory());
183
+ this.factories.set("l4_ecsClusterFactory", new ecsClusterFactory_1.ClusterFactory());
184
+ this.factories.set("l4_ecsServiceFactory", new ecsServiceFactory_1.ServiceFactory());
185
+ this.factories.set("l4_ecsCodePipelinesFactory", new ecsCodePipelineFactory_1.ECSCodePipelineFactory());
186
+ this.factories.set("l4_cloudfrontCodePipelineFactory", new cloudfrontCodePipelineFactory_1.CloudFrontCodePipelineFactory());
187
+ this.factories.set("l4_s3StaticHostingFactory", new s3StaticHostingFactory_1.S3StaticHostingFactory());
188
+ this.factories.set("l4_enhancedEcsCodePipelineFactory", new enhancedEcsCodePipelineFactory_1.EnhancedEcsCodePipelineFactory());
189
+ this.factories.set("l4_enhancedCloudFrontCodePipelineFactory", new enhancedCloudFrontCodePipelineFactory_1.EnhancedCloudFrontCodePipelineFactory());
190
+ this.factories.set("l4_simpleNotificationFactory", new simpleNotificationFactory_1.SimpleNotificationFactory());
191
+ this.factories.set("l4_codePipelineNotificationRulesFactory", new codePipelineNotificationRulesFactory_1.CodePipelineNotificationRulesFactory());
192
+ this.factories.set("l4_bedrockFactory", new bedrockFactory_1.BedrockFactory());
193
+ this.factories.set("l4_opensearchCollectionFactory", new opensearchCollectionFactory_1.OpenSearchCollectionFactory());
194
+ this.factories.set("l4_lambdaFactory", new lambdaFactory_2.LambdaFactory());
195
+ this.providers = loadProviders(this.config);
196
+ Object.entries(this.providers).forEach(([key, provider]) => { });
197
+ }
198
+ resolveInputs(inputs) {
199
+ const resolved = {};
200
+ for (const [key, value] of Object.entries(inputs || {})) {
201
+ let resolvedValue = value;
202
+ if (typeof value === "string" && value.startsWith("${output:")) {
203
+ const match = value.match(/^[\$]{output:([^.]+)\.([\w$]+)(\[(\d+)\])?}$/);
204
+ if (match) {
205
+ const [, resourceId, outputKey, , indexStr] = match;
206
+ let outputVal = this.resourceOutputs[resourceId]?.[outputKey];
207
+ if (outputVal === undefined) {
208
+ throw new Error(`Output value for ${resourceId}.${outputKey} is not available`);
209
+ }
210
+ if (indexStr !== undefined && Array.isArray(outputVal)) {
211
+ resolvedValue = outputVal[parseInt(indexStr, 10)];
212
+ }
213
+ else {
214
+ resolvedValue = outputVal;
215
+ }
216
+ }
217
+ }
218
+ const logValue = typeof resolvedValue === 'object' && resolvedValue !== null && typeof resolvedValue.apply === 'function'
219
+ ? '[Pulumi Output]'
220
+ : resolvedValue;
221
+ console.log(`[resolveInputs] key: ${key}, raw:`, value, ', resolved:', logValue);
222
+ resolved[key] = resolvedValue;
223
+ }
224
+ return resolved;
225
+ }
226
+ async resolveOutputsDeep(obj) {
227
+ if (Array.isArray(obj)) {
228
+ const resolvedArray = await Promise.all(obj.map(item => this.resolveOutputsDeep(item)));
229
+ return resolvedArray;
230
+ }
231
+ if (obj && typeof obj === "object") {
232
+ const resolved = {};
233
+ for (const [key, value] of Object.entries(obj)) {
234
+ resolved[key] = await this.resolveOutputsDeep(value);
235
+ }
236
+ return resolved;
237
+ }
238
+ if (typeof obj === "string") {
239
+ let resolvedString = obj;
240
+ let hasChanges = true;
241
+ let maxIterations = 10;
242
+ let iteration = 0;
243
+ while (hasChanges && iteration < maxIterations) {
244
+ const originalString = resolvedString;
245
+ if (this.isMetaPattern(resolvedString)) {
246
+ resolvedString = this.resolveMetaPattern(resolvedString);
247
+ }
248
+ if (this.isIdPattern(resolvedString)) {
249
+ resolvedString = this.resolveIdPattern(resolvedString);
250
+ }
251
+ if (this.isOutputPattern(resolvedString)) {
252
+ const outputResolved = this.resolveOutputPattern(resolvedString);
253
+ if (typeof outputResolved === "string") {
254
+ resolvedString = outputResolved;
255
+ }
256
+ else {
257
+ resolvedString = outputResolved;
258
+ }
259
+ }
260
+ if (typeof resolvedString === "object" && resolvedString !== null && typeof resolvedString.apply === "function") {
261
+ return resolvedString.apply(async (value) => {
262
+ let finalString = value;
263
+ if (this.isSecretPattern(finalString)) {
264
+ finalString = await this.resolveSecretPatternAsync(finalString);
265
+ }
266
+ return finalString;
267
+ });
268
+ }
269
+ if (this.isSecretPattern(resolvedString)) {
270
+ resolvedString = await this.resolveSecretPatternAsync(resolvedString);
271
+ }
272
+ hasChanges = (originalString !== resolvedString);
273
+ iteration++;
274
+ }
275
+ if (iteration >= maxIterations) {
276
+ console.warn(`Maximum iterations reached while resolving patterns in string: ${obj}`);
277
+ }
278
+ return resolvedString;
279
+ }
280
+ return obj;
281
+ }
282
+ isOutputPattern(str) {
283
+ return /\$\{output:([^.}]+)\.([\w$]+)((?:\[\d+\])?(?:\.[\w$]+)*)\}/.test(str);
284
+ }
285
+ resolveOutputPattern(str) {
286
+ const fullMatch = str.match(/^\$\{output:([^.}]+)\.([\w$]+)((?:\[\d+\])?(?:\.[\w$]+)*)}$/);
287
+ if (fullMatch) {
288
+ const [, resourceId, outputKey, rest] = fullMatch;
289
+ let outputVal;
290
+ try {
291
+ outputVal = (0, resourceMap_1.getResourceOutput)(resourceId, outputKey);
292
+ }
293
+ catch (e) {
294
+ return str;
295
+ }
296
+ let chain = rest || "";
297
+ const chainRegex = /(\[\d+\])|\.([\w$]+)/g;
298
+ let match;
299
+ let accessors = [];
300
+ while ((match = chainRegex.exec(chain)) !== null) {
301
+ if (match[1]) {
302
+ accessors.push(Number(match[1].slice(1, -1)));
303
+ }
304
+ else if (match[2]) {
305
+ accessors.push(match[2]);
306
+ }
307
+ }
308
+ function resolveChain(val, accs) {
309
+ if (accs.length === 0)
310
+ return val;
311
+ const [head, ...tail] = accs;
312
+ if (val == null)
313
+ return val;
314
+ if (typeof val === "object" && val !== null && typeof val.apply === "function") {
315
+ return val.apply((v) => resolveChain(v, accs));
316
+ }
317
+ if (typeof head === "number" && Array.isArray(val)) {
318
+ return resolveChain(val[head], tail);
319
+ }
320
+ if (typeof head === "string" && typeof val === "object" && val !== null) {
321
+ return resolveChain(val[head], tail);
322
+ }
323
+ return undefined;
324
+ }
325
+ return resolveChain(outputVal, accessors);
326
+ }
327
+ const regex = /\$\{output:([^.}]+)\.([\w$]+)((?:\[\d+\])?(?:\.[\w$]+)*)\}/g;
328
+ const matches = [...str.matchAll(regex)];
329
+ if (matches.length === 0)
330
+ return str;
331
+ const values = matches.map(match => {
332
+ const [, resourceId, outputKey, rest] = match;
333
+ let outputVal;
334
+ try {
335
+ outputVal = (0, resourceMap_1.getResourceOutput)(resourceId, outputKey);
336
+ }
337
+ catch (e) {
338
+ return match[0];
339
+ }
340
+ let chain = rest || "";
341
+ const chainRegex = /(\[\d+\])|\.([\w$]+)/g;
342
+ let m;
343
+ let accessors = [];
344
+ while ((m = chainRegex.exec(chain)) !== null) {
345
+ if (m[1]) {
346
+ accessors.push(Number(m[1].slice(1, -1)));
347
+ }
348
+ else if (m[2]) {
349
+ accessors.push(m[2]);
350
+ }
351
+ }
352
+ function resolveChain(val, accs) {
353
+ if (accs.length === 0)
354
+ return val;
355
+ const [head, ...tail] = accs;
356
+ if (val == null)
357
+ return val;
358
+ if (typeof val === "object" && val !== null && typeof val.apply === "function") {
359
+ return val.apply((v) => resolveChain(v, accs));
360
+ }
361
+ if (typeof head === "number" && Array.isArray(val)) {
362
+ return resolveChain(val[head], tail);
363
+ }
364
+ if (typeof head === "string" && typeof val === "object" && val !== null) {
365
+ return resolveChain(val[head], tail);
366
+ }
367
+ return undefined;
368
+ }
369
+ return resolveChain(outputVal, accessors);
370
+ });
371
+ if (values.some(v => typeof v === "object" && v !== null && typeof v.apply === "function")) {
372
+ return pulumi.all(values).apply((resolvedValues) => {
373
+ let result = str;
374
+ matches.forEach((match, i) => {
375
+ const valueStr = typeof resolvedValues[i] === 'object' && resolvedValues[i] !== null
376
+ ? JSON.stringify(resolvedValues[i])
377
+ : String(resolvedValues[i]);
378
+ result = result.replace(match[0], valueStr);
379
+ });
380
+ return result;
381
+ });
382
+ }
383
+ else {
384
+ let result = str;
385
+ matches.forEach((match, i) => {
386
+ const valueStr = typeof values[i] === 'object' && values[i] !== null
387
+ ? JSON.stringify(values[i])
388
+ : String(values[i]);
389
+ result = result.replace(match[0], valueStr);
390
+ });
391
+ return result;
392
+ }
393
+ }
394
+ isMetaPattern(str) {
395
+ return /\$\{meta\.[^}]+\}/.test(str);
396
+ }
397
+ resolveMetaPattern(str) {
398
+ if (this.config && this.config.meta) {
399
+ const fullMatch = str.match(/^\$\{meta\.([^}]+)\}$/);
400
+ if (fullMatch) {
401
+ const keyPath = fullMatch[1];
402
+ const parts = keyPath.split(/\.|\/+?/);
403
+ let val = this.config.meta;
404
+ for (const part of parts) {
405
+ if (val == null)
406
+ break;
407
+ val = val[part];
408
+ }
409
+ return typeof val !== "undefined" ? val : "";
410
+ }
411
+ return str.replace(/\$\{meta\.([^}]+)\}/g, (_, keyPath) => {
412
+ const parts = keyPath.split(/\.|\/+?/);
413
+ let val = this.config.meta;
414
+ for (const part of parts) {
415
+ if (val == null)
416
+ break;
417
+ val = val[part];
418
+ }
419
+ return typeof val !== "undefined" ? String(val) : "";
420
+ });
421
+ }
422
+ return str;
423
+ }
424
+ isIdPattern(str) {
425
+ return /\$\{id\}/.test(str);
426
+ }
427
+ resolveIdPattern(str) {
428
+ let idVal = "";
429
+ if (this.config && typeof this.config.id === "string") {
430
+ idVal = this.config.id;
431
+ }
432
+ return str.replace(/\$\{id\}/g, idVal);
433
+ }
434
+ isSecretPattern(str) {
435
+ return /\$\{secret:[^:}]+:[^}]+\}/.test(str);
436
+ }
437
+ resolveSecretPattern(str) {
438
+ const match = str.match(/\$\{secret:([^:}]+):([^}]+)\}(.*)$/);
439
+ if (match) {
440
+ const [_, secretId, key, suffix] = match;
441
+ const secretResource = this.deployedResources[secretId] || this.resourceOutputs[secretId];
442
+ if (secretResource && secretResource[key]) {
443
+ return secretResource[key] + (suffix || '');
444
+ }
445
+ return str;
446
+ }
447
+ return str;
448
+ }
449
+ async resolveSecretPatternAsync(str, region) {
450
+ const secretPattern = /\$\{secret:([^:}]+):([^}]+)\}/g;
451
+ const matches = Array.from(str.matchAll(secretPattern));
452
+ if (matches.length === 0) {
453
+ return str;
454
+ }
455
+ let result = str;
456
+ for (const match of matches) {
457
+ const [fullMatch, secretId, key] = match;
458
+ let resolvedValue = '';
459
+ const secretResource = this.deployedResources[secretId] || this.resourceOutputs[secretId];
460
+ if (secretResource && secretResource[key]) {
461
+ console.log(`Resolved secret key ${key} from local resources for secret ${secretId}`);
462
+ resolvedValue = secretResource[key];
463
+ }
464
+ else {
465
+ try {
466
+ const awsRegion = region || this.config?.providers?.default?.region || 'us-east-1';
467
+ const secretVersion = await aws.secretsmanager.getSecretVersion({
468
+ secretId: secretId,
469
+ });
470
+ if (secretVersion && secretVersion.secretString) {
471
+ let parsed;
472
+ try {
473
+ parsed = JSON.parse(secretVersion.secretString);
474
+ }
475
+ catch (e) {
476
+ parsed = { [key]: secretVersion.secretString };
477
+ }
478
+ if (key in parsed) {
479
+ resolvedValue = parsed[key];
480
+ }
481
+ else {
482
+ console.warn(`Secret key ${key} not found in AWS Secrets Manager secret ${secretId}. Available keys: ${Object.keys(parsed).join(', ')}`);
483
+ resolvedValue = fullMatch;
484
+ }
485
+ }
486
+ else {
487
+ resolvedValue = fullMatch;
488
+ }
489
+ }
490
+ catch (error) {
491
+ console.warn(`Failed to fetch secret ${secretId} from AWS Secrets Manager:`, error.message);
492
+ if (error.message && error.message.includes('ResourceNotFoundException')) {
493
+ console.warn(`Secret ${secretId} does not exist in AWS Secrets Manager`);
494
+ }
495
+ else if (error.message && (error.message.includes('UnauthorizedOperation') || error.message.includes('AccessDenied'))) {
496
+ console.warn(`Access denied when trying to fetch secret ${secretId}. Check IAM permissions.`);
497
+ }
498
+ resolvedValue = fullMatch;
499
+ }
500
+ }
501
+ result = result.replace(fullMatch, resolvedValue);
502
+ }
503
+ return result;
504
+ }
505
+ async deployResource(category, resourceKey, resourceConfig) {
506
+ const factory = this.factories.get(resourceKey);
507
+ if (!factory)
508
+ throw new Error(`No factory registered for resource type: ${resourceKey}`);
509
+ let resolvedConfig;
510
+ if (resourceConfig && typeof resourceConfig === 'object') {
511
+ resolvedConfig = { ...resourceConfig };
512
+ if (resourceConfig.configuration) {
513
+ resolvedConfig.configuration = await this.resolveOutputsDeep(resourceConfig.configuration);
514
+ }
515
+ if (resourceConfig.inputs) {
516
+ resolvedConfig.inputs = await this.resolveOutputsDeep(resourceConfig.inputs);
517
+ if (typeof resolvedConfig.inputs.providers === "string") {
518
+ const provName = resolvedConfig.inputs.providers;
519
+ if (this.providers[provName]) {
520
+ resolvedConfig.inputs.providers = { [provName]: this.providers[provName] };
521
+ }
522
+ else {
523
+ console.warn(`[DynamicResourceManager] Provider '${provName}' not found in registry, cannot inject into inputs.providers`);
524
+ }
525
+ }
526
+ }
527
+ }
528
+ else {
529
+ resolvedConfig = await this.resolveOutputsDeep(resourceConfig);
530
+ }
531
+ resolvedConfig.meta = this.config.meta;
532
+ if (resourceKey === "l3_auroraFactory" && resolvedConfig.configuration && resolvedConfig.configuration.finalSnapshotIdentifier) { }
533
+ let provider = undefined;
534
+ const providerName = resourceConfig.provider || "default";
535
+ if (providerName !== "default") {
536
+ provider = this.providers[providerName];
537
+ if (!provider)
538
+ throw new Error(`Provider '${providerName}' is not defined in config.providers`);
539
+ }
540
+ factory.validateConfig(resolvedConfig);
541
+ if (factory.constructor.supportsProviderRegistry === true) {
542
+ const resource = await factory.createResource(resolvedConfig, provider, this.providers);
543
+ const outputsConfig = resourceConfig.outputs || {};
544
+ const allOutputs = factory.getOutputs(resource);
545
+ const filteredOutputs = {};
546
+ for (const key of Object.keys(outputsConfig)) {
547
+ filteredOutputs[key] = allOutputs[key];
548
+ }
549
+ this.resourceOutputs[resourceConfig.id] = filteredOutputs;
550
+ return filteredOutputs;
551
+ }
552
+ else {
553
+ const resource = provider
554
+ ? await factory.createResource(resolvedConfig, provider)
555
+ : await factory.createResource(resolvedConfig);
556
+ const outputsConfig = resourceConfig.outputs || {};
557
+ const allOutputs = factory.getOutputs(resource);
558
+ const filteredOutputs = {};
559
+ for (const key of Object.keys(outputsConfig)) {
560
+ filteredOutputs[key] = allOutputs[key];
561
+ }
562
+ this.resourceOutputs[resourceConfig.id] = filteredOutputs;
563
+ return filteredOutputs;
564
+ }
565
+ }
566
+ flattenResources() {
567
+ const flat = [];
568
+ const resourceTypes = Array.from(this.factories.keys());
569
+ function recurse(obj, category) {
570
+ if (Array.isArray(obj)) {
571
+ for (const item of obj) {
572
+ recurse(item, category);
573
+ }
574
+ }
575
+ else if (obj && typeof obj === "object") {
576
+ for (const [key, value] of Object.entries(obj)) {
577
+ if (resourceTypes.includes(key) && Array.isArray(value)) {
578
+ for (const resourceConfig of value) {
579
+ flat.push({ category, resourceKey: key, config: resourceConfig });
580
+ }
581
+ }
582
+ else if (typeof value === "object" && value !== null) {
583
+ recurse(value, category);
584
+ }
585
+ }
586
+ }
587
+ }
588
+ for (const [category, resources] of Object.entries(this.config)) {
589
+ if (category === "meta")
590
+ continue;
591
+ recurse(resources, category);
592
+ }
593
+ return flat;
594
+ }
595
+ topoSortResources(resources) {
596
+ const sorted = [];
597
+ const visited = new Set();
598
+ const temp = new Set();
599
+ const byId = Object.fromEntries(resources.map(r => [r.config.id, r]));
600
+ function visit(res) {
601
+ if (visited.has(res.config.id))
602
+ return;
603
+ if (temp.has(res.config.id))
604
+ throw new Error(`Cyclic dependency detected for resource ${res.config.id}`);
605
+ temp.add(res.config.id);
606
+ const deps = res.config.dependsOn || [];
607
+ for (const depId of deps) {
608
+ if (byId[depId])
609
+ visit(byId[depId]);
610
+ }
611
+ temp.delete(res.config.id);
612
+ visited.add(res.config.id);
613
+ sorted.push(res);
614
+ }
615
+ for (const res of resources) {
616
+ visit(res);
617
+ }
618
+ return sorted;
619
+ }
620
+ async deployResources() {
621
+ const flatResources = this.flattenResources();
622
+ const sortedResources = this.topoSortResources(flatResources);
623
+ for (const { category, resourceKey, config } of sortedResources) {
624
+ let resolvedEnabled = config.enabled;
625
+ if (typeof config.enabled === "string" && this.isMetaPattern(config.enabled)) {
626
+ resolvedEnabled = this.resolveMetaPattern(config.enabled);
627
+ }
628
+ config.enabled = resolvedEnabled;
629
+ if (!config.enabled) {
630
+ continue;
631
+ }
632
+ if (this.deployedResources[config.id] || globalResourceRegistry.has(config.id)) {
633
+ console.warn(`Resource with ID ${config.id} is already deployed. Skipping.`);
634
+ continue;
635
+ }
636
+ if (config.dependsOn) {
637
+ let skip = false;
638
+ for (const dependency of config.dependsOn) {
639
+ if (!this.deployedResources[dependency]) {
640
+ console.warn(`Dependency ${dependency} for resource ${config.id} is not ready. Skipping.`);
641
+ skip = true;
642
+ break;
643
+ }
644
+ }
645
+ if (skip)
646
+ continue;
647
+ }
648
+ try {
649
+ const resource = await this.deployResource(category, resourceKey, config);
650
+ this.deployedResources[config.id] = resource;
651
+ globalResourceRegistry.add(config.id);
652
+ const outputs = Object.keys(config.outputs || {});
653
+ if (outputs.length > 0) {
654
+ (0, resourceMap_1.registerResource)(config.id, resource, outputs);
655
+ }
656
+ }
657
+ catch (error) {
658
+ console.error(`Failed to deploy resource ${config.id}:`, error);
659
+ }
660
+ }
661
+ }
662
+ registerResources() {
663
+ Object.entries(this.deployedResources).forEach(([resourceId, resource]) => {
664
+ const resourceConfig = this.findResourceConfigById(resourceId);
665
+ if (!resourceConfig) {
666
+ console.error(`Error: Resource configuration for ${resourceId} not found. Skipping registration.`);
667
+ return;
668
+ }
669
+ const outputs = Object.keys(resourceConfig.outputs || {});
670
+ if (outputs.length === 0) {
671
+ console.warn(`Warning: No outputs defined for resource ${resourceId}.`);
672
+ }
673
+ if (!resource) {
674
+ console.error(`Error: Resource ${resourceId} is undefined and cannot be registered.`);
675
+ return;
676
+ }
677
+ (0, resourceMap_1.registerResource)(resourceId, resource, outputs);
678
+ });
679
+ }
680
+ getConfig() {
681
+ return this.config;
682
+ }
683
+ getAllDeployedResources() {
684
+ return this.deployedResources;
685
+ }
686
+ findResourceConfigById(resourceId) {
687
+ function search(obj) {
688
+ if (Array.isArray(obj)) {
689
+ for (const item of obj) {
690
+ const found = search(item);
691
+ if (found)
692
+ return found;
693
+ }
694
+ }
695
+ else if (obj && typeof obj === "object") {
696
+ if (obj.id === resourceId)
697
+ return obj;
698
+ for (const value of Object.values(obj)) {
699
+ const found = search(value);
700
+ if (found)
701
+ return found;
702
+ }
703
+ }
704
+ return undefined;
705
+ }
706
+ return search(this.config);
707
+ }
708
+ }
709
+ exports.DynamicResourceManager = DynamicResourceManager;