@fjall/components-infrastructure 0.89.5 → 0.89.6

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 (378) hide show
  1. package/LICENSE +50 -21
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1 -18
  4. package/dist/lib/app.d.ts +12 -12
  5. package/dist/lib/app.js +61 -56
  6. package/dist/lib/aspects/index.d.ts +1 -1
  7. package/dist/lib/aspects/index.js +1 -6
  8. package/dist/lib/aspects/resourceInventory.js +6 -13
  9. package/dist/lib/config/audit.js +1 -5
  10. package/dist/lib/config/aws/accessAnalyser.d.ts +11 -0
  11. package/dist/lib/config/aws/accessAnalyser.js +17 -0
  12. package/dist/lib/config/aws/accountAuditRole.js +11 -15
  13. package/dist/lib/config/aws/accountMonitoringRole.js +25 -29
  14. package/dist/lib/config/aws/alarmTopic.d.ts +8 -0
  15. package/dist/lib/config/aws/alarmTopic.js +19 -0
  16. package/dist/lib/config/aws/cloudTrail.js +4 -9
  17. package/dist/lib/config/aws/configRecorder.d.ts +16 -0
  18. package/dist/lib/config/aws/configRecorder.js +51 -0
  19. package/dist/lib/config/aws/configRulePreset.d.ts +13 -0
  20. package/dist/lib/config/aws/configRulePreset.js +62 -0
  21. package/dist/lib/config/aws/disasterRecovery.d.ts +1 -1
  22. package/dist/lib/config/aws/disasterRecovery.js +56 -73
  23. package/dist/lib/config/aws/ebsDefaultEncryption.d.ts +8 -0
  24. package/dist/lib/config/aws/ebsDefaultEncryption.js +41 -0
  25. package/dist/lib/config/aws/ecrDefaultImage.js +25 -30
  26. package/dist/lib/config/aws/eventBus.js +8 -11
  27. package/dist/lib/config/aws/guardDutyDetector.d.ts +16 -0
  28. package/dist/lib/config/aws/guardDutyDetector.js +26 -0
  29. package/dist/lib/config/aws/identityCenter.d.ts +1 -1
  30. package/dist/lib/config/aws/identityCenter.js +23 -25
  31. package/dist/lib/config/aws/identityCenterGroupMembership.js +18 -22
  32. package/dist/lib/config/aws/index.d.ts +19 -8
  33. package/dist/lib/config/aws/index.js +19 -25
  34. package/dist/lib/config/aws/inspectorEnablement.d.ts +9 -0
  35. package/dist/lib/config/aws/inspectorEnablement.js +51 -0
  36. package/dist/lib/config/aws/ipam.js +9 -13
  37. package/dist/lib/config/aws/oidcConnector.js +8 -12
  38. package/dist/lib/config/aws/platform.js +1 -5
  39. package/dist/lib/config/aws/s3BlockPublicAccess.d.ts +9 -0
  40. package/dist/lib/config/aws/s3BlockPublicAccess.js +55 -0
  41. package/dist/lib/config/aws/scpPreset.d.ts +21 -0
  42. package/dist/lib/config/aws/scpPreset.js +311 -0
  43. package/dist/lib/config/aws/securityBaseline.d.ts +15 -0
  44. package/dist/lib/config/aws/securityBaseline.js +27 -0
  45. package/dist/lib/config/aws/securityHubHub.d.ts +15 -0
  46. package/dist/lib/config/aws/securityHubHub.js +28 -0
  47. package/dist/lib/config/aws/securityServicesAdmin.d.ts +20 -0
  48. package/dist/lib/config/aws/securityServicesAdmin.js +115 -0
  49. package/dist/lib/config/index.d.ts +2 -2
  50. package/dist/lib/config/index.js +2 -21
  51. package/dist/lib/index.d.ts +4 -4
  52. package/dist/lib/index.js +5 -26
  53. package/dist/lib/patterns/aws/account.d.ts +17 -1
  54. package/dist/lib/patterns/aws/account.js +60 -33
  55. package/dist/lib/patterns/aws/apexDomainPattern.d.ts +26 -0
  56. package/dist/lib/patterns/aws/apexDomainPattern.js +91 -0
  57. package/dist/lib/patterns/aws/auditRole.js +13 -16
  58. package/dist/lib/patterns/aws/buildkite.d.ts +1 -1
  59. package/dist/lib/patterns/aws/buildkite.js +70 -75
  60. package/dist/lib/patterns/aws/cdn.d.ts +5 -5
  61. package/dist/lib/patterns/aws/cdn.js +22 -28
  62. package/dist/lib/patterns/aws/compute.d.ts +1 -1
  63. package/dist/lib/patterns/aws/compute.js +31 -44
  64. package/dist/lib/patterns/aws/computeEc2.d.ts +1 -1
  65. package/dist/lib/patterns/aws/computeEc2.js +11 -14
  66. package/dist/lib/patterns/aws/computeEcs.d.ts +18 -2
  67. package/dist/lib/patterns/aws/computeEcs.js +41 -31
  68. package/dist/lib/patterns/aws/computeLambda.d.ts +2 -2
  69. package/dist/lib/patterns/aws/computeLambda.js +24 -31
  70. package/dist/lib/patterns/aws/database.d.ts +16 -7
  71. package/dist/lib/patterns/aws/database.js +81 -73
  72. package/dist/lib/patterns/aws/delegatedDomainPattern.d.ts +17 -0
  73. package/dist/lib/patterns/aws/delegatedDomainPattern.js +54 -0
  74. package/dist/lib/patterns/aws/dnsRecordComposer.d.ts +25 -0
  75. package/dist/lib/patterns/aws/dnsRecordComposer.js +225 -0
  76. package/dist/lib/patterns/aws/domain.d.ts +32 -0
  77. package/dist/lib/patterns/aws/domain.js +115 -0
  78. package/dist/lib/patterns/aws/domainDelegation.d.ts +3 -3
  79. package/dist/lib/patterns/aws/domainDelegation.js +28 -37
  80. package/dist/lib/patterns/aws/domainFactory.d.ts +20 -5
  81. package/dist/lib/patterns/aws/domainFactory.js +48 -10
  82. package/dist/lib/patterns/aws/domainValidation.d.ts +11 -0
  83. package/dist/lib/patterns/aws/domainValidation.js +145 -0
  84. package/dist/lib/patterns/aws/externalRecordsPattern.d.ts +18 -0
  85. package/dist/lib/patterns/aws/externalRecordsPattern.js +141 -0
  86. package/dist/lib/patterns/aws/fivetranProxy.d.ts +1 -1
  87. package/dist/lib/patterns/aws/fivetranProxy.js +6 -11
  88. package/dist/lib/patterns/aws/index.d.ts +21 -19
  89. package/dist/lib/patterns/aws/index.js +25 -36
  90. package/dist/lib/patterns/aws/interfaces/cdn.js +1 -5
  91. package/dist/lib/patterns/aws/interfaces/compute.js +4 -11
  92. package/dist/lib/patterns/aws/interfaces/connector.js +1 -15
  93. package/dist/lib/patterns/aws/interfaces/database.d.ts +1 -1
  94. package/dist/lib/patterns/aws/interfaces/database.js +6 -15
  95. package/dist/lib/patterns/aws/interfaces/domain.d.ts +80 -2
  96. package/dist/lib/patterns/aws/interfaces/domain.js +1 -6
  97. package/dist/lib/patterns/aws/interfaces/index.js +8 -41
  98. package/dist/lib/patterns/aws/interfaces/messaging.js +4 -11
  99. package/dist/lib/patterns/aws/interfaces/organisation.d.ts +1 -1
  100. package/dist/lib/patterns/aws/interfaces/organisation.js +4 -11
  101. package/dist/lib/patterns/aws/interfaces/pattern.js +2 -7
  102. package/dist/lib/patterns/aws/interfaces/storage.js +1 -5
  103. package/dist/lib/patterns/aws/managedIdentityCenter.js +7 -12
  104. package/dist/lib/patterns/aws/messaging.d.ts +7 -7
  105. package/dist/lib/patterns/aws/messaging.js +22 -33
  106. package/dist/lib/patterns/aws/network.d.ts +2 -2
  107. package/dist/lib/patterns/aws/network.js +9 -14
  108. package/dist/lib/patterns/aws/organisation.d.ts +6 -2
  109. package/dist/lib/patterns/aws/organisation.js +34 -35
  110. package/dist/lib/patterns/aws/organisationFactory.d.ts +3 -3
  111. package/dist/lib/patterns/aws/organisationFactory.js +7 -12
  112. package/dist/lib/patterns/aws/pattern.js +6 -12
  113. package/dist/lib/patterns/aws/payload.js +73 -63
  114. package/dist/lib/patterns/aws/platform.d.ts +6 -3
  115. package/dist/lib/patterns/aws/platform.js +15 -15
  116. package/dist/lib/patterns/aws/storage.d.ts +6 -4
  117. package/dist/lib/patterns/aws/storage.js +35 -40
  118. package/dist/lib/patterns/aws/subdomainHostedZone.js +11 -16
  119. package/dist/lib/patterns/aws/targets/fjallTargets.d.ts +37 -0
  120. package/dist/lib/patterns/aws/targets/fjallTargets.js +66 -0
  121. package/dist/lib/patterns/aws/targets/index.d.ts +2 -0
  122. package/dist/lib/patterns/aws/targets/index.js +2 -0
  123. package/dist/lib/patterns/aws/targets/targetResolution.d.ts +76 -0
  124. package/dist/lib/patterns/aws/targets/targetResolution.js +119 -0
  125. package/dist/lib/patterns/index.d.ts +1 -0
  126. package/dist/lib/patterns/index.js +1 -0
  127. package/dist/lib/resources/aws/analytics/clickhouse.d.ts +15 -0
  128. package/dist/lib/resources/aws/analytics/clickhouse.js +292 -0
  129. package/dist/lib/resources/aws/analytics/clickhouseConstants.d.ts +73 -0
  130. package/dist/lib/resources/aws/analytics/clickhouseConstants.js +87 -0
  131. package/dist/lib/resources/aws/analytics/clickhouseSecurityGroup.d.ts +13 -0
  132. package/dist/lib/resources/aws/analytics/clickhouseSecurityGroup.js +28 -0
  133. package/dist/lib/resources/aws/analytics/clickhouseTypes.d.ts +47 -0
  134. package/dist/lib/resources/aws/analytics/clickhouseTypes.js +1 -0
  135. package/dist/lib/resources/aws/analytics/clickhouseUserData.d.ts +5 -0
  136. package/dist/lib/resources/aws/analytics/clickhouseUserData.js +248 -0
  137. package/dist/lib/resources/aws/analytics/index.d.ts +2 -0
  138. package/dist/lib/resources/aws/analytics/index.js +1 -0
  139. package/dist/lib/resources/aws/audit/auditRole.js +10 -15
  140. package/dist/lib/resources/aws/audit/index.d.ts +1 -1
  141. package/dist/lib/resources/aws/audit/index.js +1 -6
  142. package/dist/lib/resources/aws/backup/backupPlan.d.ts +1 -1
  143. package/dist/lib/resources/aws/backup/backupPlan.js +14 -16
  144. package/dist/lib/resources/aws/backup/backupVault.d.ts +1 -1
  145. package/dist/lib/resources/aws/backup/backupVault.js +13 -15
  146. package/dist/lib/resources/aws/backup/index.d.ts +2 -2
  147. package/dist/lib/resources/aws/backup/index.js +2 -19
  148. package/dist/lib/resources/aws/base/awsStack.js +17 -19
  149. package/dist/lib/resources/aws/base/index.d.ts +1 -1
  150. package/dist/lib/resources/aws/base/index.js +1 -18
  151. package/dist/lib/resources/aws/cdn/cloudFront.js +40 -42
  152. package/dist/lib/resources/aws/cdn/index.d.ts +1 -1
  153. package/dist/lib/resources/aws/cdn/index.js +1 -18
  154. package/dist/lib/resources/aws/compute/ec2.js +39 -39
  155. package/dist/lib/resources/aws/compute/ecs.d.ts +18 -396
  156. package/dist/lib/resources/aws/compute/ecs.js +105 -976
  157. package/dist/lib/resources/aws/compute/ecsCapacityProviderAspect.d.ts +22 -0
  158. package/dist/lib/resources/aws/compute/ecsCapacityProviderAspect.js +35 -0
  159. package/dist/lib/resources/aws/compute/ecsConstants.d.ts +20 -0
  160. package/dist/lib/resources/aws/compute/ecsConstants.js +49 -0
  161. package/dist/lib/resources/aws/compute/ecsContext.d.ts +12 -0
  162. package/dist/lib/resources/aws/compute/ecsContext.js +1 -0
  163. package/dist/lib/resources/aws/compute/ecsImages.d.ts +4 -0
  164. package/dist/lib/resources/aws/compute/ecsImages.js +35 -0
  165. package/dist/lib/resources/aws/compute/ecsNetworking.d.ts +28 -0
  166. package/dist/lib/resources/aws/compute/ecsNetworking.js +290 -0
  167. package/dist/lib/resources/aws/compute/ecsRoles.d.ts +15 -0
  168. package/dist/lib/resources/aws/compute/ecsRoles.js +110 -0
  169. package/dist/lib/resources/aws/compute/ecsServiceFactory.d.ts +33 -0
  170. package/dist/lib/resources/aws/compute/ecsServiceFactory.js +183 -0
  171. package/dist/lib/resources/aws/compute/ecsTaskDefinition.d.ts +30 -0
  172. package/dist/lib/resources/aws/compute/ecsTaskDefinition.js +168 -0
  173. package/dist/lib/resources/aws/compute/ecsTypes.d.ts +337 -0
  174. package/dist/lib/resources/aws/compute/ecsTypes.js +10 -0
  175. package/dist/lib/resources/aws/compute/ecsValidation.d.ts +18 -0
  176. package/dist/lib/resources/aws/compute/ecsValidation.js +72 -0
  177. package/dist/lib/resources/aws/compute/index.d.ts +3 -3
  178. package/dist/lib/resources/aws/compute/index.js +3 -20
  179. package/dist/lib/resources/aws/compute/lambda.d.ts +10 -2
  180. package/dist/lib/resources/aws/compute/lambda.js +81 -71
  181. package/dist/lib/resources/aws/database/dynamodb.js +24 -27
  182. package/dist/lib/resources/aws/database/index.d.ts +7 -7
  183. package/dist/lib/resources/aws/database/index.js +14 -33
  184. package/dist/lib/resources/aws/database/rdsAurora.d.ts +10 -2
  185. package/dist/lib/resources/aws/database/rdsAurora.js +76 -61
  186. package/dist/lib/resources/aws/database/rdsAuroraGlobal.d.ts +2 -2
  187. package/dist/lib/resources/aws/database/rdsAuroraGlobal.js +24 -21
  188. package/dist/lib/resources/aws/database/rdsDefaults.js +3 -7
  189. package/dist/lib/resources/aws/database/rdsHelpers.d.ts +2 -2
  190. package/dist/lib/resources/aws/database/rdsHelpers.js +21 -29
  191. package/dist/lib/resources/aws/database/rdsInstance.d.ts +11 -3
  192. package/dist/lib/resources/aws/database/rdsInstance.js +101 -83
  193. package/dist/lib/resources/aws/database/rdsProxyOutput.js +5 -9
  194. package/dist/lib/resources/aws/iam/delegationRole.d.ts +18 -0
  195. package/dist/lib/resources/aws/iam/delegationRole.js +60 -0
  196. package/dist/lib/resources/aws/iam/identityCenter/assignment.js +4 -9
  197. package/dist/lib/resources/aws/iam/identityCenter/group.js +5 -9
  198. package/dist/lib/resources/aws/iam/identityCenter/index.d.ts +3 -3
  199. package/dist/lib/resources/aws/iam/identityCenter/index.js +3 -20
  200. package/dist/lib/resources/aws/iam/identityCenter/permissionSet.d.ts +1 -1
  201. package/dist/lib/resources/aws/iam/identityCenter/permissionSet.js +5 -9
  202. package/dist/lib/resources/aws/iam/index.d.ts +5 -4
  203. package/dist/lib/resources/aws/iam/index.js +5 -21
  204. package/dist/lib/resources/aws/iam/instanceProfile.js +2 -7
  205. package/dist/lib/resources/aws/iam/managedPolicy.js +2 -7
  206. package/dist/lib/resources/aws/iam/policy.js +2 -7
  207. package/dist/lib/resources/aws/iam/role.js +2 -7
  208. package/dist/lib/resources/aws/index.d.ts +7 -7
  209. package/dist/lib/resources/aws/index.js +7 -24
  210. package/dist/lib/resources/aws/logging/cloudTrail.d.ts +1 -1
  211. package/dist/lib/resources/aws/logging/cloudTrail.js +18 -22
  212. package/dist/lib/resources/aws/logging/index.d.ts +2 -2
  213. package/dist/lib/resources/aws/logging/index.js +2 -19
  214. package/dist/lib/resources/aws/logging/logGroup.js +4 -10
  215. package/dist/lib/resources/aws/messaging/eventbridge.js +11 -14
  216. package/dist/lib/resources/aws/messaging/index.d.ts +4 -4
  217. package/dist/lib/resources/aws/messaging/index.js +4 -21
  218. package/dist/lib/resources/aws/messaging/sns.js +11 -14
  219. package/dist/lib/resources/aws/messaging/sqs.js +32 -34
  220. package/dist/lib/resources/aws/messaging/utils.d.ts +1 -1
  221. package/dist/lib/resources/aws/messaging/utils.js +1 -6
  222. package/dist/lib/resources/aws/monitoring/alarmDefaults.d.ts +36 -0
  223. package/dist/lib/resources/aws/monitoring/alarmDefaults.js +34 -0
  224. package/dist/lib/resources/aws/monitoring/ecsAlarms.d.ts +21 -0
  225. package/dist/lib/resources/aws/monitoring/ecsAlarms.js +88 -0
  226. package/dist/lib/resources/aws/monitoring/index.d.ts +4 -0
  227. package/dist/lib/resources/aws/monitoring/index.js +4 -5
  228. package/dist/lib/resources/aws/monitoring/lambdaAlarms.d.ts +18 -0
  229. package/dist/lib/resources/aws/monitoring/lambdaAlarms.js +44 -0
  230. package/dist/lib/resources/aws/monitoring/rdsAlarms.d.ts +20 -0
  231. package/dist/lib/resources/aws/monitoring/rdsAlarms.js +52 -0
  232. package/dist/lib/resources/aws/networking/crossAccountDelegationRecord.d.ts +17 -0
  233. package/dist/lib/resources/aws/networking/crossAccountDelegationRecord.js +26 -0
  234. package/dist/lib/resources/aws/networking/dnsRecord/aRecord.d.ts +12 -0
  235. package/dist/lib/resources/aws/networking/dnsRecord/aRecord.js +21 -0
  236. package/dist/lib/resources/aws/networking/dnsRecord/aaaaRecord.d.ts +12 -0
  237. package/dist/lib/resources/aws/networking/dnsRecord/aaaaRecord.js +22 -0
  238. package/dist/lib/resources/aws/networking/dnsRecord/aliasRecord.d.ts +12 -0
  239. package/dist/lib/resources/aws/networking/dnsRecord/aliasRecord.js +23 -0
  240. package/dist/lib/resources/aws/networking/dnsRecord/caaRecord.d.ts +17 -0
  241. package/dist/lib/resources/aws/networking/dnsRecord/caaRecord.js +21 -0
  242. package/dist/lib/resources/aws/networking/dnsRecord/cnameRecord.d.ts +12 -0
  243. package/dist/lib/resources/aws/networking/dnsRecord/cnameRecord.js +22 -0
  244. package/dist/lib/resources/aws/networking/dnsRecord/dnsRecordBase.d.ts +17 -0
  245. package/dist/lib/resources/aws/networking/dnsRecord/dnsRecordBase.js +17 -0
  246. package/dist/lib/resources/aws/networking/dnsRecord/index.d.ts +10 -0
  247. package/dist/lib/resources/aws/networking/dnsRecord/index.js +10 -0
  248. package/dist/lib/resources/aws/networking/dnsRecord/mxRecord.d.ts +16 -0
  249. package/dist/lib/resources/aws/networking/dnsRecord/mxRecord.js +21 -0
  250. package/dist/lib/resources/aws/networking/dnsRecord/nsRecord.d.ts +12 -0
  251. package/dist/lib/resources/aws/networking/dnsRecord/nsRecord.js +21 -0
  252. package/dist/lib/resources/aws/networking/dnsRecord/srvRecord.d.ts +18 -0
  253. package/dist/lib/resources/aws/networking/dnsRecord/srvRecord.js +21 -0
  254. package/dist/lib/resources/aws/networking/dnsRecord/txtRecord.d.ts +12 -0
  255. package/dist/lib/resources/aws/networking/dnsRecord/txtRecord.js +21 -0
  256. package/dist/lib/resources/aws/networking/domain.d.ts +1 -1
  257. package/dist/lib/resources/aws/networking/domain.js +32 -34
  258. package/dist/lib/resources/aws/networking/domainCertificate.d.ts +8 -3
  259. package/dist/lib/resources/aws/networking/domainCertificate.js +22 -16
  260. package/dist/lib/resources/aws/networking/hostedZone.d.ts +23 -19
  261. package/dist/lib/resources/aws/networking/hostedZone.js +70 -134
  262. package/dist/lib/resources/aws/networking/index.d.ts +8 -7
  263. package/dist/lib/resources/aws/networking/index.js +8 -24
  264. package/dist/lib/resources/aws/networking/ipam.js +2 -7
  265. package/dist/lib/resources/aws/networking/ipamPool.d.ts +1 -1
  266. package/dist/lib/resources/aws/networking/ipamPool.js +45 -55
  267. package/dist/lib/resources/aws/networking/securityGroup.js +2 -7
  268. package/dist/lib/resources/aws/networking/vpc.d.ts +1 -1
  269. package/dist/lib/resources/aws/networking/vpc.js +17 -21
  270. package/dist/lib/resources/aws/organisation/costAllocationTagActivator.d.ts +1 -1
  271. package/dist/lib/resources/aws/organisation/costAllocationTagActivator.js +11 -15
  272. package/dist/lib/resources/aws/organisation/index.d.ts +5 -5
  273. package/dist/lib/resources/aws/organisation/index.js +4 -12
  274. package/dist/lib/resources/aws/organisation/organisation.js +5 -7
  275. package/dist/lib/resources/aws/organisation/organisationAccount.js +7 -10
  276. package/dist/lib/resources/aws/organisation/organisationPolicy.js +5 -9
  277. package/dist/lib/resources/aws/organisation/organisationalUnit.js +1 -3
  278. package/dist/lib/resources/aws/secrets/alias.js +2 -7
  279. package/dist/lib/resources/aws/secrets/index.d.ts +4 -4
  280. package/dist/lib/resources/aws/secrets/index.js +4 -21
  281. package/dist/lib/resources/aws/secrets/kms.js +15 -18
  282. package/dist/lib/resources/aws/secrets/parameter.d.ts +3 -3
  283. package/dist/lib/resources/aws/secrets/parameter.js +19 -22
  284. package/dist/lib/resources/aws/secrets/secret.d.ts +2 -2
  285. package/dist/lib/resources/aws/secrets/secret.js +12 -14
  286. package/dist/lib/resources/aws/storage/ecr.d.ts +2 -2
  287. package/dist/lib/resources/aws/storage/ecr.js +7 -13
  288. package/dist/lib/resources/aws/storage/index.d.ts +2 -2
  289. package/dist/lib/resources/aws/storage/index.js +2 -19
  290. package/dist/lib/resources/aws/storage/s3.d.ts +1 -1
  291. package/dist/lib/resources/aws/storage/s3.js +24 -12
  292. package/dist/lib/resources/aws/utilities/awsCustomResource.js +3 -7
  293. package/dist/lib/resources/aws/utilities/codeBuild.js +7 -12
  294. package/dist/lib/resources/aws/utilities/customResource.js +14 -17
  295. package/dist/lib/resources/aws/utilities/customResourceProvider.js +2 -7
  296. package/dist/lib/resources/aws/utilities/index.d.ts +5 -5
  297. package/dist/lib/resources/aws/utilities/index.js +5 -22
  298. package/dist/lib/resources/aws/utilities/resourceShare.js +2 -7
  299. package/dist/lib/resources/index.d.ts +1 -1
  300. package/dist/lib/resources/index.js +1 -18
  301. package/dist/lib/types.js +1 -3
  302. package/dist/lib/utils/accountsUtils.d.ts +5 -0
  303. package/dist/lib/utils/accountsUtils.js +18 -0
  304. package/dist/lib/utils/addSuffixToEmail.js +1 -5
  305. package/dist/lib/utils/backupTierMapping.js +2 -6
  306. package/dist/lib/utils/capitaliseString.js +1 -10
  307. package/dist/lib/utils/connections.js +9 -13
  308. package/dist/lib/utils/connector.js +10 -23
  309. package/dist/lib/utils/constructMap.d.ts +33 -0
  310. package/dist/lib/utils/constructMap.js +154 -0
  311. package/dist/lib/utils/databaseTypes.js +4 -10
  312. package/dist/lib/utils/dnsRecords.d.ts +1 -1
  313. package/dist/lib/utils/dnsRecords.js +23 -27
  314. package/dist/lib/utils/domainTypes.d.ts +0 -1
  315. package/dist/lib/utils/domainTypes.js +2 -10
  316. package/dist/lib/utils/env.js +14 -26
  317. package/dist/lib/utils/getAccountId.js +3 -7
  318. package/dist/lib/utils/getAsync.js +7 -10
  319. package/dist/lib/utils/getConfig.d.ts +0 -2
  320. package/dist/lib/utils/getConfig.js +29 -47
  321. package/dist/lib/utils/getStackOutput.js +4 -8
  322. package/dist/lib/utils/index.d.ts +12 -12
  323. package/dist/lib/utils/index.js +12 -29
  324. package/dist/lib/utils/manifestWriter.d.ts +14 -3
  325. package/dist/lib/utils/manifestWriter.js +60 -43
  326. package/dist/lib/utils/orgConfigParser.d.ts +14 -0
  327. package/dist/lib/utils/orgConfigParser.js +49 -0
  328. package/dist/lib/utils/removalPolicy.js +5 -9
  329. package/dist/lib/utils/resourceNaming.js +11 -16
  330. package/dist/lib/utils/standardTagsAspect.js +9 -16
  331. package/dist/lib/utils/stripAndCamelCase.js +1 -5
  332. package/dist/lib/utils/validationLogger.js +12 -18
  333. package/dist/lib/utils/vpcUtils.js +5 -10
  334. package/package.json +25 -8
  335. package/dist/lib/config/aws/accountId.d.ts +0 -6
  336. package/dist/lib/config/aws/accountId.js +0 -32
  337. package/dist/lib/config/aws/backupGlobalSettings.d.ts +0 -29
  338. package/dist/lib/config/aws/backupGlobalSettings.js +0 -49
  339. package/dist/lib/config/aws/costAllocationTags.d.ts +0 -12
  340. package/dist/lib/config/aws/costAllocationTags.js +0 -47
  341. package/dist/lib/config/aws/ipamDelegateAdmin.d.ts +0 -8
  342. package/dist/lib/config/aws/ipamDelegateAdmin.js +0 -57
  343. package/dist/lib/config/aws/ipamPoolId.d.ts +0 -16
  344. package/dist/lib/config/aws/ipamPoolId.js +0 -42
  345. package/dist/lib/config/aws/organisation.d.ts +0 -30
  346. package/dist/lib/config/aws/organisation.js +0 -92
  347. package/dist/lib/config/aws/organisationId.d.ts +0 -7
  348. package/dist/lib/config/aws/organisationId.js +0 -45
  349. package/dist/lib/config/aws/organisationsAccess.d.ts +0 -10
  350. package/dist/lib/config/aws/organisationsAccess.js +0 -49
  351. package/dist/lib/config/aws/ramSharing.d.ts +0 -4
  352. package/dist/lib/config/aws/ramSharing.js +0 -34
  353. package/dist/lib/config/monitoring.d.ts +0 -18
  354. package/dist/lib/config/monitoring.js +0 -22
  355. package/dist/lib/patterns/aws/connections.d.ts +0 -46
  356. package/dist/lib/patterns/aws/connections.js +0 -159
  357. package/dist/lib/patterns/aws/hostedZone.d.ts +0 -28
  358. package/dist/lib/patterns/aws/hostedZone.js +0 -150
  359. package/dist/lib/patterns/aws/managedAccount.d.ts +0 -9
  360. package/dist/lib/patterns/aws/managedAccount.js +0 -55
  361. package/dist/lib/patterns/aws/managedOrganisation.d.ts +0 -36
  362. package/dist/lib/patterns/aws/managedOrganisation.js +0 -97
  363. package/dist/lib/patterns/aws/managedPlatform.d.ts +0 -12
  364. package/dist/lib/patterns/aws/managedPlatform.js +0 -29
  365. package/dist/lib/resources/aws/database/database.d.ts +0 -14
  366. package/dist/lib/resources/aws/database/database.js +0 -28
  367. package/dist/lib/resources/aws/database/databaseInstance.d.ts +0 -15
  368. package/dist/lib/resources/aws/database/databaseInstance.js +0 -30
  369. package/dist/lib/resources/aws/database/migrationLambda.d.ts +0 -80
  370. package/dist/lib/resources/aws/database/migrationLambda.js +0 -119
  371. package/dist/lib/resources/aws/iam/identityCenter/attachManagedPolicy.d.ts +0 -13
  372. package/dist/lib/resources/aws/iam/identityCenter/attachManagedPolicy.js +0 -51
  373. package/dist/lib/resources/aws/iam/securityGroup.d.ts +0 -5
  374. package/dist/lib/resources/aws/iam/securityGroup.js +0 -14
  375. package/dist/lib/resources/aws/monitoring/monitoringRole.d.ts +0 -29
  376. package/dist/lib/resources/aws/monitoring/monitoringRole.js +0 -120
  377. package/dist/lib/utils/capitalizeString.d.ts +0 -12
  378. package/dist/lib/utils/capitalizeString.js +0 -30
