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,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SavingsPlanFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const processSavingsPlans_1 = require("./processSavingsPlans");
6
+ const processReservedInstances_1 = require("./processReservedInstances");
7
+ class SavingsPlanFactory extends resourceFactory_1.ResourceFactory {
8
+ async createResource(config) {
9
+ if (config.hooks?.beforeCreateResources)
10
+ await config.hooks.beforeCreateResources(config);
11
+ const resources = {};
12
+ resources.savingsPlans = (0, processSavingsPlans_1.processSavingsPlans)(config.configuration.savingsPlans);
13
+ resources.reservedInstances = (0, processReservedInstances_1.processReservedInstances)(config.configuration.reservedInstances);
14
+ if (config.hooks?.afterCreateResources)
15
+ await config.hooks.afterCreateResources(resources, config);
16
+ return resources;
17
+ }
18
+ getOutputs(resource) {
19
+ return resource;
20
+ }
21
+ validateConfig(config) {
22
+ if (!config.configuration)
23
+ throw new Error("SavingsPlanFactoryConfig must include configuration block");
24
+ }
25
+ }
26
+ exports.SavingsPlanFactory = SavingsPlanFactory;
@@ -0,0 +1,107 @@
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.SecretsManagerFactory = void 0;
37
+ const pulumi = __importStar(require("@pulumi/pulumi"));
38
+ const resourceFactory_1 = require("./resourceFactory");
39
+ const validateSecretsManagerConfig_1 = require("./validateSecretsManagerConfig");
40
+ const createAwsSecret_1 = require("./createAwsSecret");
41
+ const createAwsSecretRotation_1 = require("./createAwsSecretRotation");
42
+ const createAwsSecretVersion_1 = require("./createAwsSecretVersion");
43
+ class SecretsManagerFactory extends resourceFactory_1.ResourceFactory {
44
+ async createResource(config, provider) {
45
+ (0, validateSecretsManagerConfig_1.validateSecretsManagerConfig)(config);
46
+ const { configuration } = config;
47
+ if (configuration.meta || configuration.notes) {
48
+ console.warn("[SecretsManagerFactory] 'meta' and 'notes' are for documentation only and will not be passed to the resource.");
49
+ }
50
+ const opts = provider ? { provider } : undefined;
51
+ const secret = (0, createAwsSecret_1.createAwsSecret)(configuration.name, {
52
+ name: configuration.name,
53
+ description: configuration.description,
54
+ kmsKeyId: configuration.kmsKeyId,
55
+ policy: configuration.policy ? JSON.stringify(configuration.policy) : undefined,
56
+ recoveryWindowInDays: configuration.recoveryWindowInDays,
57
+ forceOverwriteReplicaSecret: configuration.forceOverwriteReplicaSecret,
58
+ replicas: configuration.replica,
59
+ tags: configuration.tags,
60
+ }, opts);
61
+ if (configuration.rotationLambdaArn) {
62
+ (0, createAwsSecretRotation_1.createAwsSecretRotation)(`${configuration.name}-rotation`, {
63
+ secretId: secret.id,
64
+ rotationLambdaArn: configuration.rotationLambdaArn,
65
+ rotationRules: configuration.rotationRules,
66
+ }, opts);
67
+ }
68
+ if (configuration.secretString) {
69
+ const secretStringValue = this.resolveSecretString(configuration.secretString);
70
+ (0, createAwsSecretVersion_1.createAwsSecretVersion)(`${configuration.name}-version`, {
71
+ secretId: secret.id,
72
+ secretString: secretStringValue,
73
+ }, opts);
74
+ }
75
+ return secret;
76
+ }
77
+ resolveSecretString(secretString) {
78
+ const values = Object.values(secretString);
79
+ const hasOutputs = values.some(value => typeof value === 'object' &&
80
+ value !== null &&
81
+ typeof value.apply === 'function');
82
+ if (hasOutputs) {
83
+ const keys = Object.keys(secretString);
84
+ const outputValues = Object.values(secretString);
85
+ return pulumi.all(outputValues).apply((resolvedValues) => {
86
+ const resolvedObject = {};
87
+ keys.forEach((key, index) => {
88
+ resolvedObject[key] = resolvedValues[index];
89
+ });
90
+ return JSON.stringify(resolvedObject);
91
+ });
92
+ }
93
+ else {
94
+ return JSON.stringify(secretString);
95
+ }
96
+ }
97
+ getOutputs(resource) {
98
+ return {
99
+ arn: resource.arn,
100
+ name: resource.name,
101
+ };
102
+ }
103
+ validateConfig(config) {
104
+ (0, validateSecretsManagerConfig_1.validateSecretsManagerConfig)(config);
105
+ }
106
+ }
107
+ exports.SecretsManagerFactory = SecretsManagerFactory;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SecurityGroupFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const validateSecurityGroupConfig_1 = require("./validateSecurityGroupConfig");
6
+ const createAwsSecurityGroup_1 = require("./createAwsSecurityGroup");
7
+ class SecurityGroupFactory extends resourceFactory_1.ResourceFactory {
8
+ async createResource(config, provider) {
9
+ (0, validateSecurityGroupConfig_1.validateSecurityGroupConfig)(config);
10
+ const name = config.configuration.name || `${config.meta.environment}-${config.id}`;
11
+ const opts = provider ? { provider } : undefined;
12
+ return (0, createAwsSecurityGroup_1.createAwsSecurityGroup)(name, {
13
+ vpcId: config.inputs.vpcId || config.configuration.vpcId,
14
+ description: config.inputs.description || config.configuration.description,
15
+ tags: config.inputs.tags || config.configuration.tags,
16
+ ingress: config.configuration.ingress,
17
+ egress: config.configuration.egress,
18
+ revokeRulesOnDelete: config.configuration.revokeRulesOnDelete,
19
+ }, opts);
20
+ }
21
+ getOutputs(resource) {
22
+ return { id: resource.id };
23
+ }
24
+ validateConfig(config) {
25
+ (0, validateSecurityGroupConfig_1.validateSecurityGroupConfig)(config);
26
+ }
27
+ }
28
+ exports.SecurityGroupFactory = SecurityGroupFactory;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SecurityGroupRuleFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const validateSecurityGroupRuleConfig_1 = require("./validateSecurityGroupRuleConfig");
6
+ const createAwsSecurityGroupRule_1 = require("./createAwsSecurityGroupRule");
7
+ class SecurityGroupRuleFactory extends resourceFactory_1.ResourceFactory {
8
+ async createResource(config, provider) {
9
+ (0, validateSecurityGroupRuleConfig_1.validateSecurityGroupRuleConfig)(config);
10
+ const name = `${config.meta.environment}-${config.id}`;
11
+ const c = config.configuration;
12
+ const opts = provider ? { provider } : undefined;
13
+ return (0, createAwsSecurityGroupRule_1.createAwsSecurityGroupRule)(name, {
14
+ securityGroupId: config.inputs.securityGroupId || c.securityGroupId,
15
+ type: config.inputs.type || c.type,
16
+ fromPort: config.inputs.fromPort || c.fromPort,
17
+ toPort: config.inputs.toPort || c.toPort,
18
+ protocol: config.inputs.protocol || c.protocol,
19
+ cidrBlocks: config.inputs.cidrBlocks || c.cidrBlocks,
20
+ ipv6CidrBlocks: c.ipv6CidrBlocks,
21
+ prefixListIds: c.prefixListIds,
22
+ self: c.self,
23
+ sourceSecurityGroupId: config.inputs.sourceSecurityGroupId || c.sourceSecurityGroupId,
24
+ description: c.description,
25
+ }, opts);
26
+ }
27
+ getOutputs(resource) {
28
+ return {
29
+ id: resource.id,
30
+ securityGroupId: resource.securityGroupId,
31
+ type: resource.type,
32
+ fromPort: resource.fromPort,
33
+ toPort: resource.toPort,
34
+ protocol: resource.protocol,
35
+ cidrBlocks: resource.cidrBlocks,
36
+ sourceSecurityGroupId: resource.sourceSecurityGroupId,
37
+ };
38
+ }
39
+ validateConfig(config) {
40
+ (0, validateSecurityGroupRuleConfig_1.validateSecurityGroupRuleConfig)(config);
41
+ }
42
+ }
43
+ exports.SecurityGroupRuleFactory = SecurityGroupRuleFactory;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SecurityHubFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const createAwsSecurityHubAccount_1 = require("./createAwsSecurityHubAccount");
6
+ const createAwsSecurityHubStandardsSubscription_1 = require("./createAwsSecurityHubStandardsSubscription");
7
+ const createAwsSecurityHubStandardsControl_1 = require("./createAwsSecurityHubStandardsControl");
8
+ const createAwsSecurityHubAutomationRule_1 = require("./createAwsSecurityHubAutomationRule");
9
+ class SecurityHubFactory extends resourceFactory_1.ResourceFactory {
10
+ async createResource(config) {
11
+ if (config.hooks?.beforeCreateResources)
12
+ await config.hooks.beforeCreateResources(config);
13
+ const resources = {};
14
+ resources.account = (0, createAwsSecurityHubAccount_1.createAwsSecurityHubAccount)(config.id);
15
+ if (config.configuration.standards) {
16
+ resources.standards = config.configuration.standards.map(std => (0, createAwsSecurityHubStandardsSubscription_1.createAwsSecurityHubStandardsSubscription)(std, [resources.account]));
17
+ }
18
+ if (config.configuration.controls) {
19
+ resources.controls = config.configuration.controls.map(ctrl => (0, createAwsSecurityHubStandardsControl_1.createAwsSecurityHubStandardsControl)(ctrl));
20
+ }
21
+ if (config.configuration.automationRules) {
22
+ resources.automationRules = config.configuration.automationRules.map(rule => (0, createAwsSecurityHubAutomationRule_1.createAwsSecurityHubAutomationRule)(rule));
23
+ }
24
+ if (config.hooks?.afterCreateResources)
25
+ await config.hooks.afterCreateResources(resources, config);
26
+ return resources;
27
+ }
28
+ getOutputs(resources) {
29
+ const outputs = {};
30
+ if (resources.account) {
31
+ outputs.accountId = resources.account.id;
32
+ outputs.hubArn = resources.account.hubArn;
33
+ }
34
+ if (resources.standardsSubscriptions && resources.standardsSubscriptions.length > 0) {
35
+ outputs.standardsArns = resources.standardsSubscriptions.map((sub) => sub.standardsArn);
36
+ outputs.standardsSubscriptionArns = resources.standardsSubscriptions.map((sub) => sub.standardsSubscriptionArn);
37
+ }
38
+ if (resources.standardsControls && resources.standardsControls.length > 0) {
39
+ outputs.controlArns = resources.standardsControls.map((control) => control.standardsControlArn);
40
+ outputs.controlStatuses = resources.standardsControls.map((control) => control.controlStatus);
41
+ }
42
+ if (resources.automationRules && resources.automationRules.length > 0) {
43
+ outputs.automationRuleArns = resources.automationRules.map((rule) => rule.ruleArn);
44
+ outputs.automationRuleNames = resources.automationRules.map((rule) => rule.ruleName);
45
+ }
46
+ return outputs;
47
+ }
48
+ validateConfig(config) {
49
+ if (!config.id) {
50
+ throw new Error("SecurityHub factory configuration must include an 'id'");
51
+ }
52
+ if (!config.configuration) {
53
+ throw new Error("SecurityHub factory configuration must include a 'configuration' object");
54
+ }
55
+ if (config.configuration.standards) {
56
+ config.configuration.standards.forEach((standard, index) => {
57
+ if (!standard.standardsArn) {
58
+ throw new Error(`SecurityHub standard at index ${index} must specify standardsArn`);
59
+ }
60
+ if (!standard.name) {
61
+ throw new Error(`SecurityHub standard at index ${index} must specify name`);
62
+ }
63
+ });
64
+ }
65
+ if (config.configuration.controls) {
66
+ config.configuration.controls.forEach((control, index) => {
67
+ if (!control.standardsControlArn) {
68
+ throw new Error(`SecurityHub control at index ${index} must specify standardsControlArn`);
69
+ }
70
+ if (!control.controlStatus || !["ENABLED", "DISABLED"].includes(control.controlStatus)) {
71
+ throw new Error(`SecurityHub control '${control.standardsControlArn}' must have controlStatus of 'ENABLED' or 'DISABLED'`);
72
+ }
73
+ if (control.controlStatus === "DISABLED" && !control.disabledReason) {
74
+ throw new Error(`SecurityHub control '${control.standardsControlArn}' with DISABLED status must specify disabledReason`);
75
+ }
76
+ });
77
+ }
78
+ if (config.configuration.automationRules) {
79
+ config.configuration.automationRules.forEach((rule, index) => {
80
+ if (!rule.ruleName) {
81
+ throw new Error(`SecurityHub automation rule at index ${index} must specify ruleName`);
82
+ }
83
+ if (typeof rule.ruleOrder !== 'number' || rule.ruleOrder < 1 || rule.ruleOrder > 1000) {
84
+ throw new Error(`SecurityHub automation rule '${rule.ruleName}' must have ruleOrder between 1 and 1000`);
85
+ }
86
+ if (!rule.criteria || typeof rule.criteria !== 'object') {
87
+ throw new Error(`SecurityHub automation rule '${rule.ruleName}' must specify criteria object`);
88
+ }
89
+ if (!rule.actions || !Array.isArray(rule.actions) || rule.actions.length === 0) {
90
+ throw new Error(`SecurityHub automation rule '${rule.ruleName}' must specify actions array with at least one action`);
91
+ }
92
+ });
93
+ }
94
+ }
95
+ }
96
+ exports.SecurityHubFactory = SecurityHubFactory;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SesDomainDkimFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const validateSesDomainDkimConfig_1 = require("./validateSesDomainDkimConfig");
6
+ const createAwsSesDomainDkim_1 = require("./createAwsSesDomainDkim");
7
+ class SesDomainDkimFactory extends resourceFactory_1.ResourceFactory {
8
+ async createResource(config) {
9
+ (0, validateSesDomainDkimConfig_1.validateSesDomainDkimConfig)(config);
10
+ return (0, createAwsSesDomainDkim_1.createAwsSesDomainDkim)(config.configuration.domain, {
11
+ domain: config.configuration.domain,
12
+ });
13
+ }
14
+ getOutputs(resource) {
15
+ return {
16
+ id: resource.id,
17
+ dkimTokens: resource.dkimTokens,
18
+ domain: resource.domain,
19
+ };
20
+ }
21
+ validateConfig(config) {
22
+ (0, validateSesDomainDkimConfig_1.validateSesDomainDkimConfig)(config);
23
+ }
24
+ }
25
+ exports.SesDomainDkimFactory = SesDomainDkimFactory;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SesFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const validateSesDomainIdentityConfig_1 = require("./validateSesDomainIdentityConfig");
6
+ const createAwsSesDomainIdentity_1 = require("./createAwsSesDomainIdentity");
7
+ class SesFactory extends resourceFactory_1.ResourceFactory {
8
+ async createResource(config) {
9
+ (0, validateSesDomainIdentityConfig_1.validateSesDomainIdentityConfig)(config);
10
+ return (0, createAwsSesDomainIdentity_1.createAwsSesDomainIdentity)(config.configuration.domain, {
11
+ domain: config.configuration.domain,
12
+ });
13
+ }
14
+ getOutputs(resource) {
15
+ return {
16
+ id: resource.id,
17
+ arn: resource.arn,
18
+ domain: resource.domain,
19
+ };
20
+ }
21
+ validateConfig(config) {
22
+ (0, validateSesDomainIdentityConfig_1.validateSesDomainIdentityConfig)(config);
23
+ }
24
+ }
25
+ exports.SesFactory = SesFactory;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SesIdentitiesFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const createAwsSesDomainIdentity_1 = require("./createAwsSesDomainIdentity");
6
+ const createAwsSesEmailIdentity_1 = require("./createAwsSesEmailIdentity");
7
+ const createAwsSesDomainDkim_1 = require("./createAwsSesDomainDkim");
8
+ const createAwsRoute53Record_1 = require("./createAwsRoute53Record");
9
+ class SesIdentitiesFactory extends resourceFactory_1.ResourceFactory {
10
+ static supportsProviderRegistry = true;
11
+ async createResource(config, provider, providerRegistry = {}) {
12
+ if (!config.configuration) {
13
+ throw new Error("SES Identities configuration is required");
14
+ }
15
+ if (!config.configuration.domains && !config.configuration.emails) {
16
+ throw new Error("At least one domain or email identity must be specified");
17
+ }
18
+ const getRoute53Provider = () => {
19
+ const route53Provider = config.inputs?.route53Provider;
20
+ let selectedProvider;
21
+ if (!route53Provider)
22
+ selectedProvider = provider;
23
+ else if (typeof route53Provider === "object" && route53Provider !== null)
24
+ selectedProvider = route53Provider;
25
+ else if (typeof route53Provider === "string" && providerRegistry && providerRegistry[route53Provider])
26
+ selectedProvider = providerRegistry[route53Provider];
27
+ else {
28
+ throw new Error(`route53Provider='${route53Provider}' is not found in providerRegistry. Available keys: ${Object.keys(providerRegistry).join(", ")}. Must be an aws.Provider object or a valid provider name string for cross-account Route53 access.`);
29
+ }
30
+ return selectedProvider;
31
+ };
32
+ const resources = {
33
+ domainIdentities: [],
34
+ emailIdentities: [],
35
+ dkimResources: [],
36
+ dnsRecords: []
37
+ };
38
+ if (config.configuration.domains) {
39
+ for (const domainConfig of config.configuration.domains) {
40
+ const domainIdentity = (0, createAwsSesDomainIdentity_1.createAwsSesDomainIdentity)(`${config.id}-domain-${domainConfig.domain.replace(/\./g, '-')}`, {
41
+ domain: domainConfig.domain,
42
+ });
43
+ resources.domainIdentities.push(domainIdentity);
44
+ if (domainConfig.enableDkim !== false) {
45
+ const dkim = (0, createAwsSesDomainDkim_1.createAwsSesDomainDkim)(`${config.id}-dkim-${domainConfig.domain.replace(/\./g, '-')}`, {
46
+ domain: domainConfig.domain,
47
+ });
48
+ resources.dkimResources.push(dkim);
49
+ if (config.configuration.dnsConfiguration?.autoCreateRecords && config.inputs?.hostedZoneId) {
50
+ const recordProvider = domainConfig.crossAccountDns ? getRoute53Provider() : provider;
51
+ for (let i = 0; i < 3; i++) {
52
+ const dkimRecord = (0, createAwsRoute53Record_1.createAwsRoute53Record)(`${config.id}-dkim-${i}-${domainConfig.domain.replace(/\./g, '-')}`, {
53
+ zoneId: config.inputs.hostedZoneId,
54
+ name: dkim.dkimTokens.apply(tokens => `${tokens[i]}._domainkey.${domainConfig.domain}`),
55
+ type: "CNAME",
56
+ ttl: config.configuration.dnsConfiguration?.ttl || 300,
57
+ records: [dkim.dkimTokens.apply(tokens => `${tokens[i]}.dkim.amazonses.com`)],
58
+ allowOverwrite: true,
59
+ }, recordProvider);
60
+ resources.dnsRecords.push(dkimRecord);
61
+ }
62
+ }
63
+ }
64
+ if (domainConfig.enableSpf && config.configuration.dnsConfiguration?.autoCreateRecords && config.inputs?.hostedZoneId) {
65
+ const recordProvider = domainConfig.crossAccountDns ? getRoute53Provider() : provider;
66
+ const spfRecord = (0, createAwsRoute53Record_1.createAwsRoute53Record)(`${config.id}-spf-${domainConfig.domain.replace(/\./g, '-')}`, {
67
+ zoneId: config.inputs.hostedZoneId,
68
+ name: domainConfig.domain,
69
+ type: "TXT",
70
+ ttl: config.configuration.dnsConfiguration?.ttl || 300,
71
+ records: [domainConfig.spfRecord || "v=spf1 include:amazonses.com ~all"],
72
+ allowOverwrite: true,
73
+ }, recordProvider);
74
+ resources.dnsRecords.push(spfRecord);
75
+ }
76
+ if (domainConfig.enableDmarc && config.configuration.dnsConfiguration?.autoCreateRecords && config.inputs?.hostedZoneId) {
77
+ const recordProvider = domainConfig.crossAccountDns ? getRoute53Provider() : provider;
78
+ const dmarcRecord = (0, createAwsRoute53Record_1.createAwsRoute53Record)(`${config.id}-dmarc-${domainConfig.domain.replace(/\./g, '-')}`, {
79
+ zoneId: config.inputs.hostedZoneId,
80
+ name: `_dmarc.${domainConfig.domain}`,
81
+ type: "TXT",
82
+ ttl: config.configuration.dnsConfiguration?.ttl || 300,
83
+ records: [domainConfig.dmarcPolicy || "v=DMARC1; p=quarantine; rua=mailto:dmarc@" + domainConfig.domain],
84
+ allowOverwrite: true,
85
+ }, recordProvider);
86
+ resources.dnsRecords.push(dmarcRecord);
87
+ }
88
+ if (config.configuration.dnsConfiguration?.autoCreateRecords && config.inputs?.hostedZoneId) {
89
+ const recordProvider = domainConfig.crossAccountDns ? getRoute53Provider() : provider;
90
+ const verificationRecord = (0, createAwsRoute53Record_1.createAwsRoute53Record)(`${config.id}-verification-${domainConfig.domain.replace(/\./g, '-')}`, {
91
+ zoneId: config.inputs.hostedZoneId,
92
+ name: `_amazonses.${domainConfig.domain}`,
93
+ type: "TXT",
94
+ ttl: config.configuration.dnsConfiguration?.ttl || 300,
95
+ records: [domainIdentity.verificationToken],
96
+ allowOverwrite: true,
97
+ }, recordProvider);
98
+ resources.dnsRecords.push(verificationRecord);
99
+ }
100
+ }
101
+ }
102
+ if (config.configuration.emails) {
103
+ for (const emailConfig of config.configuration.emails) {
104
+ const emailIdentity = (0, createAwsSesEmailIdentity_1.createAwsSesEmailIdentity)(`${config.id}-email-${emailConfig.email.replace(/[@\.]/g, '-')}`, {
105
+ email: emailConfig.email,
106
+ });
107
+ resources.emailIdentities.push(emailIdentity);
108
+ }
109
+ }
110
+ return resources;
111
+ }
112
+ getOutputs(resource) {
113
+ return {
114
+ domainIdentityArns: resource.domainIdentities.map(identity => identity.arn),
115
+ emailIdentityArns: resource.emailIdentities.map(identity => identity.arn),
116
+ dkimTokens: resource.dkimResources.map(dkim => dkim.dkimTokens),
117
+ dnsRecords: resource.dnsRecords.map(record => ({
118
+ name: record.name,
119
+ type: record.type,
120
+ records: record.records
121
+ })),
122
+ verificationTokens: resource.domainIdentities.map(identity => identity.verificationToken),
123
+ };
124
+ }
125
+ validateConfig(config) {
126
+ if (!config.configuration) {
127
+ throw new Error("SES Identities configuration is required");
128
+ }
129
+ if (!config.configuration.domains && !config.configuration.emails) {
130
+ throw new Error("At least one domain or email identity must be specified");
131
+ }
132
+ }
133
+ }
134
+ exports.SesIdentitiesFactory = SesIdentitiesFactory;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SimpleNotificationFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const comprehensiveNotificationFactory_1 = require("./comprehensiveNotificationFactory");
6
+ class SimpleNotificationFactory extends resourceFactory_1.ResourceFactory {
7
+ comprehensiveFactory = new comprehensiveNotificationFactory_1.ComprehensiveNotificationFactory();
8
+ validateConfig(config) {
9
+ if (!config.configuration.name) {
10
+ throw new Error("Notification name is required");
11
+ }
12
+ const hasAnyChannel = config.configuration.email ||
13
+ config.configuration.slack ||
14
+ config.configuration.webhookUrl ||
15
+ config.configuration.lambdaArn ||
16
+ config.configuration.phoneNumber;
17
+ if (!hasAnyChannel) {
18
+ throw new Error("At least one notification channel (email, slack, webhook, lambda, or sms) must be configured");
19
+ }
20
+ if (config.configuration.slack && (!config.configuration.slack.workspaceId || !config.configuration.slack.channelId)) {
21
+ throw new Error("Slack workspaceId and channelId are required when Slack is configured");
22
+ }
23
+ }
24
+ async createResource(config, provider) {
25
+ const channels = [];
26
+ if (config.configuration.email) {
27
+ channels.push({
28
+ type: "email",
29
+ enabled: true,
30
+ name: "email",
31
+ configuration: {
32
+ email: config.configuration.email
33
+ },
34
+ tags: config.configuration.tags
35
+ });
36
+ }
37
+ if (config.configuration.slack) {
38
+ channels.push({
39
+ type: "slack",
40
+ enabled: true,
41
+ name: config.configuration.slack.channelName || "slack",
42
+ configuration: {
43
+ slack: {
44
+ workspaceId: config.configuration.slack.workspaceId,
45
+ channelId: config.configuration.slack.channelId,
46
+ loggingLevel: "ERROR"
47
+ }
48
+ },
49
+ tags: config.configuration.tags
50
+ });
51
+ }
52
+ if (config.configuration.webhookUrl) {
53
+ channels.push({
54
+ type: "webhook",
55
+ enabled: true,
56
+ name: "webhook",
57
+ configuration: {
58
+ webhook: {
59
+ url: config.configuration.webhookUrl
60
+ }
61
+ },
62
+ tags: config.configuration.tags
63
+ });
64
+ }
65
+ if (config.configuration.lambdaArn) {
66
+ channels.push({
67
+ type: "lambda",
68
+ enabled: true,
69
+ name: "lambda",
70
+ configuration: {
71
+ lambda: {
72
+ functionArn: config.configuration.lambdaArn
73
+ }
74
+ },
75
+ tags: config.configuration.tags
76
+ });
77
+ }
78
+ if (config.configuration.phoneNumber) {
79
+ channels.push({
80
+ type: "sms",
81
+ enabled: true,
82
+ name: "sms",
83
+ configuration: {
84
+ sms: {
85
+ phoneNumber: config.configuration.phoneNumber
86
+ }
87
+ },
88
+ tags: config.configuration.tags
89
+ });
90
+ }
91
+ const comprehensiveConfig = {
92
+ id: config.id,
93
+ configuration: {
94
+ name: config.configuration.name,
95
+ displayName: config.configuration.displayName,
96
+ description: config.configuration.description,
97
+ channels,
98
+ chatbotRole: config.configuration.slack ? {
99
+ enabled: config.configuration.enableChatbotRole ?? true,
100
+ name: `${config.configuration.name}-chatbot-role`
101
+ } : { enabled: false },
102
+ tags: config.configuration.tags
103
+ },
104
+ inputs: config.inputs
105
+ };
106
+ return await this.comprehensiveFactory.createResource(comprehensiveConfig, provider);
107
+ }
108
+ getOutputs(resource) {
109
+ return this.comprehensiveFactory.getOutputs(resource);
110
+ }
111
+ }
112
+ exports.SimpleNotificationFactory = SimpleNotificationFactory;