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,193 @@
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.CodePipelineNotificationFactory = void 0;
37
+ const aws = __importStar(require("@pulumi/aws"));
38
+ const pulumi = __importStar(require("@pulumi/pulumi"));
39
+ const resourceFactory_1 = require("./resourceFactory");
40
+ class CodePipelineNotificationFactory extends resourceFactory_1.ResourceFactory {
41
+ validateConfig(config) {
42
+ if (!config.configuration.pipelineName) {
43
+ throw new Error("Pipeline name is required");
44
+ }
45
+ if (!config.configuration.snsTopicArn) {
46
+ throw new Error("SNS topic ARN is required");
47
+ }
48
+ }
49
+ async createResource(config, provider) {
50
+ const { configuration } = config;
51
+ const eventTypes = configuration.eventTypes || [
52
+ "PIPELINE_EXECUTION_STARTED",
53
+ "PIPELINE_EXECUTION_SUCCEEDED",
54
+ "PIPELINE_EXECUTION_FAILED"
55
+ ];
56
+ const eventPattern = configuration.customEventPattern || {
57
+ source: ["aws.codepipeline"],
58
+ "detail-type": this.createDetailTypePattern(eventTypes),
59
+ detail: {
60
+ pipeline: [configuration.pipelineName],
61
+ ...(configuration.stageNames && { stage: configuration.stageNames })
62
+ }
63
+ };
64
+ const ruleName = `${config.id}-events`.substring(0, 64);
65
+ const eventRule = new aws.cloudwatch.EventRule(ruleName, {
66
+ name: ruleName,
67
+ description: `Monitor CodePipeline events for ${configuration.pipelineName}`,
68
+ eventPattern: JSON.stringify(eventPattern),
69
+ state: "ENABLED",
70
+ tags: configuration.tags
71
+ }, provider ? { provider } : undefined);
72
+ let snsTopicPolicy;
73
+ const topicArn = configuration.snsTopicArn;
74
+ snsTopicPolicy = new aws.sns.TopicPolicy(`${config.id}-sns-policy`, {
75
+ arn: topicArn,
76
+ policy: pulumi.interpolate `{
77
+ "Version": "2012-10-17",
78
+ "Statement": [
79
+ {
80
+ "Sid": "AllowCloudWatchEventsToPublish",
81
+ "Effect": "Allow",
82
+ "Principal": {
83
+ "Service": "events.amazonaws.com"
84
+ },
85
+ "Action": "sns:Publish",
86
+ "Resource": "${topicArn}",
87
+ "Condition": {
88
+ "StringEquals": {
89
+ "aws:SourceAccount": "${aws.getCallerIdentity().then(id => id.accountId)}"
90
+ }
91
+ }
92
+ }
93
+ ]
94
+ }`
95
+ }, provider ? { provider } : undefined);
96
+ const eventTarget = new aws.cloudwatch.EventTarget(`${config.id}-sns-target`, {
97
+ rule: eventRule.name,
98
+ targetId: `${config.id}-sns-target`,
99
+ arn: topicArn,
100
+ inputTransformer: configuration.detailType === "Full" ? {
101
+ inputPaths: {
102
+ pipeline: "$.detail.pipeline",
103
+ state: "$.detail.state",
104
+ stage: "$.detail.stage",
105
+ action: "$.detail.action-name",
106
+ region: "$.region",
107
+ time: "$.time",
108
+ account: "$.account"
109
+ },
110
+ inputTemplate: JSON.stringify({
111
+ version: "1.0",
112
+ source: "aws.codepipeline",
113
+ account: "<account>",
114
+ region: "<region>",
115
+ time: "<time>",
116
+ pipeline: "<pipeline>",
117
+ state: "<state>",
118
+ stage: "<stage>",
119
+ action: "<action>",
120
+ message: "CodePipeline <pipeline> <state> in stage <stage>",
121
+ severity: this.getSeverityFromState("<state>"),
122
+ eventType: "PIPELINE_EVENT",
123
+ tags: {
124
+ service: "CodePipeline",
125
+ pipeline: "<pipeline>",
126
+ environment: configuration.tags?.Environment || "unknown"
127
+ }
128
+ })
129
+ } : {
130
+ inputPaths: {
131
+ pipeline: "$.detail.pipeline",
132
+ state: "$.detail.state"
133
+ },
134
+ inputTemplate: `"CodePipeline <pipeline> <state>"`
135
+ }
136
+ }, provider ? { provider } : undefined);
137
+ return {
138
+ eventRule,
139
+ eventTarget,
140
+ snsTopicPolicy
141
+ };
142
+ }
143
+ getOutputs(resource) {
144
+ return {
145
+ eventRuleArn: resource.eventRule.arn,
146
+ eventRuleName: resource.eventRule.name,
147
+ eventTargetId: resource.eventTarget.targetId
148
+ };
149
+ }
150
+ createDetailTypePattern(eventTypes) {
151
+ const detailTypes = [];
152
+ for (const eventType of eventTypes) {
153
+ switch (eventType) {
154
+ case "PIPELINE_EXECUTION_STARTED":
155
+ case "PIPELINE_EXECUTION_SUCCEEDED":
156
+ case "PIPELINE_EXECUTION_FAILED":
157
+ case "PIPELINE_EXECUTION_CANCELED":
158
+ case "PIPELINE_EXECUTION_SUPERSEDED":
159
+ detailTypes.push("CodePipeline Pipeline Execution State Change");
160
+ break;
161
+ case "STAGE_EXECUTION_STARTED":
162
+ case "STAGE_EXECUTION_SUCCEEDED":
163
+ case "STAGE_EXECUTION_FAILED":
164
+ case "STAGE_EXECUTION_CANCELED":
165
+ detailTypes.push("CodePipeline Stage Execution State Change");
166
+ break;
167
+ case "ACTION_EXECUTION_STARTED":
168
+ case "ACTION_EXECUTION_SUCCEEDED":
169
+ case "ACTION_EXECUTION_FAILED":
170
+ case "ACTION_EXECUTION_CANCELED":
171
+ detailTypes.push("CodePipeline Action Execution State Change");
172
+ break;
173
+ }
174
+ }
175
+ return [...new Set(detailTypes)];
176
+ }
177
+ getSeverityFromState(state) {
178
+ switch (state.toUpperCase()) {
179
+ case "FAILED":
180
+ return "HIGH";
181
+ case "CANCELED":
182
+ case "SUPERSEDED":
183
+ return "MEDIUM";
184
+ case "STARTED":
185
+ return "INFO";
186
+ case "SUCCEEDED":
187
+ return "LOW";
188
+ default:
189
+ return "INFO";
190
+ }
191
+ }
192
+ }
193
+ exports.CodePipelineNotificationFactory = CodePipelineNotificationFactory;
@@ -0,0 +1,117 @@
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.CodePipelineNotificationRulesFactory = void 0;
37
+ const aws = __importStar(require("@pulumi/aws"));
38
+ const pulumi = __importStar(require("@pulumi/pulumi"));
39
+ const resourceFactory_1 = require("./resourceFactory");
40
+ class CodePipelineNotificationRulesFactory extends resourceFactory_1.ResourceFactory {
41
+ validateConfig(config) {
42
+ if (!config.configuration.pipelineArn) {
43
+ throw new Error("Pipeline ARN is required for notification rules");
44
+ }
45
+ if (!config.configuration.snsTopicArn) {
46
+ throw new Error("SNS Topic ARN is required for notification rules");
47
+ }
48
+ }
49
+ async createResource(config, provider) {
50
+ const { configuration } = config;
51
+ const eventTypeIds = configuration.eventTypeIds || [
52
+ "codepipeline-pipeline-pipeline-execution-started",
53
+ "codepipeline-pipeline-pipeline-execution-succeeded",
54
+ "codepipeline-pipeline-pipeline-execution-failed",
55
+ "codepipeline-pipeline-manual-approval-needed"
56
+ ];
57
+ const ruleName = configuration.name || `${config.id}-notification-rule`;
58
+ const cleanTags = {};
59
+ if (configuration.tags) {
60
+ for (const [key, value] of Object.entries(configuration.tags)) {
61
+ if (!value.includes('${')) {
62
+ cleanTags[key] = value;
63
+ }
64
+ }
65
+ }
66
+ const current = aws.getCallerIdentity({});
67
+ const snsTopicPolicy = new aws.sns.TopicPolicy(`${config.id}-codestar-sns-policy`, {
68
+ arn: configuration.snsTopicArn,
69
+ policy: pulumi.all([current, configuration.snsTopicArn]).apply(([account, topicArn]) => JSON.stringify({
70
+ Version: "2012-10-17",
71
+ Statement: [
72
+ {
73
+ Sid: "AllowCodeStarNotificationsToPublish",
74
+ Effect: "Allow",
75
+ Principal: {
76
+ Service: "codestar-notifications.amazonaws.com"
77
+ },
78
+ Action: "sns:Publish",
79
+ Resource: topicArn,
80
+ Condition: {
81
+ StringEquals: {
82
+ "aws:SourceAccount": account.accountId
83
+ }
84
+ }
85
+ }
86
+ ]
87
+ }))
88
+ }, provider ? { provider } : undefined);
89
+ const notificationRule = new aws.codestarnotifications.NotificationRule(`${config.id}-notification-rule`, {
90
+ name: ruleName,
91
+ resource: configuration.pipelineArn,
92
+ detailType: configuration.detailType || "FULL",
93
+ eventTypeIds: eventTypeIds,
94
+ targets: [
95
+ {
96
+ address: configuration.snsTopicArn,
97
+ type: "SNS"
98
+ }
99
+ ],
100
+ tags: Object.keys(cleanTags).length > 0 ? cleanTags : undefined
101
+ }, {
102
+ provider,
103
+ dependsOn: [snsTopicPolicy]
104
+ });
105
+ return {
106
+ notificationRule,
107
+ snsTopicPolicy
108
+ };
109
+ }
110
+ getOutputs(resource) {
111
+ return {
112
+ notificationRuleArn: resource.notificationRule.arn,
113
+ snsTopicPolicyId: resource.snsTopicPolicy?.id
114
+ };
115
+ }
116
+ }
117
+ exports.CodePipelineNotificationRulesFactory = CodePipelineNotificationRulesFactory;
@@ -0,0 +1,56 @@
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.CodeStarConnectionFactory = void 0;
37
+ const pulumi = __importStar(require("@pulumi/pulumi"));
38
+ const resourceFactory_1 = require("./resourceFactory");
39
+ const createGithubCodeStarConnection_1 = require("./createGithubCodeStarConnection");
40
+ class CodeStarConnectionFactory extends resourceFactory_1.ResourceFactory {
41
+ async createResource(config) {
42
+ const { id, configuration } = config;
43
+ return (0, createGithubCodeStarConnection_1.createGithubCodeStarConnection)(id, configuration.providerType || "GitHub", configuration.tags);
44
+ }
45
+ getOutputs(resource) {
46
+ return {
47
+ arn: pulumi.output(resource.arn),
48
+ name: pulumi.output(resource.name),
49
+ };
50
+ }
51
+ validateConfig(config) {
52
+ if (!config.id)
53
+ throw new Error("Missing 'id' for CodeStar connection");
54
+ }
55
+ }
56
+ exports.CodeStarConnectionFactory = CodeStarConnectionFactory;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectSecretKeys = collectSecretKeys;
4
+ function collectSecretKeys(env) {
5
+ const secretsById = {};
6
+ for (const envVar of env) {
7
+ if (typeof envVar.value === "string" && envVar.value.startsWith("${secret:")) {
8
+ const match = envVar.value.match(/^\$\{secret:([^:}]+):([^}]+)\}$/);
9
+ if (match) {
10
+ const [_, secretId, key] = match;
11
+ if (!secretsById[secretId])
12
+ secretsById[secretId] = [];
13
+ secretsById[secretId].push(key);
14
+ }
15
+ }
16
+ }
17
+ return secretsById;
18
+ }
@@ -0,0 +1,250 @@
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.ComprehensiveNotificationFactory = void 0;
37
+ const aws = __importStar(require("@pulumi/aws"));
38
+ const resourceFactory_1 = require("./resourceFactory");
39
+ const createAwsSnsTopic_1 = require("./createAwsSnsTopic");
40
+ const createAwsSnsSubscription_1 = require("./createAwsSnsSubscription");
41
+ const createSlackChannelConfiguration_1 = require("./createSlackChannelConfiguration");
42
+ class ComprehensiveNotificationFactory extends resourceFactory_1.ResourceFactory {
43
+ validateConfig(config) {
44
+ if (!config.configuration.name) {
45
+ throw new Error("Notification topic name is required");
46
+ }
47
+ if (!config.configuration.channels || config.configuration.channels.length === 0) {
48
+ throw new Error("At least one notification channel must be configured");
49
+ }
50
+ for (const channel of config.configuration.channels) {
51
+ if (!channel.type || !channel.name) {
52
+ throw new Error(`Channel type and name are required for channel: ${channel.name || 'unnamed'}`);
53
+ }
54
+ switch (channel.type) {
55
+ case "email":
56
+ if (channel.enabled && !channel.configuration.email) {
57
+ throw new Error(`Email address is required for email channel: ${channel.name}`);
58
+ }
59
+ break;
60
+ case "slack":
61
+ if (channel.enabled && (!channel.configuration.slack?.workspaceId || !channel.configuration.slack?.channelId)) {
62
+ throw new Error(`Slack workspace ID and channel ID are required for Slack channel: ${channel.name}`);
63
+ }
64
+ break;
65
+ case "lambda":
66
+ if (channel.enabled && !channel.configuration.lambda?.functionArn) {
67
+ throw new Error(`Lambda function ARN is required for Lambda channel: ${channel.name}`);
68
+ }
69
+ break;
70
+ case "webhook":
71
+ if (channel.enabled && !channel.configuration.webhook?.url) {
72
+ throw new Error(`Webhook URL is required for webhook channel: ${channel.name}`);
73
+ }
74
+ break;
75
+ case "sms":
76
+ if (channel.enabled && !channel.configuration.sms?.phoneNumber) {
77
+ throw new Error(`Phone number is required for SMS channel: ${channel.name}`);
78
+ }
79
+ break;
80
+ }
81
+ }
82
+ }
83
+ async createResource(config, provider) {
84
+ const { configuration } = config;
85
+ const topicConfig = {
86
+ name: configuration.name,
87
+ displayName: configuration.displayName,
88
+ fifoTopic: configuration.fifoTopic,
89
+ contentBasedDeduplication: configuration.contentBasedDeduplication,
90
+ kmsMasterKeyId: configuration.kmsMasterKeyId,
91
+ };
92
+ const topic = (0, createAwsSnsTopic_1.createAwsSnsTopic)(`${config.id}-topic`, topicConfig, provider);
93
+ const subscriptions = {};
94
+ const chatbotConfigurations = {};
95
+ let chatbotRole;
96
+ let chatbotRolePolicyAttachments;
97
+ const slackChannels = configuration.channels.filter(c => c.type === "slack" && c.enabled);
98
+ if (slackChannels.length > 0 && configuration.chatbotRole?.enabled) {
99
+ chatbotRole = new aws.iam.Role(`${config.id}-chatbot-role`, {
100
+ name: configuration.chatbotRole.name || `${configuration.name}-chatbot-role`,
101
+ assumeRolePolicy: JSON.stringify({
102
+ Version: "2012-10-17",
103
+ Statement: [
104
+ {
105
+ Effect: "Allow",
106
+ Principal: {
107
+ Service: "chatbot.amazonaws.com"
108
+ },
109
+ Action: "sts:AssumeRole"
110
+ }
111
+ ]
112
+ }),
113
+ }, provider ? { provider } : undefined);
114
+ const defaultPolicies = [
115
+ "arn:aws:iam::aws:policy/CloudWatchReadOnlyAccess",
116
+ "arn:aws:iam::aws:policy/ReadOnlyAccess"
117
+ ];
118
+ const policiesToAttach = configuration.chatbotRole.policies || defaultPolicies;
119
+ chatbotRolePolicyAttachments = policiesToAttach.map((policyArn, index) => new aws.iam.RolePolicyAttachment(`${config.id}-chatbot-policy-${index}`, {
120
+ role: chatbotRole.name,
121
+ policyArn: policyArn
122
+ }, provider ? { provider } : undefined));
123
+ if (configuration.chatbotRole.customPolicyStatements) {
124
+ const customPolicy = new aws.iam.RolePolicy(`${config.id}-chatbot-custom-policy`, {
125
+ role: chatbotRole.id,
126
+ policy: JSON.stringify({
127
+ Version: "2012-10-17",
128
+ Statement: configuration.chatbotRole.customPolicyStatements
129
+ })
130
+ }, provider ? { provider } : undefined);
131
+ }
132
+ }
133
+ for (const channel of configuration.channels) {
134
+ if (!channel.enabled)
135
+ continue;
136
+ const channelId = `${config.id}-${channel.name}`;
137
+ switch (channel.type) {
138
+ case "email":
139
+ if (channel.configuration.email) {
140
+ const subscription = await (0, createAwsSnsSubscription_1.createAwsSnsSubscription)({
141
+ id: channelId,
142
+ configuration: {
143
+ topicArn: topic.arn,
144
+ protocol: "email",
145
+ endpoint: channel.configuration.email,
146
+ filterPolicy: channel.filterPolicy,
147
+ rawMessageDelivery: channel.rawMessageDelivery,
148
+ deliveryPolicy: channel.deliveryPolicy
149
+ }
150
+ }, provider);
151
+ subscriptions[channel.name] = subscription.subscription;
152
+ }
153
+ break;
154
+ case "slack":
155
+ if (channel.configuration.slack) {
156
+ if (chatbotRole) {
157
+ const slackConfig = (0, createSlackChannelConfiguration_1.createSlackChannelConfiguration)(channelId, {
158
+ name: `${configuration.name}-${channel.name}`,
159
+ slackWorkspaceId: channel.configuration.slack.workspaceId,
160
+ slackChannelId: channel.configuration.slack.channelId,
161
+ snsTopicArns: [topic.arn],
162
+ iamRoleArn: chatbotRole.arn,
163
+ loggingLevel: channel.configuration.slack.loggingLevel || "ERROR",
164
+ guardrailPolicies: channel.configuration.slack.guardrailPolicies,
165
+ userRoleRequired: channel.configuration.slack.userRoleRequired,
166
+ tags: channel.tags
167
+ }, provider);
168
+ chatbotConfigurations[channel.name] = slackConfig;
169
+ }
170
+ else {
171
+ console.log(`Slack channel ${channel.name} configured but ChatBot role is disabled - skipping ChatBot integration`);
172
+ }
173
+ }
174
+ break;
175
+ case "lambda":
176
+ if (channel.configuration.lambda) {
177
+ const subscription = await (0, createAwsSnsSubscription_1.createAwsSnsSubscription)({
178
+ id: channelId,
179
+ configuration: {
180
+ topicArn: topic.arn,
181
+ protocol: "lambda",
182
+ endpoint: channel.configuration.lambda.functionArn,
183
+ filterPolicy: channel.configuration.lambda.filterPolicy || channel.filterPolicy,
184
+ rawMessageDelivery: channel.configuration.lambda.rawMessageDelivery ?? channel.rawMessageDelivery,
185
+ deliveryPolicy: channel.deliveryPolicy
186
+ }
187
+ }, provider);
188
+ subscriptions[channel.name] = subscription.subscription;
189
+ }
190
+ break;
191
+ case "webhook":
192
+ if (channel.configuration.webhook) {
193
+ const subscription = await (0, createAwsSnsSubscription_1.createAwsSnsSubscription)({
194
+ id: channelId,
195
+ configuration: {
196
+ topicArn: topic.arn,
197
+ protocol: "https",
198
+ endpoint: channel.configuration.webhook.url,
199
+ filterPolicy: channel.configuration.webhook.filterPolicy || channel.filterPolicy,
200
+ rawMessageDelivery: channel.configuration.webhook.rawMessageDelivery ?? channel.rawMessageDelivery,
201
+ deliveryPolicy: channel.deliveryPolicy
202
+ }
203
+ }, provider);
204
+ subscriptions[channel.name] = subscription.subscription;
205
+ }
206
+ break;
207
+ case "sms":
208
+ if (channel.configuration.sms) {
209
+ const subscription = await (0, createAwsSnsSubscription_1.createAwsSnsSubscription)({
210
+ id: channelId,
211
+ configuration: {
212
+ topicArn: topic.arn,
213
+ protocol: "sms",
214
+ endpoint: channel.configuration.sms.phoneNumber,
215
+ filterPolicy: channel.filterPolicy,
216
+ deliveryPolicy: channel.deliveryPolicy
217
+ }
218
+ }, provider);
219
+ subscriptions[channel.name] = subscription.subscription;
220
+ }
221
+ break;
222
+ }
223
+ }
224
+ return {
225
+ topic,
226
+ subscriptions,
227
+ chatbotConfigurations,
228
+ chatbotRole,
229
+ chatbotRolePolicyAttachments
230
+ };
231
+ }
232
+ getOutputs(resource) {
233
+ const subscriptionArns = {};
234
+ Object.keys(resource.subscriptions).forEach(key => {
235
+ subscriptionArns[key] = resource.subscriptions[key].arn;
236
+ });
237
+ const chatbotConfigArns = {};
238
+ Object.keys(resource.chatbotConfigurations).forEach(key => {
239
+ chatbotConfigArns[key] = resource.chatbotConfigurations[key].configurationName;
240
+ });
241
+ return {
242
+ topicArn: resource.topic.arn,
243
+ topicName: resource.topic.name,
244
+ subscriptionArns,
245
+ chatbotConfigurations: chatbotConfigArns,
246
+ chatbotRoleArn: resource.chatbotRole?.arn
247
+ };
248
+ }
249
+ }
250
+ exports.ComprehensiveNotificationFactory = ComprehensiveNotificationFactory;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CostAndUsageReportFactory = void 0;
4
+ const resourceFactory_1 = require("./resourceFactory");
5
+ const createCostAndUsageReport_1 = require("./createCostAndUsageReport");
6
+ class CostAndUsageReportFactory extends resourceFactory_1.ResourceFactory {
7
+ getConfig(config) {
8
+ if (config && config.configuration) {
9
+ return {
10
+ id: config.id,
11
+ args: config.configuration
12
+ };
13
+ }
14
+ return config;
15
+ }
16
+ async createResource(config) {
17
+ const cfg = this.getConfig(config);
18
+ return (0, createCostAndUsageReport_1.createCostAndUsageReport)(cfg.id, cfg.args);
19
+ }
20
+ getOutputs(resource) {
21
+ return {
22
+ reportName: resource.reportName,
23
+ arn: resource.arn,
24
+ };
25
+ }
26
+ validateConfig(config) {
27
+ const cfg = this.getConfig(config);
28
+ if (!cfg.id || !cfg.args)
29
+ throw new Error("CostAndUsageReportConfig requires id and args");
30
+ }
31
+ }
32
+ exports.CostAndUsageReportFactory = CostAndUsageReportFactory;