@@ -0,0 +1,292 @@
1
+ import { Cluster, Ec2TaskDefinition, NetworkMode, ContainerImage, LogDriver, AsgCapacityProvider, EcsOptimizedImage, Ec2Service, Secret as EcsSecret } from "aws-cdk-lib/aws-ecs";
2
+ import { ScheduledEc2Task } from "aws-cdk-lib/aws-ecs-patterns";
3
+ import { Schedule } from "aws-cdk-lib/aws-applicationautoscaling";
4
+ import { InstanceType, SubnetType, Connections, Port, UserData } from "aws-cdk-lib/aws-ec2";
5
+ import { AutoScalingGroup, Monitoring, BlockDeviceVolume, EbsDeviceVolumeType } from "aws-cdk-lib/aws-autoscaling";
6
+ import { Duration, Stack } from "aws-cdk-lib";
7
+ import { Construct } from "constructs";
8
+ import { RetentionDays } from "aws-cdk-lib/aws-logs";
9
+ import { S3Bucket } from "../storage/s3.js";
10
+ import { Secret } from "../secrets/secret.js";
11
+ import { vpcHasNatGateways } from "../../../utils/vpcUtils.js";
12
+ import { inferAmiHardwareType } from "../compute/ecsConstants.js";
13
+ import { createClickHouseSecurityGroup } from "./clickhouseSecurityGroup.js";
14
+ import { generateClickHouseUserData } from "./clickhouseUserData.js";
15
+ import { CLICKHOUSE_CLUSTER_NAME, DEFAULT_CLICKHOUSE_INSTANCE_TYPE, CLICKHOUSE_IMAGE, CLICKHOUSE_EBS_VOLUME_SIZE_GB, CLICKHOUSE_EBS_IOPS, CLICKHOUSE_EBS_THROUGHPUT_MBPS, CLICKHOUSE_TASK_MEMORY_MIB, CLICKHOUSE_TASK_CPU_UNITS, CLICKHOUSE_HTTP_PORT, CLICKHOUSE_NATIVE_PORT, CLICKHOUSE_PROMETHEUS_PORT, CLICKHOUSE_DATA_MOUNT_PATH, CLICKHOUSE_SECRETS_PREFIX, CLICKHOUSE_SECRET_NAMES, CLICKHOUSE_SECRET_OPTIONS, CLICKHOUSE_HEALTH_CHECK, CLICKHOUSE_EBS_DEVICE_NAME, CLICKHOUSE_CONFIG_SUBDIR, CLICKHOUSE_USERS_SUBDIR, OPTIMISE_FINAL_SCHEDULE, REPLACING_MERGE_TREE_TABLES, OPTIMISE_MV_TABLES, CLICKHOUSE_CLOUDMAP_NAMESPACE, CLICKHOUSE_CLOUDMAP_SERVICE_NAME, OPTIMISE_TASK_MEMORY_MIB, OPTIMISE_TASK_CPU_UNITS, BACKUP_SCHEDULE, BACKUP_TASK_MEMORY_MIB, BACKUP_TASK_CPU_UNITS, BACKUP_RETENTION_DAYS } from "./clickhouseConstants.js";
16
+ function createClickHouseSecret(scope, id, secretKey, description) {
17
+ return new Secret(scope, id, {
18
+ secretName: `${CLICKHOUSE_SECRETS_PREFIX}/${secretKey}`,
19
+ description,
20
+ generateSecretString: CLICKHOUSE_SECRET_OPTIONS
21
+ });
22
+ }
23
+ /**
24
+ * ClickHouse analytics infrastructure.
25
+ *
26
+ * Creates a single-node ClickHouse instance on ECS EC2 with a dedicated
27
+ * gp3 EBS volume for data persistence. Designed for analytical workloads
28
+ * (cost aggregation, deployment metrics, audit logs) rather than OLTP.
29
+ */
30
+ export default class ClickHouse extends Construct {
31
+ connections;
32
+ outputs;
33
+ constructor(scope, id, props) {
34
+ super(scope, id);
35
+ const contextValue = this.node.tryGetContext("clickhouseInstanceType");
36
+ const instanceType = (typeof contextValue === "string" ? contextValue : undefined) ??
37
+ props.instanceType ??
38
+ DEFAULT_CLICKHOUSE_INSTANCE_TYPE;
39
+ // 1. Security group
40
+ const securityGroup = createClickHouseSecurityGroup(this, props.vpc, props.webappSecurityGroup);
41
+ // 2. Secrets Manager secrets (auto-generated passwords)
42
+ const appPasswordSecret = createClickHouseSecret(this, "ClickHouseAppPassword", CLICKHOUSE_SECRET_NAMES.APP_PASSWORD, "ClickHouse application user password");
43
+ const auditPasswordSecret = createClickHouseSecret(this, "ClickHouseAuditPassword", CLICKHOUSE_SECRET_NAMES.AUDIT_PASSWORD, "ClickHouse audit user password");
44
+ const backupPasswordSecret = createClickHouseSecret(this, "ClickHouseBackupPassword", CLICKHOUSE_SECRET_NAMES.BACKUP_PASSWORD, "ClickHouse backup user password");
45
+ const schemaPasswordSecret = createClickHouseSecret(this, "ClickHouseSchemaPassword", CLICKHOUSE_SECRET_NAMES.SCHEMA_PASSWORD, "ClickHouse schema migration user password");
46
+ // 3. ECS cluster with Cloud Map namespace for service discovery
47
+ const cluster = new Cluster(this, "ClickHouseCluster", {
48
+ clusterName: CLICKHOUSE_CLUSTER_NAME,
49
+ vpc: props.vpc,
50
+ defaultCloudMapNamespace: {
51
+ name: CLICKHOUSE_CLOUDMAP_NAMESPACE,
52
+ vpc: props.vpc
53
+ }
54
+ });
55
+ // 4. Auto Scaling Group with gp3 EBS volume
56
+ const amiHardwareType = inferAmiHardwareType(instanceType);
57
+ const hasNat = vpcHasNatGateways(props.vpc);
58
+ const subnetType = hasNat
59
+ ? SubnetType.PRIVATE_WITH_EGRESS
60
+ : SubnetType.PUBLIC;
61
+ const userData = UserData.custom(generateClickHouseUserData({
62
+ cfAccountId: props.r2Config?.accountId
63
+ }));
64
+ const asg = new AutoScalingGroup(this, "ClickHouseAsg", {
65
+ autoScalingGroupName: `${CLICKHOUSE_CLUSTER_NAME}-asg`,
66
+ vpc: props.vpc,
67
+ vpcSubnets: {
68
+ subnetType
69
+ },
70
+ securityGroup,
71
+ minCapacity: 1,
72
+ maxCapacity: 1,
73
+ desiredCapacity: 1,
74
+ instanceType: new InstanceType(instanceType),
75
+ machineImage: EcsOptimizedImage.amazonLinux2023(amiHardwareType),
76
+ instanceMonitoring: Monitoring.BASIC,
77
+ blockDevices: [
78
+ {
79
+ deviceName: CLICKHOUSE_EBS_DEVICE_NAME,
80
+ volume: BlockDeviceVolume.ebs(CLICKHOUSE_EBS_VOLUME_SIZE_GB, {
81
+ volumeType: EbsDeviceVolumeType.GP3,
82
+ iops: CLICKHOUSE_EBS_IOPS,
83
+ throughput: CLICKHOUSE_EBS_THROUGHPUT_MBPS,
84
+ encrypted: true
85
+ })
86
+ }
87
+ ],
88
+ userData
89
+ });
90
+ // 5. Capacity provider
91
+ const capacityProvider = new AsgCapacityProvider(this, "ClickHouseCapacityProvider", {
92
+ autoScalingGroup: asg,
93
+ enableManagedDraining: true,
94
+ enableManagedTerminationProtection: false
95
+ });
96
+ cluster.addAsgCapacityProvider(capacityProvider);
97
+ // 6. Task definition with bind mount for EBS volume
98
+ const taskDefinition = new Ec2TaskDefinition(this, "ClickHouseTaskDefinition", {
99
+ family: CLICKHOUSE_CLUSTER_NAME,
100
+ networkMode: NetworkMode.AWS_VPC
101
+ });
102
+ taskDefinition.addVolume({
103
+ name: "clickhouse-data",
104
+ host: {
105
+ sourcePath: CLICKHOUSE_DATA_MOUNT_PATH
106
+ }
107
+ });
108
+ taskDefinition.addVolume({
109
+ name: "clickhouse-config",
110
+ host: {
111
+ sourcePath: `${CLICKHOUSE_DATA_MOUNT_PATH}/${CLICKHOUSE_CONFIG_SUBDIR}`
112
+ }
113
+ });
114
+ taskDefinition.addVolume({
115
+ name: "clickhouse-users",
116
+ host: {
117
+ sourcePath: `${CLICKHOUSE_DATA_MOUNT_PATH}/${CLICKHOUSE_USERS_SUBDIR}`
118
+ }
119
+ });
120
+ // 7. Container
121
+ const container = taskDefinition.addContainer("clickhouse", {
122
+ image: ContainerImage.fromRegistry(CLICKHOUSE_IMAGE),
123
+ memoryLimitMiB: CLICKHOUSE_TASK_MEMORY_MIB,
124
+ cpu: CLICKHOUSE_TASK_CPU_UNITS,
125
+ logging: LogDriver.awsLogs({
126
+ streamPrefix: "clickhouse",
127
+ logRetention: RetentionDays.TWO_WEEKS
128
+ }),
129
+ healthCheck: {
130
+ command: [
131
+ "CMD-SHELL",
132
+ `curl -f http://localhost:${CLICKHOUSE_HTTP_PORT}/?query=SELECT%201 || exit 1`
133
+ ],
134
+ interval: Duration.seconds(CLICKHOUSE_HEALTH_CHECK.INTERVAL_SECONDS),
135
+ timeout: Duration.seconds(CLICKHOUSE_HEALTH_CHECK.TIMEOUT_SECONDS),
136
+ retries: CLICKHOUSE_HEALTH_CHECK.RETRIES,
137
+ startPeriod: Duration.seconds(CLICKHOUSE_HEALTH_CHECK.START_PERIOD_SECONDS)
138
+ },
139
+ secrets: {
140
+ CLICKHOUSE_APP_PASSWORD: EcsSecret.fromSecretsManager(appPasswordSecret.secret),
141
+ CLICKHOUSE_AUDIT_PASSWORD: EcsSecret.fromSecretsManager(auditPasswordSecret.secret),
142
+ ...(props.r2Config
143
+ ? {
144
+ R2_ACCESS_KEY: EcsSecret.fromSecretsManager(props.r2Config.accessKeySecret),
145
+ R2_SECRET_KEY: EcsSecret.fromSecretsManager(props.r2Config.secretKeySecret)
146
+ }
147
+ : {})
148
+ },
149
+ portMappings: [
150
+ { containerPort: CLICKHOUSE_HTTP_PORT, hostPort: CLICKHOUSE_HTTP_PORT },
151
+ {
152
+ containerPort: CLICKHOUSE_NATIVE_PORT,
153
+ hostPort: CLICKHOUSE_NATIVE_PORT
154
+ },
155
+ {
156
+ containerPort: CLICKHOUSE_PROMETHEUS_PORT,
157
+ hostPort: CLICKHOUSE_PROMETHEUS_PORT
158
+ }
159
+ ]
160
+ });
161
+ container.addMountPoints({
162
+ sourceVolume: "clickhouse-data",
163
+ containerPath: "/var/lib/clickhouse",
164
+ readOnly: false
165
+ }, {
166
+ sourceVolume: "clickhouse-config",
167
+ containerPath: "/etc/clickhouse-server/config.d",
168
+ readOnly: true
169
+ }, {
170
+ sourceVolume: "clickhouse-users",
171
+ containerPath: "/etc/clickhouse-server/users.d",
172
+ readOnly: true
173
+ });
174
+ // 8. ECS service with Cloud Map registration for optimise task discovery
175
+ const clickHouseHost = `${CLICKHOUSE_CLOUDMAP_SERVICE_NAME}.${CLICKHOUSE_CLOUDMAP_NAMESPACE}`;
176
+ new Ec2Service(this, "ClickHouseService", {
177
+ cluster,
178
+ taskDefinition,
179
+ desiredCount: 1,
180
+ capacityProviderStrategies: [
181
+ {
182
+ capacityProvider: capacityProvider.capacityProviderName,
183
+ weight: 1
184
+ }
185
+ ],
186
+ circuitBreaker: { rollback: true },
187
+ cloudMapOptions: {
188
+ name: CLICKHOUSE_CLOUDMAP_SERVICE_NAME
189
+ }
190
+ });
191
+ // 9. Scheduled OPTIMIZE TABLE FINAL task (deduplicates ReplacingMergeTree tables)
192
+ const optimiseQuery = [
193
+ ...REPLACING_MERGE_TREE_TABLES.map((table) => `OPTIMIZE TABLE analytics.${table} FINAL`),
194
+ ...OPTIMISE_MV_TABLES.map((table) => `OPTIMIZE TABLE analytics.${table}`)
195
+ ].join("; ");
196
+ new ScheduledEc2Task(this, "ClickHouseOptimiseTask", {
197
+ cluster,
198
+ schedule: Schedule.expression(OPTIMISE_FINAL_SCHEDULE),
199
+ scheduledEc2TaskImageOptions: {
200
+ image: ContainerImage.fromRegistry(CLICKHOUSE_IMAGE),
201
+ memoryLimitMiB: OPTIMISE_TASK_MEMORY_MIB,
202
+ cpu: OPTIMISE_TASK_CPU_UNITS,
203
+ command: [
204
+ "clickhouse-client",
205
+ "--host",
206
+ clickHouseHost,
207
+ "--port",
208
+ String(CLICKHOUSE_NATIVE_PORT),
209
+ "--user",
210
+ "schema_admin",
211
+ "--query",
212
+ `${optimiseQuery};`
213
+ ],
214
+ secrets: {
215
+ CLICKHOUSE_PASSWORD: EcsSecret.fromSecretsManager(schemaPasswordSecret.secret)
216
+ },
217
+ logDriver: LogDriver.awsLogs({
218
+ streamPrefix: "clickhouse-optimise",
219
+ logRetention: RetentionDays.ONE_WEEK
220
+ })
221
+ },
222
+ securityGroups: [securityGroup],
223
+ subnetSelection: {
224
+ subnetType
225
+ }
226
+ });
227
+ // 10. S3 bucket for weekly backups
228
+ const backupBucket = new S3Bucket(this, "ClickHouseBackupBucket", {
229
+ versioned: true,
230
+ lifecycleRules: [
231
+ {
232
+ enabled: true,
233
+ expiration: Duration.days(BACKUP_RETENTION_DAYS),
234
+ noncurrentVersionExpiration: Duration.days(BACKUP_RETENTION_DAYS)
235
+ }
236
+ ]
237
+ });
238
+ // 11. Scheduled weekly backup to S3
239
+ const backupDestUrl = `https://${backupBucket.bucketName}.s3.${Stack.of(this).region}.amazonaws.com/`;
240
+ const backupTask = new ScheduledEc2Task(this, "ClickHouseBackupTask", {
241
+ cluster,
242
+ schedule: Schedule.expression(BACKUP_SCHEDULE),
243
+ scheduledEc2TaskImageOptions: {
244
+ image: ContainerImage.fromRegistry(CLICKHOUSE_IMAGE),
245
+ memoryLimitMiB: BACKUP_TASK_MEMORY_MIB,
246
+ cpu: BACKUP_TASK_CPU_UNITS,
247
+ command: [
248
+ "sh",
249
+ "-c",
250
+ `STAMP=$(date +%Y%m%d-%H%M%S) && clickhouse-client --host ${clickHouseHost} --port ${CLICKHOUSE_NATIVE_PORT} --user backup_reader --password "$CLICKHOUSE_BACKUP_PASSWORD" --query "BACKUP DATABASE analytics TO S3('${backupDestUrl}weekly-$STAMP/')"`
251
+ ],
252
+ secrets: {
253
+ CLICKHOUSE_BACKUP_PASSWORD: EcsSecret.fromSecretsManager(backupPasswordSecret.secret)
254
+ },
255
+ logDriver: LogDriver.awsLogs({
256
+ streamPrefix: "clickhouse-backup",
257
+ logRetention: RetentionDays.TWO_WEEKS
258
+ })
259
+ },
260
+ securityGroups: [securityGroup],
261
+ subnetSelection: {
262
+ subnetType
263
+ }
264
+ });
265
+ // 12. Grant S3 write access to the backup task role
266
+ backupBucket.grantReadWrite(backupTask.taskDefinition.taskRole);
267
+ // 13. Grant secret read to execution role
268
+ const executionRole = taskDefinition.executionRole;
269
+ if (!executionRole) {
270
+ throw new Error("ClickHouse task definition has no execution role — cannot grant secret access");
271
+ }
272
+ appPasswordSecret.secret.grantRead(executionRole);
273
+ auditPasswordSecret.secret.grantRead(executionRole);
274
+ backupPasswordSecret.secret.grantRead(executionRole);
275
+ schemaPasswordSecret.secret.grantRead(executionRole);
276
+ // 14. Connections and outputs
277
+ this.connections = new Connections({
278
+ securityGroups: [securityGroup],
279
+ defaultPort: Port.tcp(CLICKHOUSE_HTTP_PORT)
280
+ });
281
+ this.outputs = {
282
+ securityGroup,
283
+ backupBucket,
284
+ secrets: {
285
+ appPassword: appPasswordSecret.secret,
286
+ auditPassword: auditPasswordSecret.secret,
287
+ backupPassword: backupPasswordSecret.secret,
288
+ schemaPassword: schemaPasswordSecret.secret
289
+ }
290
+ };
291
+ }
292
+ }
@@ -0,0 +1,73 @@
1
+ /** Cluster/task family name used for ECS resources. */
2
+ export declare const CLICKHOUSE_CLUSTER_NAME = "clickhouse-analytics";
3
+ /** Default EC2 instance type for ClickHouse (Graviton — best cost/performance). */
4
+ export declare const DEFAULT_CLICKHOUSE_INSTANCE_TYPE = "t4g.medium";
5
+ /** ClickHouse container image. */
6
+ export declare const CLICKHOUSE_IMAGE = "clickhouse/clickhouse-server:26.3-alpine";
7
+ /** EBS volume configuration. */
8
+ export declare const CLICKHOUSE_EBS_VOLUME_SIZE_GB = 80;
9
+ export declare const CLICKHOUSE_EBS_IOPS = 3000;
10
+ export declare const CLICKHOUSE_EBS_THROUGHPUT_MBPS = 125;
11
+ /** ECS task resource allocation (t4g.medium = 4 GB total). */
12
+ export declare const CLICKHOUSE_TASK_MEMORY_MIB = 3072;
13
+ export declare const CLICKHOUSE_TASK_CPU_UNITS = 1024;
14
+ /** ClickHouse ports. */
15
+ export declare const CLICKHOUSE_HTTP_PORT = 8123;
16
+ export declare const CLICKHOUSE_NATIVE_PORT = 9000;
17
+ export declare const CLICKHOUSE_PROMETHEUS_PORT = 9363;
18
+ /** EBS device name for the data volume (must match user data script). */
19
+ export declare const CLICKHOUSE_EBS_DEVICE_NAME = "/dev/xvdf";
20
+ /** EBS mount path on the EC2 host. */
21
+ export declare const CLICKHOUSE_DATA_MOUNT_PATH = "/mnt/clickhouse-data";
22
+ /** Secrets Manager path prefix. */
23
+ export declare const CLICKHOUSE_SECRETS_PREFIX = "fjall/clickhouse";
24
+ /** Secret names (under the prefix). */
25
+ export declare const CLICKHOUSE_SECRET_NAMES: {
26
+ readonly APP_PASSWORD: "app-password";
27
+ readonly AUDIT_PASSWORD: "audit-password";
28
+ readonly BACKUP_PASSWORD: "backup-password";
29
+ readonly SCHEMA_PASSWORD: "schema-password";
30
+ };
31
+ /** Shared secret generation options (all ClickHouse users share the same policy). */
32
+ export declare const CLICKHOUSE_SECRET_OPTIONS: {
33
+ readonly excludePunctuation: true;
34
+ readonly passwordLength: 32;
35
+ };
36
+ /** Health check configuration. */
37
+ export declare const CLICKHOUSE_HEALTH_CHECK: {
38
+ readonly INTERVAL_SECONDS: 30;
39
+ readonly TIMEOUT_SECONDS: 5;
40
+ readonly RETRIES: 3;
41
+ readonly START_PERIOD_SECONDS: 60;
42
+ };
43
+ /** OPTIMIZE TABLE FINAL schedule.
44
+ * RMT tables carry min_age_to_force_merge_seconds=600 so the engine already merges
45
+ * old parts within 10 min; this task is a safety net for MVs (no engine-level setting)
46
+ * and for ReplacingMergeTree dedup under skewed write patterns. 6 hours is sufficient. */
47
+ export declare const OPTIMISE_FINAL_SCHEDULE = "rate(6 hours)";
48
+ /** Tables requiring periodic OPTIMIZE FINAL (ReplacingMergeTree only).
49
+ * Keep in sync with REPLACING_MERGE_TREE_TABLES in
50
+ * webapp/app/.server/lib/clickhouse/tenantQuery.ts (auto-FINAL). */
51
+ export declare const REPLACING_MERGE_TREE_TABLES: readonly ["application_metrics", "cost_records", "log_fingerprints", "insights", "asset_inventory"];
52
+ /** Subdirectory on the EBS volume for server config files (must match CDK volume mount). */
53
+ export declare const CLICKHOUSE_CONFIG_SUBDIR = "server-config.d";
54
+ /** Subdirectory on the EBS volume for users config files (must match CDK volume mount). */
55
+ export declare const CLICKHOUSE_USERS_SUBDIR = "server-users.d";
56
+ /** Cloud Map namespace for ClickHouse service discovery. */
57
+ export declare const CLICKHOUSE_CLOUDMAP_NAMESPACE = "clickhouse.local";
58
+ /** Cloud Map service name (resolves to clickhouse.clickhouse.local). */
59
+ export declare const CLICKHOUSE_CLOUDMAP_SERVICE_NAME = "clickhouse";
60
+ /** Materialised views that benefit from periodic OPTIMIZE to reduce part count at read time.
61
+ * These are not ReplacingMergeTree (no dedup needed) but un-merged parts force
62
+ * read-time aggregation which degrades query performance. */
63
+ export declare const OPTIMISE_MV_TABLES: readonly ["metrics_hourly_mv", "metrics_daily_mv", "response_time_quantiles_hourly_mv", "deployment_duration_quantiles_daily_mv", "log_severity_hourly_mv", "compliance_score_daily_mv", "ai_usage_daily_mv"];
64
+ /** Resource allocation for the lightweight optimise task. */
65
+ export declare const OPTIMISE_TASK_MEMORY_MIB = 256;
66
+ export declare const OPTIMISE_TASK_CPU_UNITS = 256;
67
+ /** Automated backup schedule (weekly, Sunday 03:00 UTC — low-traffic window). */
68
+ export declare const BACKUP_SCHEDULE = "cron(0 3 ? * SUN *)";
69
+ /** Resource allocation for the backup task (lightweight — clickhouse-client only). */
70
+ export declare const BACKUP_TASK_MEMORY_MIB = 256;
71
+ export declare const BACKUP_TASK_CPU_UNITS = 256;
72
+ /** Backup object expiration: 14 days (retains 2 weekly snapshots). */
73
+ export declare const BACKUP_RETENTION_DAYS = 14;
@@ -0,0 +1,87 @@
1
+ /** Cluster/task family name used for ECS resources. */
2
+ export const CLICKHOUSE_CLUSTER_NAME = "clickhouse-analytics";
3
+ /** Default EC2 instance type for ClickHouse (Graviton — best cost/performance). */
4
+ export const DEFAULT_CLICKHOUSE_INSTANCE_TYPE = "t4g.medium";
5
+ /** ClickHouse container image. */
6
+ export const CLICKHOUSE_IMAGE = "clickhouse/clickhouse-server:26.3-alpine";
7
+ /** EBS volume configuration. */
8
+ export const CLICKHOUSE_EBS_VOLUME_SIZE_GB = 80;
9
+ export const CLICKHOUSE_EBS_IOPS = 3000;
10
+ export const CLICKHOUSE_EBS_THROUGHPUT_MBPS = 125;
11
+ /** ECS task resource allocation (t4g.medium = 4 GB total). */
12
+ export const CLICKHOUSE_TASK_MEMORY_MIB = 3072;
13
+ export const CLICKHOUSE_TASK_CPU_UNITS = 1024;
14
+ /** ClickHouse ports. */
15
+ export const CLICKHOUSE_HTTP_PORT = 8123;
16
+ export const CLICKHOUSE_NATIVE_PORT = 9000;
17
+ export const CLICKHOUSE_PROMETHEUS_PORT = 9363;
18
+ /** EBS device name for the data volume (must match user data script). */
19
+ export const CLICKHOUSE_EBS_DEVICE_NAME = "/dev/xvdf";
20
+ /** EBS mount path on the EC2 host. */
21
+ export const CLICKHOUSE_DATA_MOUNT_PATH = "/mnt/clickhouse-data";
22
+ /** Secrets Manager path prefix. */
23
+ export const CLICKHOUSE_SECRETS_PREFIX = "fjall/clickhouse";
24
+ /** Secret names (under the prefix). */
25
+ export const CLICKHOUSE_SECRET_NAMES = {
26
+ APP_PASSWORD: "app-password",
27
+ AUDIT_PASSWORD: "audit-password",
28
+ BACKUP_PASSWORD: "backup-password",
29
+ SCHEMA_PASSWORD: "schema-password"
30
+ };
31
+ /** Shared secret generation options (all ClickHouse users share the same policy). */
32
+ export const CLICKHOUSE_SECRET_OPTIONS = {
33
+ excludePunctuation: true,
34
+ passwordLength: 32
35
+ };
36
+ /** Health check configuration. */
37
+ export const CLICKHOUSE_HEALTH_CHECK = {
38
+ INTERVAL_SECONDS: 30,
39
+ TIMEOUT_SECONDS: 5,
40
+ RETRIES: 3,
41
+ START_PERIOD_SECONDS: 60
42
+ };
43
+ /** OPTIMIZE TABLE FINAL schedule.
44
+ * RMT tables carry min_age_to_force_merge_seconds=600 so the engine already merges
45
+ * old parts within 10 min; this task is a safety net for MVs (no engine-level setting)
46
+ * and for ReplacingMergeTree dedup under skewed write patterns. 6 hours is sufficient. */
47
+ export const OPTIMISE_FINAL_SCHEDULE = "rate(6 hours)";
48
+ /** Tables requiring periodic OPTIMIZE FINAL (ReplacingMergeTree only).
49
+ * Keep in sync with REPLACING_MERGE_TREE_TABLES in
50
+ * webapp/app/.server/lib/clickhouse/tenantQuery.ts (auto-FINAL). */
51
+ export const REPLACING_MERGE_TREE_TABLES = [
52
+ "application_metrics",
53
+ "cost_records",
54
+ "log_fingerprints",
55
+ "insights",
56
+ "asset_inventory"
57
+ ];
58
+ /** Subdirectory on the EBS volume for server config files (must match CDK volume mount). */
59
+ export const CLICKHOUSE_CONFIG_SUBDIR = "server-config.d";
60
+ /** Subdirectory on the EBS volume for users config files (must match CDK volume mount). */
61
+ export const CLICKHOUSE_USERS_SUBDIR = "server-users.d";
62
+ /** Cloud Map namespace for ClickHouse service discovery. */
63
+ export const CLICKHOUSE_CLOUDMAP_NAMESPACE = "clickhouse.local";
64
+ /** Cloud Map service name (resolves to clickhouse.clickhouse.local). */
65
+ export const CLICKHOUSE_CLOUDMAP_SERVICE_NAME = "clickhouse";
66
+ /** Materialised views that benefit from periodic OPTIMIZE to reduce part count at read time.
67
+ * These are not ReplacingMergeTree (no dedup needed) but un-merged parts force
68
+ * read-time aggregation which degrades query performance. */
69
+ export const OPTIMISE_MV_TABLES = [
70
+ "metrics_hourly_mv",
71
+ "metrics_daily_mv",
72
+ "response_time_quantiles_hourly_mv",
73
+ "deployment_duration_quantiles_daily_mv",
74
+ "log_severity_hourly_mv",
75
+ "compliance_score_daily_mv",
76
+ "ai_usage_daily_mv"
77
+ ];
78
+ /** Resource allocation for the lightweight optimise task. */
79
+ export const OPTIMISE_TASK_MEMORY_MIB = 256;
80
+ export const OPTIMISE_TASK_CPU_UNITS = 256;
81
+ /** Automated backup schedule (weekly, Sunday 03:00 UTC — low-traffic window). */
82
+ export const BACKUP_SCHEDULE = "cron(0 3 ? * SUN *)";
83
+ /** Resource allocation for the backup task (lightweight — clickhouse-client only). */
84
+ export const BACKUP_TASK_MEMORY_MIB = 256;
85
+ export const BACKUP_TASK_CPU_UNITS = 256;
86
+ /** Backup object expiration: 14 days (retains 2 weekly snapshots). */
87
+ export const BACKUP_RETENTION_DAYS = 14;
@@ -0,0 +1,13 @@
1
+ import { type ISecurityGroup, type IVpc } from "aws-cdk-lib/aws-ec2";
2
+ import type { Construct } from "constructs";
3
+ import { SecurityGroup } from "../networking/securityGroup.js";
4
+ /**
5
+ * Creates the ClickHouse security group.
6
+ *
7
+ * Inbound:
8
+ * - TCP 8123 from webapp ECS service SG (HTTP queries)
9
+ *
10
+ * Outbound:
11
+ * - HTTPS 443 to 0.0.0.0/0 (R2 endpoint + Secrets Manager)
12
+ */
13
+ export declare function createClickHouseSecurityGroup(scope: Construct, vpc: IVpc, webappSecurityGroup: ISecurityGroup): SecurityGroup;
@@ -0,0 +1,28 @@
1
+ import { Peer, Port } from "aws-cdk-lib/aws-ec2";
2
+ import { SecurityGroup } from "../networking/securityGroup.js";
3
+ import { CLICKHOUSE_HTTP_PORT, CLICKHOUSE_NATIVE_PORT } from "./clickhouseConstants.js";
4
+ /**
5
+ * Creates the ClickHouse security group.
6
+ *
7
+ * Inbound:
8
+ * - TCP 8123 from webapp ECS service SG (HTTP queries)
9
+ *
10
+ * Outbound:
11
+ * - HTTPS 443 to 0.0.0.0/0 (R2 endpoint + Secrets Manager)
12
+ */
13
+ export function createClickHouseSecurityGroup(scope, vpc, webappSecurityGroup) {
14
+ const sg = new SecurityGroup(scope, "ClickHouseSecurityGroup", {
15
+ vpc,
16
+ description: "Security group for ClickHouse analytics instance",
17
+ allowAllOutbound: false
18
+ });
19
+ // Inbound: HTTP API from webapp
20
+ sg.addIngressRule(webappSecurityGroup, Port.tcp(CLICKHOUSE_HTTP_PORT), "ClickHouse HTTP API from webapp ECS service");
21
+ // Inbound: Native protocol from optimise scheduled task (same SG, self-referencing)
22
+ sg.addIngressRule(sg, Port.tcp(CLICKHOUSE_NATIVE_PORT), "ClickHouse native protocol from optimise task");
23
+ // Outbound: HTTPS for R2 cold storage and Secrets Manager
24
+ sg.addEgressRule(Peer.anyIpv4(), Port.tcp(443), "HTTPS to R2 and Secrets Manager endpoints");
25
+ // Outbound: Native protocol to ClickHouse (optimise task connection)
26
+ sg.addEgressRule(sg, Port.tcp(CLICKHOUSE_NATIVE_PORT), "ClickHouse native protocol for optimise task");
27
+ return sg;
28
+ }
@@ -0,0 +1,47 @@
1
+ import type { IVpc, ISecurityGroup } from "aws-cdk-lib/aws-ec2";
2
+ import type { IBucket } from "aws-cdk-lib/aws-s3";
3
+ import type { ISecret } from "aws-cdk-lib/aws-secretsmanager";
4
+ /** Props for the ClickHouse CDK construct. */
5
+ export interface ClickHouseProps {
6
+ /** VPC to deploy into. */
7
+ vpc: IVpc;
8
+ /**
9
+ * EC2 instance type for ClickHouse.
10
+ * Overridden by CDK context parameter `clickhouseInstanceType` if set.
11
+ * Default: t4g.medium (4 GB RAM).
12
+ */
13
+ instanceType?: string;
14
+ /**
15
+ * Security group of the webapp ECS service.
16
+ * Used to allow inbound HTTP (8123) from the webapp.
17
+ */
18
+ webappSecurityGroup: ISecurityGroup;
19
+ /**
20
+ * R2 configuration for cold storage.
21
+ * If omitted, tiered storage is disabled (local-only).
22
+ */
23
+ r2Config?: ClickHouseR2Config;
24
+ }
25
+ /** Cloudflare R2 configuration for tiered storage and backups. */
26
+ export interface ClickHouseR2Config {
27
+ /** Cloudflare account ID. */
28
+ accountId: string;
29
+ /** R2 access key (stored in Secrets Manager). */
30
+ accessKeySecret: ISecret;
31
+ /** R2 secret key (stored in Secrets Manager). */
32
+ secretKeySecret: ISecret;
33
+ }
34
+ /** Outputs from the ClickHouse construct for use by other constructs. */
35
+ export interface ClickHouseOutputs {
36
+ /** Security group for the ClickHouse instance (for connection rules). */
37
+ securityGroup: ISecurityGroup;
38
+ /** S3 bucket for weekly automated backups (for restore operations). */
39
+ backupBucket: IBucket;
40
+ /** Secrets Manager secrets for ClickHouse passwords. */
41
+ secrets: {
42
+ appPassword: ISecret;
43
+ auditPassword: ISecret;
44
+ backupPassword: ISecret;
45
+ schemaPassword: ISecret;
46
+ };
47
+ }
@@ -0,0 +1,5 @@
1
+ export interface ClickHouseUserDataOptions {
2
+ /** Cloudflare account ID for R2 cold storage. If omitted, local-only storage is used. */
3
+ cfAccountId?: string;
4
+ }
5
+ export declare function generateClickHouseUserData(options?: ClickHouseUserDataOptions): string;