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,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDeterministicPriority = getDeterministicPriority;
4
+ function getDeterministicPriority(id, fallback) {
5
+ if (fallback)
6
+ return fallback;
7
+ let hash = 0;
8
+ for (let i = 0; i < id.length; i++) {
9
+ hash = ((hash << 5) - hash) + id.charCodeAt(i);
10
+ hash |= 0;
11
+ }
12
+ return Math.abs(hash % 1000) + 10;
13
+ }
@@ -0,0 +1,57 @@
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.getOrCreateSshKeyPair = getOrCreateSshKeyPair;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ function getOrCreateSshKeyPair(id, keysDir) {
40
+ const privKeyPath = path.join(keysDir, `${id}-bastion`);
41
+ const pubKeyPath = path.join(keysDir, `${id}-bastion.pub`);
42
+ if (fs.existsSync(privKeyPath) && fs.existsSync(pubKeyPath)) {
43
+ return {
44
+ privateKey: fs.readFileSync(privKeyPath, "utf8"),
45
+ publicKey: fs.readFileSync(pubKeyPath, "utf8"),
46
+ };
47
+ }
48
+ const forge = require("node-forge");
49
+ const keypair = forge.pki.rsa.generateKeyPair(2048);
50
+ const privateKey = forge.ssh.privateKeyToOpenSSH(keypair.privateKey);
51
+ const publicKey = forge.ssh.publicKeyToOpenSSH(keypair.publicKey, `${id}-bastion`);
52
+ if (!fs.existsSync(keysDir))
53
+ fs.mkdirSync(keysDir, { recursive: true });
54
+ fs.writeFileSync(privKeyPath, privateKey, { mode: 0o600 });
55
+ fs.writeFileSync(pubKeyPath, publicKey, { mode: 0o644 });
56
+ return { privateKey, publicKey };
57
+ }
@@ -0,0 +1,151 @@
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.GuardDutyFactory = void 0;
37
+ const aws = __importStar(require("@pulumi/aws"));
38
+ const resourceFactory_1 = require("./resourceFactory");
39
+ const createAwsGuardDutyDetectorFeature_1 = require("./createAwsGuardDutyDetectorFeature");
40
+ const createAwsGuardDutyFilter_1 = require("./createAwsGuardDutyFilter");
41
+ const createAwsGuardDutyPublishingDestination_1 = require("./createAwsGuardDutyPublishingDestination");
42
+ class GuardDutyFactory extends resourceFactory_1.ResourceFactory {
43
+ async createResource(config) {
44
+ if (config.hooks?.beforeCreateResources)
45
+ await config.hooks.beforeCreateResources(config);
46
+ const resources = {};
47
+ const detectorConfig = {
48
+ enable: config.configuration.detector?.enable ?? true,
49
+ tags: { ...config.configuration.tags, ...config.configuration.detector?.tags }
50
+ };
51
+ if (config.configuration.detector?.findingPublishingFrequency) {
52
+ detectorConfig.findingPublishingFrequency = config.configuration.detector.findingPublishingFrequency;
53
+ }
54
+ if (config.configuration.detector?.datasources) {
55
+ detectorConfig.datasources = {};
56
+ if (config.configuration.detector.datasources.s3Logs) {
57
+ detectorConfig.datasources.s3Logs = config.configuration.detector.datasources.s3Logs;
58
+ }
59
+ if (config.configuration.detector.datasources.kubernetes) {
60
+ detectorConfig.datasources.kubernetes = config.configuration.detector.datasources.kubernetes;
61
+ }
62
+ }
63
+ resources.detector = new aws.guardduty.Detector(config.id, detectorConfig);
64
+ if (config.configuration.features) {
65
+ resources.features = config.configuration.features.map(f => (0, createAwsGuardDutyDetectorFeature_1.createAwsGuardDutyDetectorFeature)(resources.detector.id, f));
66
+ }
67
+ if (config.configuration.filters) {
68
+ resources.filters = config.configuration.filters.map(filter => (0, createAwsGuardDutyFilter_1.createAwsGuardDutyFilter)(resources.detector.id, filter));
69
+ }
70
+ if (config.configuration.publishingDestinations) {
71
+ resources.publishingDestinations = config.configuration.publishingDestinations.map(dest => {
72
+ if (dest.destinationType === "S3" && !dest.kmsKeyArn) {
73
+ throw new Error(`GuardDuty PublishingDestination of type S3 requires kmsKeyArn (destination: ${dest.name})`);
74
+ }
75
+ return (0, createAwsGuardDutyPublishingDestination_1.createAwsGuardDutyPublishingDestination)(resources.detector.id, dest);
76
+ });
77
+ }
78
+ if (config.hooks?.afterCreateResources)
79
+ await config.hooks.afterCreateResources(resources, config);
80
+ return resources;
81
+ }
82
+ getOutputs(resources) {
83
+ const outputs = {};
84
+ if (resources.detector) {
85
+ outputs.detectorId = resources.detector.id;
86
+ outputs.detectorArn = resources.detector.arn;
87
+ }
88
+ if (resources.features && resources.features.length > 0) {
89
+ outputs.featureNames = resources.features.map((feature) => feature.name);
90
+ }
91
+ if (resources.filters && resources.filters.length > 0) {
92
+ outputs.filterNames = resources.filters.map((filter) => filter.name);
93
+ outputs.filterArns = resources.filters.map((filter) => filter.arn);
94
+ }
95
+ if (resources.publishingDestinations && resources.publishingDestinations.length > 0) {
96
+ outputs.publishingDestinationIds = resources.publishingDestinations.map((dest) => dest.id);
97
+ }
98
+ return outputs;
99
+ }
100
+ validateConfig(config) {
101
+ if (!config.id) {
102
+ throw new Error("GuardDuty factory configuration must include an 'id'");
103
+ }
104
+ if (!config.configuration) {
105
+ throw new Error("GuardDuty factory configuration must include a 'configuration' object");
106
+ }
107
+ if (config.configuration.features) {
108
+ config.configuration.features.forEach((feature, index) => {
109
+ if (!feature.name) {
110
+ throw new Error(`GuardDuty feature at index ${index} must specify name`);
111
+ }
112
+ if (!feature.status || !["ENABLED", "DISABLED"].includes(feature.status)) {
113
+ throw new Error(`GuardDuty feature '${feature.name}' must have status of 'ENABLED' or 'DISABLED'`);
114
+ }
115
+ });
116
+ }
117
+ if (config.configuration.filters) {
118
+ config.configuration.filters.forEach((filter, index) => {
119
+ if (!filter.name) {
120
+ throw new Error(`GuardDuty filter at index ${index} must specify name`);
121
+ }
122
+ if (!filter.action || !["ARCHIVE", "NOOP"].includes(filter.action)) {
123
+ throw new Error(`GuardDuty filter '${filter.name}' must have action of 'ARCHIVE' or 'NOOP'`);
124
+ }
125
+ if (typeof filter.rank !== 'number') {
126
+ throw new Error(`GuardDuty filter '${filter.name}' must specify numeric rank`);
127
+ }
128
+ if (!filter.findingCriteria) {
129
+ throw new Error(`GuardDuty filter '${filter.name}' must include findingCriteria`);
130
+ }
131
+ });
132
+ }
133
+ if (config.configuration.publishingDestinations) {
134
+ config.configuration.publishingDestinations.forEach((dest, index) => {
135
+ if (!dest.name) {
136
+ throw new Error(`GuardDuty publishing destination at index ${index} must specify name`);
137
+ }
138
+ if (!dest.destinationType || !["S3", "SNS"].includes(dest.destinationType)) {
139
+ throw new Error(`GuardDuty publishing destination '${dest.name}' must have destinationType of 'S3' or 'SNS'`);
140
+ }
141
+ if (!dest.destinationArn) {
142
+ throw new Error(`GuardDuty publishing destination '${dest.name}' must specify destinationArn`);
143
+ }
144
+ if (dest.destinationType === "S3" && !dest.kmsKeyArn) {
145
+ throw new Error(`GuardDuty publishing destination '${dest.name}' of type S3 requires kmsKeyArn`);
146
+ }
147
+ });
148
+ }
149
+ }
150
+ }
151
+ exports.GuardDutyFactory = GuardDutyFactory;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HostedZoneFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const validateHostedZoneConfig_1 = require("./validateHostedZoneConfig");
6
+ const createAwsHostedZone_1 = require("./createAwsHostedZone");
7
+ class HostedZoneFactory extends resourceFactory_1.ResourceFactory {
8
+ async createResource(config, provider) {
9
+ (0, validateHostedZoneConfig_1.validateHostedZoneConfig)(config);
10
+ return (0, createAwsHostedZone_1.createAwsHostedZone)(config.configuration.name, {
11
+ name: config.configuration.name,
12
+ comment: config.configuration.comment,
13
+ tags: config.configuration.tags,
14
+ forceDestroy: config.configuration.forceDestroy,
15
+ vpcs: config.configuration.vpc ? [config.configuration.vpc] : undefined,
16
+ delegationSetId: config.configuration.delegationSetId,
17
+ queryLoggingConfig: config.configuration.queryLoggingConfig,
18
+ }, provider);
19
+ }
20
+ getOutputs(resource) {
21
+ return {
22
+ zoneId: resource.zoneId,
23
+ name: resource.name,
24
+ };
25
+ }
26
+ validateConfig(config) {
27
+ (0, validateHostedZoneConfig_1.validateHostedZoneConfig)(config);
28
+ }
29
+ }
30
+ exports.HostedZoneFactory = HostedZoneFactory;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IamRoleFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const validateIamRoleConfig_1 = require("./validateIamRoleConfig");
6
+ const createAwsIamRole_1 = require("./createAwsIamRole");
7
+ const createAwsIamRoleInlinePolicies_1 = require("./createAwsIamRoleInlinePolicies");
8
+ class IamRoleFactory extends resourceFactory_1.ResourceFactory {
9
+ async createResource(config) {
10
+ (0, validateIamRoleConfig_1.validateIamRoleConfig)(config);
11
+ const cfg = config.configuration;
12
+ if (cfg.permissionsBoundaryPolicy && typeof cfg.permissionsBoundaryPolicy === "object") {
13
+ console.warn("[IamRoleFactory] 'permissionsBoundaryPolicy' as object is not supported by Pulumi and will be ignored. Use 'permissionsBoundary' ARN instead.");
14
+ }
15
+ const role = (0, createAwsIamRole_1.createAwsIamRole)(cfg);
16
+ (0, createAwsIamRoleInlinePolicies_1.createAwsIamRoleInlinePolicies)(role, cfg.inlinePolicies);
17
+ return role;
18
+ }
19
+ getOutputs(resource) {
20
+ return {
21
+ arn: resource.arn,
22
+ name: resource.name,
23
+ };
24
+ }
25
+ validateConfig(config) {
26
+ (0, validateIamRoleConfig_1.validateIamRoleConfig)(config);
27
+ }
28
+ }
29
+ exports.IamRoleFactory = IamRoleFactory;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InspectorFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const createAwsInspectorEnabler_1 = require("./createAwsInspectorEnabler");
6
+ const createAwsInspectorAssessmentTarget_1 = require("./createAwsInspectorAssessmentTarget");
7
+ const createAwsInspectorOrganizationConfiguration_1 = require("./createAwsInspectorOrganizationConfiguration");
8
+ const createAwsInspectorDelegatedAdminAccount_1 = require("./createAwsInspectorDelegatedAdminAccount");
9
+ class InspectorFactory extends resourceFactory_1.ResourceFactory {
10
+ async createResource(config) {
11
+ if (config.hooks?.beforeCreateResources)
12
+ await config.hooks.beforeCreateResources(config);
13
+ const resources = {};
14
+ if (config.configuration.resourceTypes && config.configuration.resourceTypes.length > 0) {
15
+ const enabledTypes = config.configuration.resourceTypes
16
+ .filter((rt) => rt.enabled)
17
+ .map((rt) => rt.type);
18
+ if (enabledTypes.length > 0) {
19
+ resources.inspectorEnabler = (0, createAwsInspectorEnabler_1.createAwsInspectorEnabler)(`${config.id}-enabler`, {
20
+ resourceTypes: enabledTypes,
21
+ tags: config.configuration.tags,
22
+ });
23
+ }
24
+ }
25
+ if (config.configuration.organizationConfiguration) {
26
+ resources.organizationConfiguration = (0, createAwsInspectorOrganizationConfiguration_1.createAwsInspectorOrganizationConfiguration)(`${config.id}-org-config`, {
27
+ autoEnable: config.configuration.organizationConfiguration.autoEnable,
28
+ });
29
+ }
30
+ if (config.configuration.delegatedAdminAccount) {
31
+ resources.delegatedAdminAccount = (0, createAwsInspectorDelegatedAdminAccount_1.createAwsInspectorDelegatedAdminAccount)(`${config.id}-delegated-admin`, {
32
+ accountId: config.configuration.delegatedAdminAccount.accountId,
33
+ });
34
+ }
35
+ if (config.configuration.assessmentTargets) {
36
+ resources.assessmentTargets = [];
37
+ for (let i = 0; i < config.configuration.assessmentTargets.length; i++) {
38
+ const target = config.configuration.assessmentTargets[i];
39
+ const assessmentTarget = (0, createAwsInspectorAssessmentTarget_1.createAwsInspectorAssessmentTarget)(`${config.id}-target-${i}`, {
40
+ name: target.name,
41
+ tags: config.configuration.tags,
42
+ });
43
+ resources.assessmentTargets.push(assessmentTarget);
44
+ }
45
+ }
46
+ if (config.hooks?.afterCreateResources) {
47
+ await config.hooks.afterCreateResources(resources, config);
48
+ }
49
+ return resources;
50
+ }
51
+ getOutputs(resources) {
52
+ const outputs = {};
53
+ if (resources.inspectorEnabler) {
54
+ outputs.accountId = resources.inspectorEnabler.accountId;
55
+ outputs.enabledResourceTypes = resources.inspectorEnabler.enabledResourceTypes;
56
+ }
57
+ if (resources.organizationConfiguration) {
58
+ outputs.autoEnableEc2 = resources.organizationConfiguration.autoEnableEc2;
59
+ outputs.autoEnableEcr = resources.organizationConfiguration.autoEnableEcr;
60
+ outputs.autoEnableLambda = resources.organizationConfiguration.autoEnableLambda;
61
+ outputs.autoEnableLambdaCode = resources.organizationConfiguration.autoEnableLambdaCode;
62
+ outputs.maxAccountLimitReached = resources.organizationConfiguration.maxAccountLimitReached;
63
+ }
64
+ if (resources.delegatedAdminAccount) {
65
+ outputs.delegatedAdminAccountId = resources.delegatedAdminAccount.accountId;
66
+ outputs.delegatedAdminRelationshipStatus = resources.delegatedAdminAccount.relationshipStatus;
67
+ }
68
+ if (resources.assessmentTargets && resources.assessmentTargets.length > 0) {
69
+ outputs.assessmentTargetArns = resources.assessmentTargets.map((target) => target.arn);
70
+ outputs.assessmentTargetNames = resources.assessmentTargets.map((target) => target.name);
71
+ }
72
+ return outputs;
73
+ }
74
+ validateConfig(config) {
75
+ if (!config.id) {
76
+ throw new Error("Inspector factory configuration must include an 'id'");
77
+ }
78
+ if (!config.configuration) {
79
+ throw new Error("Inspector factory configuration must include a 'configuration' object");
80
+ }
81
+ if (config.configuration.resourceTypes) {
82
+ const validTypes = ["ECR", "EC2", "LAMBDA", "LAMBDA_CODE"];
83
+ for (const resourceType of config.configuration.resourceTypes) {
84
+ if (!validTypes.includes(resourceType.type)) {
85
+ throw new Error(`Invalid resource type: ${resourceType.type}. Must be one of: ${validTypes.join(", ")}`);
86
+ }
87
+ }
88
+ }
89
+ if (config.configuration.organizationConfiguration) {
90
+ const autoEnable = config.configuration.organizationConfiguration.autoEnable;
91
+ if (typeof autoEnable.ec2 !== 'boolean' || typeof autoEnable.ecr !== 'boolean') {
92
+ throw new Error("Organization auto-enable configuration for EC2 and ECR must be boolean values");
93
+ }
94
+ }
95
+ if (config.configuration.delegatedAdminAccount) {
96
+ if (!config.configuration.delegatedAdminAccount.accountId || !config.configuration.delegatedAdminAccount.accountId.match(/^\d{12}$/)) {
97
+ throw new Error("Delegated admin account ID must be a valid 12-digit AWS account ID");
98
+ }
99
+ }
100
+ if (config.configuration.assessmentTargets) {
101
+ for (const target of config.configuration.assessmentTargets) {
102
+ if (!target.name || target.name.trim().length === 0) {
103
+ throw new Error("Assessment target name cannot be empty");
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ exports.InspectorFactory = InspectorFactory;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KmsKeyFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const validateKmsKeyConfig_1 = require("./validateKmsKeyConfig");
6
+ const createAwsKmsKey_1 = require("./createAwsKmsKey");
7
+ const createAwsKmsAliases_1 = require("./createAwsKmsAliases");
8
+ class KmsKeyFactory extends resourceFactory_1.ResourceFactory {
9
+ async createResource(config) {
10
+ (0, validateKmsKeyConfig_1.validateKmsKeyConfig)(config);
11
+ const cfg = config.configuration;
12
+ if (cfg.grantTokens) {
13
+ console.warn("[KmsKeyFactory] 'grantTokens' is not supported by Pulumi and will be ignored.");
14
+ }
15
+ if (cfg.meta || cfg.notes) {
16
+ console.warn("[KmsKeyFactory] 'meta' and 'notes' are for documentation only and will not be passed to the resource.");
17
+ }
18
+ const key = (0, createAwsKmsKey_1.createAwsKmsKey)(cfg);
19
+ (0, createAwsKmsAliases_1.createAwsKmsAliases)(key, cfg.aliases);
20
+ return key;
21
+ }
22
+ getOutputs(resource) {
23
+ return {
24
+ arn: resource.arn,
25
+ keyId: resource.keyId,
26
+ };
27
+ }
28
+ validateConfig(config) {
29
+ (0, validateKmsKeyConfig_1.validateKmsKeyConfig)(config);
30
+ }
31
+ }
32
+ exports.KmsKeyFactory = KmsKeyFactory;
@@ -0,0 +1,133 @@
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.LambdaFactory = void 0;
37
+ const aws = __importStar(require("@pulumi/aws"));
38
+ const pulumi = __importStar(require("@pulumi/pulumi"));
39
+ const resourceFactory_1 = require("./resourceFactory");
40
+ const createLambdaFunction_1 = require("./createLambdaFunction");
41
+ class LambdaFactory extends resourceFactory_1.ResourceFactory {
42
+ async createResource(config, provider) {
43
+ let vpcConfig = config.configuration.vpcConfig;
44
+ if (config.inputs) {
45
+ if (config.inputs.vpcConfig) {
46
+ vpcConfig = config.inputs.vpcConfig;
47
+ }
48
+ else if (config.inputs.securityGroupIds || config.inputs.subnetIds) {
49
+ vpcConfig = vpcConfig || {};
50
+ if (config.inputs.securityGroupIds)
51
+ vpcConfig.securityGroupIds = config.inputs.securityGroupIds;
52
+ if (config.inputs.subnetIds)
53
+ vpcConfig.subnetIds = config.inputs.subnetIds;
54
+ }
55
+ }
56
+ let codeBucket = config.configuration.codeBucket;
57
+ if (config.inputs && config.inputs.codeBucket) {
58
+ codeBucket = config.inputs.codeBucket;
59
+ }
60
+ let roleArn = config.configuration.roleArn;
61
+ if (!roleArn && config.configuration.iamPolicyStatements) {
62
+ const role = new aws.iam.Role(`${config.meta.environment}-${config.id}-role`, {
63
+ assumeRolePolicy: JSON.stringify({
64
+ Version: "2012-10-17",
65
+ Statement: [{
66
+ Action: "sts:AssumeRole",
67
+ Effect: "Allow",
68
+ Principal: {
69
+ Service: "lambda.amazonaws.com"
70
+ }
71
+ }]
72
+ }),
73
+ tags: config.configuration.tags
74
+ }, provider ? { provider } : undefined);
75
+ new aws.iam.RolePolicyAttachment(`${config.meta.environment}-${config.id}-basic`, {
76
+ role: role.name,
77
+ policyArn: "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
78
+ }, provider ? { provider } : undefined);
79
+ if (vpcConfig) {
80
+ new aws.iam.RolePolicyAttachment(`${config.meta.environment}-${config.id}-vpc`, {
81
+ role: role.name,
82
+ policyArn: "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
83
+ }, provider ? { provider } : undefined);
84
+ }
85
+ if (config.configuration.iamPolicyStatements && config.configuration.iamPolicyStatements.length > 0) {
86
+ const policyDocument = {
87
+ Version: "2012-10-17",
88
+ Statement: config.configuration.iamPolicyStatements
89
+ };
90
+ new aws.iam.RolePolicy(`${config.meta.environment}-${config.id}-policy`, {
91
+ role: role.name,
92
+ policy: pulumi.output(policyDocument).apply(doc => JSON.stringify(doc))
93
+ }, provider ? { provider } : undefined);
94
+ }
95
+ roleArn = role.arn;
96
+ }
97
+ return (0, createLambdaFunction_1.createLambdaFunction)({
98
+ name: config.configuration.functionName || `${config.meta.environment}-${config.id}`,
99
+ handler: config.configuration.handler,
100
+ runtime: config.configuration.runtime,
101
+ codePath: config.configuration.codePath,
102
+ codeBucket: codeBucket,
103
+ roleArn: roleArn,
104
+ environment: config.configuration.environment ? {
105
+ variables: config.configuration.environment
106
+ } : undefined,
107
+ tags: config.configuration.tags,
108
+ vpcConfig,
109
+ timeout: config.configuration.timeout,
110
+ memorySize: config.configuration.memorySize,
111
+ description: config.configuration.description,
112
+ provider,
113
+ });
114
+ }
115
+ getOutputs(resource) {
116
+ return {
117
+ arn: resource.arn,
118
+ name: resource.name,
119
+ functionArn: resource.arn,
120
+ functionName: resource.name,
121
+ invokeUrl: resource.arn.apply(arn => {
122
+ const region = arn.split(':')[3];
123
+ return `https://lambda.${region}.amazonaws.com/2015-03-31/functions/${resource.name}/invocations`;
124
+ }),
125
+ };
126
+ }
127
+ validateConfig(config) {
128
+ if (!config.configuration || !config.configuration.handler || !config.configuration.runtime || !config.configuration.codePath) {
129
+ throw new Error("Lambda config must include configuration with handler, runtime, codePath");
130
+ }
131
+ }
132
+ }
133
+ exports.LambdaFactory = LambdaFactory;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LambdaPermissionFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const createLambdaPermission_1 = require("./createLambdaPermission");
6
+ class LambdaPermissionFactory extends resourceFactory_1.ResourceFactory {
7
+ async createResource(config, provider) {
8
+ return (0, createLambdaPermission_1.TcreateLambdaPermission)({
9
+ name: config.id,
10
+ action: config.configuration.action,
11
+ lambdaArn: config.configuration.function,
12
+ principal: config.configuration.principal,
13
+ sourceArn: config.configuration.sourceArn,
14
+ qualifier: config.inputs?.qualifier,
15
+ eventSourceToken: config.inputs?.eventSourceToken,
16
+ condition: config.inputs?.condition,
17
+ parent: provider,
18
+ });
19
+ }
20
+ getOutputs(resource) {
21
+ return {
22
+ id: resource.id,
23
+ statementId: resource.statementId,
24
+ };
25
+ }
26
+ validateConfig(config) {
27
+ if (!config.configuration || !config.configuration.action || !config.configuration.function || !config.configuration.principal || !config.configuration.sourceArn) {
28
+ throw new Error("LambdaPermissionFactory: action, function, principal, and sourceArn are required");
29
+ }
30
+ }
31
+ }
32
+ exports.LambdaPermissionFactory = LambdaPermissionFactory;