@incloodsolutions/devkit 0.0.1 → 0.0.3

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 (154) hide show
  1. package/README.md +42 -16
  2. package/dist/aws/cdk/constructs/api-gateway-construct.cjs +95 -0
  3. package/dist/aws/cdk/constructs/api-gateway-construct.cjs.map +1 -0
  4. package/dist/aws/cdk/constructs/api-gateway-construct.d.cts +80 -0
  5. package/dist/aws/cdk/constructs/api-gateway-construct.d.ts +80 -0
  6. package/dist/aws/cdk/constructs/api-gateway-construct.js +93 -0
  7. package/dist/aws/cdk/constructs/api-gateway-construct.js.map +1 -0
  8. package/dist/aws/cdk/constructs/api-gateway-v2-construct.cjs +77 -0
  9. package/dist/aws/cdk/constructs/api-gateway-v2-construct.cjs.map +1 -0
  10. package/dist/aws/cdk/constructs/api-gateway-v2-construct.d.cts +55 -0
  11. package/dist/aws/cdk/constructs/api-gateway-v2-construct.d.ts +55 -0
  12. package/dist/aws/cdk/constructs/api-gateway-v2-construct.js +75 -0
  13. package/dist/aws/cdk/constructs/api-gateway-v2-construct.js.map +1 -0
  14. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.cjs +65 -0
  15. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.cjs.map +1 -0
  16. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.d.cts +73 -0
  17. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.d.ts +73 -0
  18. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.js +63 -0
  19. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.js.map +1 -0
  20. package/dist/aws/cdk/constructs/cloudfront-construct.cjs +68 -0
  21. package/dist/aws/cdk/constructs/cloudfront-construct.cjs.map +1 -0
  22. package/dist/aws/cdk/constructs/cloudfront-construct.d.cts +36 -0
  23. package/dist/aws/cdk/constructs/cloudfront-construct.d.ts +36 -0
  24. package/dist/aws/cdk/constructs/cloudfront-construct.js +66 -0
  25. package/dist/aws/cdk/constructs/cloudfront-construct.js.map +1 -0
  26. package/dist/aws/cdk/constructs/cloudwatch-construct.cjs +43 -0
  27. package/dist/aws/cdk/constructs/cloudwatch-construct.cjs.map +1 -0
  28. package/dist/aws/cdk/constructs/cloudwatch-construct.d.cts +36 -0
  29. package/dist/aws/cdk/constructs/cloudwatch-construct.d.ts +36 -0
  30. package/dist/aws/cdk/constructs/cloudwatch-construct.js +41 -0
  31. package/dist/aws/cdk/constructs/cloudwatch-construct.js.map +1 -0
  32. package/dist/aws/cdk/constructs/dynamo-db-construct.cjs +113 -0
  33. package/dist/aws/cdk/constructs/dynamo-db-construct.cjs.map +1 -0
  34. package/dist/aws/cdk/constructs/dynamo-db-construct.d.cts +53 -0
  35. package/dist/aws/cdk/constructs/dynamo-db-construct.d.ts +53 -0
  36. package/dist/aws/cdk/constructs/dynamo-db-construct.js +111 -0
  37. package/dist/aws/cdk/constructs/dynamo-db-construct.js.map +1 -0
  38. package/dist/aws/cdk/constructs/event-bridge-construct.cjs +47 -0
  39. package/dist/aws/cdk/constructs/event-bridge-construct.cjs.map +1 -0
  40. package/dist/aws/cdk/constructs/event-bridge-construct.d.cts +41 -0
  41. package/dist/aws/cdk/constructs/event-bridge-construct.d.ts +41 -0
  42. package/dist/aws/cdk/constructs/event-bridge-construct.js +45 -0
  43. package/dist/aws/cdk/constructs/event-bridge-construct.js.map +1 -0
  44. package/dist/aws/cdk/constructs/index.cjs +881 -0
  45. package/dist/aws/cdk/constructs/index.cjs.map +1 -0
  46. package/dist/aws/cdk/constructs/index.d.cts +34 -0
  47. package/dist/aws/cdk/constructs/index.d.ts +34 -0
  48. package/dist/aws/cdk/constructs/index.js +863 -0
  49. package/dist/aws/cdk/constructs/index.js.map +1 -0
  50. package/dist/aws/cdk/constructs/lambda-authorizer-construct.cjs +37 -0
  51. package/dist/aws/cdk/constructs/lambda-authorizer-construct.cjs.map +1 -0
  52. package/dist/aws/cdk/constructs/lambda-authorizer-construct.d.cts +44 -0
  53. package/dist/aws/cdk/constructs/lambda-authorizer-construct.d.ts +44 -0
  54. package/dist/aws/cdk/constructs/lambda-authorizer-construct.js +35 -0
  55. package/dist/aws/cdk/constructs/lambda-authorizer-construct.js.map +1 -0
  56. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.cjs +47 -0
  57. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.cjs.map +1 -0
  58. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.d.cts +45 -0
  59. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.d.ts +45 -0
  60. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.js +45 -0
  61. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.js.map +1 -0
  62. package/dist/aws/cdk/constructs/lambda-construct.cjs +82 -0
  63. package/dist/aws/cdk/constructs/lambda-construct.cjs.map +1 -0
  64. package/dist/aws/cdk/constructs/lambda-construct.d.cts +37 -0
  65. package/dist/aws/cdk/constructs/lambda-construct.d.ts +37 -0
  66. package/dist/aws/cdk/constructs/lambda-construct.js +80 -0
  67. package/dist/aws/cdk/constructs/lambda-construct.js.map +1 -0
  68. package/dist/aws/cdk/constructs/lambda-layer-construct.cjs +72 -0
  69. package/dist/aws/cdk/constructs/lambda-layer-construct.cjs.map +1 -0
  70. package/dist/aws/cdk/constructs/lambda-layer-construct.d.cts +52 -0
  71. package/dist/aws/cdk/constructs/lambda-layer-construct.d.ts +52 -0
  72. package/dist/aws/cdk/constructs/lambda-layer-construct.js +70 -0
  73. package/dist/aws/cdk/constructs/lambda-layer-construct.js.map +1 -0
  74. package/dist/aws/cdk/constructs/role-policy-construct.cjs +53 -0
  75. package/dist/aws/cdk/constructs/role-policy-construct.cjs.map +1 -0
  76. package/dist/aws/cdk/constructs/role-policy-construct.d.cts +44 -0
  77. package/dist/aws/cdk/constructs/role-policy-construct.d.ts +44 -0
  78. package/dist/aws/cdk/constructs/role-policy-construct.js +51 -0
  79. package/dist/aws/cdk/constructs/role-policy-construct.js.map +1 -0
  80. package/dist/aws/cdk/constructs/s3-construct.cjs +38 -0
  81. package/dist/aws/cdk/constructs/s3-construct.cjs.map +1 -0
  82. package/dist/aws/cdk/constructs/s3-construct.d.cts +36 -0
  83. package/dist/aws/cdk/constructs/s3-construct.d.ts +36 -0
  84. package/dist/aws/cdk/constructs/s3-construct.js +36 -0
  85. package/dist/aws/cdk/constructs/s3-construct.js.map +1 -0
  86. package/dist/aws/cdk/constructs/s3-deployment-construct.cjs +168 -0
  87. package/dist/aws/cdk/constructs/s3-deployment-construct.cjs.map +1 -0
  88. package/dist/aws/cdk/constructs/s3-deployment-construct.d.cts +72 -0
  89. package/dist/aws/cdk/constructs/s3-deployment-construct.d.ts +72 -0
  90. package/dist/aws/cdk/constructs/s3-deployment-construct.js +166 -0
  91. package/dist/aws/cdk/constructs/s3-deployment-construct.js.map +1 -0
  92. package/dist/aws/cdk/constructs/sns-construct.cjs +43 -0
  93. package/dist/aws/cdk/constructs/sns-construct.cjs.map +1 -0
  94. package/dist/aws/cdk/constructs/sns-construct.d.cts +45 -0
  95. package/dist/aws/cdk/constructs/sns-construct.d.ts +45 -0
  96. package/dist/aws/cdk/constructs/sns-construct.js +41 -0
  97. package/dist/aws/cdk/constructs/sns-construct.js.map +1 -0
  98. package/dist/aws/cdk/constructs/sqs-construct.cjs +55 -0
  99. package/dist/aws/cdk/constructs/sqs-construct.cjs.map +1 -0
  100. package/dist/aws/cdk/constructs/sqs-construct.d.cts +52 -0
  101. package/dist/aws/cdk/constructs/sqs-construct.d.ts +52 -0
  102. package/dist/aws/cdk/constructs/sqs-construct.js +53 -0
  103. package/dist/aws/cdk/constructs/sqs-construct.js.map +1 -0
  104. package/dist/aws/cdk/constructs/vpc-construct.cjs +33 -0
  105. package/dist/aws/cdk/constructs/vpc-construct.cjs.map +1 -0
  106. package/dist/aws/cdk/constructs/vpc-construct.d.cts +34 -0
  107. package/dist/aws/cdk/constructs/vpc-construct.d.ts +34 -0
  108. package/dist/aws/cdk/constructs/vpc-construct.js +31 -0
  109. package/dist/aws/cdk/constructs/vpc-construct.js.map +1 -0
  110. package/dist/aws/cdk/index.cjs +881 -0
  111. package/dist/aws/cdk/index.cjs.map +1 -0
  112. package/dist/aws/cdk/index.d.cts +34 -0
  113. package/dist/aws/cdk/index.d.ts +34 -0
  114. package/dist/aws/cdk/index.js +863 -0
  115. package/dist/aws/cdk/index.js.map +1 -0
  116. package/dist/aws/cli/index.cjs +4 -0
  117. package/dist/aws/cli/index.cjs.map +1 -0
  118. package/dist/aws/cli/index.d.cts +2 -0
  119. package/dist/aws/cli/index.d.ts +2 -0
  120. package/dist/aws/cli/index.js +3 -0
  121. package/dist/aws/cli/index.js.map +1 -0
  122. package/dist/aws/index.cjs +881 -0
  123. package/dist/aws/index.cjs.map +1 -0
  124. package/dist/aws/index.d.cts +34 -0
  125. package/dist/aws/index.d.ts +34 -0
  126. package/dist/aws/index.js +863 -0
  127. package/dist/aws/index.js.map +1 -0
  128. package/dist/aws/types/index.cjs +4 -0
  129. package/dist/aws/types/index.cjs.map +1 -0
  130. package/dist/aws/types/index.d.cts +18 -0
  131. package/dist/aws/types/index.d.ts +18 -0
  132. package/dist/aws/types/index.js +3 -0
  133. package/dist/aws/types/index.js.map +1 -0
  134. package/dist/index.d.cts +34 -755
  135. package/dist/index.d.ts +34 -755
  136. package/dist/lint/index.cjs +4 -0
  137. package/dist/lint/index.cjs.map +1 -0
  138. package/dist/lint/index.d.cts +2 -0
  139. package/dist/lint/index.d.ts +2 -0
  140. package/dist/lint/index.js +3 -0
  141. package/dist/lint/index.js.map +1 -0
  142. package/dist/prettier/index.cjs +4 -0
  143. package/dist/prettier/index.cjs.map +1 -0
  144. package/dist/prettier/index.d.cts +2 -0
  145. package/dist/prettier/index.d.ts +2 -0
  146. package/dist/prettier/index.js +3 -0
  147. package/dist/prettier/index.js.map +1 -0
  148. package/dist/utility/index.cjs +4 -0
  149. package/dist/utility/index.cjs.map +1 -0
  150. package/dist/utility/index.d.cts +2 -0
  151. package/dist/utility/index.d.ts +2 -0
  152. package/dist/utility/index.js +3 -0
  153. package/dist/utility/index.js.map +1 -0
  154. package/package.json +8 -3
@@ -0,0 +1,166 @@
1
+ import { Construct } from 'constructs';
2
+ import { S3BucketOrigin } from 'aws-cdk-lib/aws-cloudfront-origins';
3
+ import { BucketDeployment } from 'aws-cdk-lib/aws-s3-deployment';
4
+ import { CustomException } from '@incloodsolutions/toolkit';
5
+ import { RemovalPolicy, CfnOutput, Duration } from 'aws-cdk-lib';
6
+ import { Bucket } from 'aws-cdk-lib/aws-s3';
7
+ import { Distribution, ViewerProtocolPolicy } from 'aws-cdk-lib/aws-cloudfront';
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+ var BaseS3Construct = class extends Construct {
12
+ static {
13
+ __name(this, "BaseS3Construct");
14
+ }
15
+ /** The created S3 bucket instance */
16
+ bucket;
17
+ /**
18
+ * @param scope Parent construct
19
+ * @param id Unique construct identifier
20
+ * @param props Configuration for S3 bucket
21
+ */
22
+ constructor(scope, id, props) {
23
+ super(scope, id);
24
+ this.bucket = new Bucket(this, id, {
25
+ ...props.options?.bucketOptions,
26
+ /**
27
+ * Removal policy applied to the bucket
28
+ * Defaults to DESTROY if not explicitly defined
29
+ */
30
+ removalPolicy: props.options?.bucketOptions?.removalPolicy || RemovalPolicy.DESTROY
31
+ });
32
+ new CfnOutput(this, "S3BucketArn", {
33
+ value: this.bucket.bucketArn
34
+ });
35
+ }
36
+ };
37
+ var BaseCloudfrontConstruct = class extends Construct {
38
+ static {
39
+ __name(this, "BaseCloudfrontConstruct");
40
+ }
41
+ /** The created CloudFront distribution instance */
42
+ distribution;
43
+ /**
44
+ * @param scope Parent construct
45
+ * @param id Unique construct identifier
46
+ * @param props Configuration for CloudFront distribution
47
+ */
48
+ constructor(scope, id, props) {
49
+ super(scope, id);
50
+ this.distribution = new Distribution(this, id, {
51
+ ...props.options?.cloudfrontOptions,
52
+ /**
53
+ * Default behaviour configuration
54
+ * Enforces HTTPS if not explicitly defined
55
+ */
56
+ defaultBehavior: {
57
+ ...props.options?.cloudfrontOptions?.defaultBehavior,
58
+ viewerProtocolPolicy: props.options?.cloudfrontOptions?.defaultBehavior?.viewerProtocolPolicy || ViewerProtocolPolicy.REDIRECT_TO_HTTPS
59
+ },
60
+ /**
61
+ * Error response configuration
62
+ *
63
+ * Adds SPA-friendly fallbacks:
64
+ * - 400, 403, 404 responses are redirected to index.html
65
+ */
66
+ errorResponses: [
67
+ ...props.options?.cloudfrontOptions?.errorResponses || [],
68
+ /** Handle 400 errors */
69
+ {
70
+ httpStatus: 400,
71
+ responseHttpStatus: 200,
72
+ responsePagePath: "/index.html",
73
+ ttl: Duration.days(1)
74
+ },
75
+ /** Handle 403 errors */
76
+ {
77
+ httpStatus: 403,
78
+ responseHttpStatus: 200,
79
+ responsePagePath: "/index.html",
80
+ ttl: Duration.days(1)
81
+ },
82
+ /** Handle 404 errors */
83
+ {
84
+ httpStatus: 404,
85
+ responseHttpStatus: 200,
86
+ responsePagePath: "/index.html",
87
+ ttl: Duration.days(1)
88
+ }
89
+ ]
90
+ });
91
+ }
92
+ };
93
+
94
+ // src/aws/cdk/constructs/s3-deployment-construct.ts
95
+ var BaseS3DeploymentConstruct = class extends Construct {
96
+ static {
97
+ __name(this, "BaseS3DeploymentConstruct");
98
+ }
99
+ /** The created or provided S3 bucket */
100
+ bucket;
101
+ /** The created CloudFront distribution */
102
+ distribution;
103
+ /** S3 bucket deployment instance */
104
+ bucketDeployment;
105
+ /**
106
+ * @param scope Parent construct
107
+ * @param id Unique construct identifier
108
+ * @param props Configuration for bucket, distribution, and deployment
109
+ */
110
+ constructor(scope, id, props) {
111
+ super(scope, id);
112
+ if (!props.options?.cloudfrontOptions?.defaultBehavior?.origin && !props?.withS3Bucket && props.withCloudfront) {
113
+ throw new CustomException("Cloudfront distribution S3_Bucket origins must be defined!");
114
+ }
115
+ if (!props.options?.bucketDeploymentOptions?.destinationBucket && !props?.withS3Bucket) {
116
+ throw new CustomException("Deployment S3_Bucket destination must be defined!");
117
+ }
118
+ if (props?.withS3Bucket) {
119
+ this.bucket = new BaseS3Construct(this, "bucket", {
120
+ enableDebug: props.enableDebug,
121
+ options: { bucketOptions: props.options?.bucketOptions }
122
+ }).bucket;
123
+ }
124
+ if (props?.withCloudfront) {
125
+ const s3Origin = props.options?.cloudfrontOptions?.defaultBehavior?.origin || S3BucketOrigin.withOriginAccessControl(this.bucket);
126
+ this.distribution = new BaseCloudfrontConstruct(this, "distribution", {
127
+ enableDebug: props.enableDebug,
128
+ options: {
129
+ cloudfrontOptions: {
130
+ ...props.options?.cloudfrontOptions,
131
+ /**
132
+ * Map additional behaviors and ensure origin is assigned
133
+ */
134
+ additionalBehaviors: Object.entries(props.options?.cloudfrontOptions?.additionalBehaviors || {}).reduce((behavior, [pattern, behaviorOptions]) => {
135
+ behavior[pattern] = {
136
+ ...behaviorOptions,
137
+ origin: behaviorOptions.origin || s3Origin
138
+ };
139
+ return behavior;
140
+ }, {}),
141
+ /**
142
+ * Default behavior configuration
143
+ */
144
+ defaultBehavior: {
145
+ ...props.options?.cloudfrontOptions?.defaultBehavior,
146
+ origin: s3Origin
147
+ }
148
+ }
149
+ }
150
+ }).distribution;
151
+ }
152
+ this.bucketDeployment = new BucketDeployment(this, "deployment", {
153
+ ...props.options?.bucketDeploymentOptions,
154
+ /** Target distribution for cache invalidation */
155
+ distribution: props.options?.bucketDeploymentOptions?.distribution || this.distribution,
156
+ /** Paths to invalidate after deployment */
157
+ distributionPaths: props.options?.bucketDeploymentOptions?.distributionPaths || ["/*"],
158
+ /** Destination S3 bucket */
159
+ destinationBucket: props.options?.bucketDeploymentOptions?.destinationBucket || this.bucket
160
+ });
161
+ }
162
+ };
163
+
164
+ export { BaseS3DeploymentConstruct };
165
+ //# sourceMappingURL=s3-deployment-construct.js.map
166
+ //# sourceMappingURL=s3-deployment-construct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/aws/cdk/constructs/s3-construct.ts","../../../../src/aws/cdk/constructs/cloudfront-construct.ts","../../../../src/aws/cdk/constructs/s3-deployment-construct.ts"],"names":["Construct"],"mappings":"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","file":"s3-deployment-construct.js","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseS3Construct\n *\n * Provides configuration for creating an S3 bucket\n * with optional overrides for bucket properties.\n */\ninterface IS3DeploymentConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** Configuration options for the S3 bucket */\n\treadonly bucketOptions?: BucketProps;\n}>, 'appName' | 'stackName'> { }\n\n/**\n * CDK construct for S3 bucket\n *\n * Responsibilities:\n * - Creates an S3 bucket with configurable options\n * - Applies a default removal policy if not provided\n * - Exposes the bucket ARN as a CloudFormation output\n */\nexport class BaseS3Construct extends Construct {\n\t/** The created S3 bucket instance */\n\treadonly bucket: Bucket;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for S3 bucket\n\t */\n\tconstructor(scope: Construct, id: string, props: IS3DeploymentConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.bucket = new Bucket(this, id, {\n\t\t\t...props.options?.bucketOptions,\n\n\t\t\t/**\n\t\t\t * Removal policy applied to the bucket\n\t\t\t * Defaults to DESTROY if not explicitly defined\n\t\t\t */\n\t\t\tremovalPolicy:\n\t\t\t\tprops.options?.bucketOptions?.removalPolicy\n\t\t\t\t|| RemovalPolicy.DESTROY\n\t\t});\n\n\t\t/**\n\t\t * CloudFormation output exposing the S3 bucket ARN\n\t\t */\n\t\tnew CfnOutput(this, 'S3BucketArn', {\n\t\t\tvalue: this.bucket.bucketArn\n\t\t});\n\t}\n}","import { Construct } from 'constructs';\nimport { Duration } from 'aws-cdk-lib';\nimport { Distribution, DistributionProps, ViewerProtocolPolicy } from 'aws-cdk-lib/aws-cloudfront';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseCloudfrontConstruct\n *\n * Provides configuration for creating a CloudFront distribution\n * with optional overrides for default behaviour and error handling.\n */\ninterface ICloudfrontConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** Partial configuration for the CloudFront distribution */\n\treadonly cloudfrontOptions: Partial<DistributionProps>;\n}>, 'appName' | 'stage' | 'stackName'> { }\n\n/**\n * CDK construct for CloudFront distribution\n *\n * Responsibilities:\n * - Creates a CloudFront distribution with configurable options\n * - Enforces HTTPS redirection by default\n * - Adds fallback error responses for SPA routing (400, 403, 404 → index.html)\n */\nexport class BaseCloudfrontConstruct extends Construct {\n\t/** The created CloudFront distribution instance */\n\treadonly distribution: Distribution;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for CloudFront distribution\n\t */\n\tconstructor(scope: Construct, id: string, props: ICloudfrontConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.distribution = new Distribution(this, id, {\n\t\t\t...props.options?.cloudfrontOptions,\n\n\t\t\t/**\n\t\t\t * Default behaviour configuration\n\t\t\t * Enforces HTTPS if not explicitly defined\n\t\t\t */\n\t\t\tdefaultBehavior: {\n\t\t\t\t...props.options?.cloudfrontOptions?.defaultBehavior,\n\t\t\t\tviewerProtocolPolicy:\n\t\t\t\t\tprops.options?.cloudfrontOptions?.defaultBehavior?.viewerProtocolPolicy\n\t\t\t\t\t|| ViewerProtocolPolicy.REDIRECT_TO_HTTPS\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Error response configuration\n\t\t\t *\n\t\t\t * Adds SPA-friendly fallbacks:\n\t\t\t * - 400, 403, 404 responses are redirected to index.html\n\t\t\t */\n\t\t\terrorResponses: [\n\t\t\t\t...props.options?.cloudfrontOptions?.errorResponses || [],\n\n\t\t\t\t/** Handle 400 errors */\n\t\t\t\t{\n\t\t\t\t\thttpStatus: 400,\n\t\t\t\t\tresponseHttpStatus: 200,\n\t\t\t\t\tresponsePagePath: '/index.html',\n\t\t\t\t\tttl: Duration.days(1)\n\t\t\t\t},\n\n\t\t\t\t/** Handle 403 errors */\n\t\t\t\t{\n\t\t\t\t\thttpStatus: 403,\n\t\t\t\t\tresponseHttpStatus: 200,\n\t\t\t\t\tresponsePagePath: '/index.html',\n\t\t\t\t\tttl: Duration.days(1)\n\t\t\t\t},\n\n\t\t\t\t/** Handle 404 errors */\n\t\t\t\t{\n\t\t\t\t\thttpStatus: 404,\n\t\t\t\t\tresponseHttpStatus: 200,\n\t\t\t\t\tresponsePagePath: '/index.html',\n\t\t\t\t\tttl: Duration.days(1)\n\t\t\t\t},\n\t\t\t],\n\t\t});\n\t}\n}","import { Construct } from 'constructs';\nimport { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';\nimport { S3BucketOrigin } from 'aws-cdk-lib/aws-cloudfront-origins';\nimport { BucketDeployment, BucketDeploymentProps } from 'aws-cdk-lib/aws-s3-deployment';\nimport { BehaviorOptions, Distribution, DistributionProps } from 'aws-cdk-lib/aws-cloudfront';\n\nimport { ObjectType, CustomException } from '@incloodsolutions/toolkit';\n\nimport { BaseS3Construct } from './s3-construct';\nimport { BaseCloudfrontConstruct } from './cloudfront-construct';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseS3DeploymentConstruct\n *\n * Provides configuration for:\n * - Optional S3 bucket creation\n * - Optional CloudFront distribution\n * - S3 bucket deployment\n */\ninterface IS3DeploymentConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** Configuration options for S3 bucket */\n\treadonly bucketOptions?: BucketProps;\n\n\t/**\n\t * Configuration options for CloudFront distribution\n\t *\n\t * Note:\n\t * - `additionalBehaviors` supports dynamic route mappings\n\t * - Origins are automatically resolved if not provided\n\t */\n\treadonly cloudfrontOptions?: Partial<Omit<DistributionProps, 'additionalBehaviors'>> & {\n\t\treadonly additionalBehaviors?: ObjectType<Partial<BehaviorOptions>, string>;\n\t};\n\n\t/**\n\t * Configuration for S3 bucket deployment\n\t *\n\t * Note:\n\t * - `sources` is required\n\t * - `destinationBucket` can be auto-resolved\n\t */\n\treadonly bucketDeploymentOptions: Omit<Partial<BucketDeploymentProps>, 'sources'> & Pick<BucketDeploymentProps, 'sources'>;\n}>, 'appName' | 'stackName'> {\n\t/** Whether to create a new S3 bucket */\n\treadonly withS3Bucket?: boolean;\n\n\t/** Whether to create a CloudFront distribution */\n\treadonly withCloudfront?: boolean;\n}\n\n/**\n * CDK construct for S3 deployment with optional CloudFront integration\n *\n * Responsibilities:\n * - Optionally creates an S3 bucket\n * - Optionally creates a CloudFront distribution with S3 origin\n * - Deploys assets to S3 bucket\n * - Configures CloudFront invalidation paths\n *\n * Behaviour:\n * - Automatically links S3 bucket as CloudFront origin when enabled\n * - Resolves destination bucket and distribution if not explicitly provided\n * - Throws when required dependencies are missing\n */\nexport class BaseS3DeploymentConstruct extends Construct {\n\t/** The created or provided S3 bucket */\n\treadonly bucket: Bucket;\n\n\t/** The created CloudFront distribution */\n\treadonly distribution: Distribution;\n\n\t/** S3 bucket deployment instance */\n\treadonly bucketDeployment: BucketDeployment;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for bucket, distribution, and deployment\n\t */\n\tconstructor(scope: Construct, id: string, props: IS3DeploymentConstructProps) {\n\t\tsuper(scope, id);\n\n\t\t/**\n\t\t * Validate CloudFront origin requirements\n\t\t */\n\t\tif ((!props.options?.cloudfrontOptions?.defaultBehavior?.origin && !props?.withS3Bucket) && props.withCloudfront) {\n\t\t\tthrow new CustomException('Cloudfront distribution S3_Bucket origins must be defined!');\n\t\t}\n\n\t\t/**\n\t\t * Validate deployment destination requirements\n\t\t */\n\t\tif (!props.options?.bucketDeploymentOptions?.destinationBucket && !props?.withS3Bucket) {\n\t\t\tthrow new CustomException('Deployment S3_Bucket destination must be defined!');\n\t\t}\n\n\t\t/**\n\t\t * Create S3 bucket if enabled\n\t\t */\n\t\tif (props?.withS3Bucket) {\n\t\t\tthis.bucket = new BaseS3Construct(this, 'bucket', {\n\t\t\t\tenableDebug: props.enableDebug,\n\t\t\t\toptions: { bucketOptions: props.options?.bucketOptions }\n\t\t\t}).bucket;\n\t\t}\n\n\t\t/**\n\t\t * Create CloudFront distribution if enabled\n\t\t */\n\t\tif (props?.withCloudfront) {\n\n\t\t\t/**\n\t\t\t * Resolve S3 origin for distribution\n\t\t\t */\n\t\t\tconst s3Origin =\n\t\t\t\tprops.options?.cloudfrontOptions?.defaultBehavior?.origin\n\t\t\t\t|| S3BucketOrigin.withOriginAccessControl(this.bucket);\n\n\t\t\tthis.distribution = new BaseCloudfrontConstruct(this, 'distribution', {\n\t\t\t\tenableDebug: props.enableDebug,\n\t\t\t\toptions: {\n\t\t\t\t\tcloudfrontOptions: {\n\t\t\t\t\t\t...props.options?.cloudfrontOptions,\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Map additional behaviors and ensure origin is assigned\n\t\t\t\t\t\t */\n\t\t\t\t\t\tadditionalBehaviors: Object.entries(props.options?.cloudfrontOptions?.additionalBehaviors || {})\n\t\t\t\t\t\t\t.reduce((behavior, [pattern, behaviorOptions]) => {\n\t\t\t\t\t\t\t\tbehavior[pattern] = {\n\t\t\t\t\t\t\t\t\t...behaviorOptions,\n\t\t\t\t\t\t\t\t\torigin: behaviorOptions.origin || s3Origin\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\treturn behavior;\n\t\t\t\t\t\t\t}, {} as typeof props.options.cloudfrontOptions.additionalBehaviors) as ObjectType<BehaviorOptions>,\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Default behavior configuration\n\t\t\t\t\t\t */\n\t\t\t\t\t\tdefaultBehavior: {\n\t\t\t\t\t\t\t...props.options?.cloudfrontOptions?.defaultBehavior,\n\t\t\t\t\t\t\torigin: s3Origin\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}).distribution;\n\t\t}\n\n\t\t/**\n\t\t * Deploy assets to S3 bucket\n\t\t *\n\t\t * Automatically resolves:\n\t\t * - Destination bucket\n\t\t * - CloudFront distribution\n\t\t * - Invalidation paths\n\t\t */\n\t\tthis.bucketDeployment = new BucketDeployment(this, 'deployment', {\n\t\t\t...props.options?.bucketDeploymentOptions,\n\n\t\t\t/** Target distribution for cache invalidation */\n\t\t\tdistribution:\n\t\t\t\tprops.options?.bucketDeploymentOptions?.distribution\n\t\t\t\t|| this.distribution,\n\n\t\t\t/** Paths to invalidate after deployment */\n\t\t\tdistributionPaths:\n\t\t\t\tprops.options?.bucketDeploymentOptions?.distributionPaths\n\t\t\t\t|| ['/*'],\n\n\t\t\t/** Destination S3 bucket */\n\t\t\tdestinationBucket:\n\t\t\t\tprops.options?.bucketDeploymentOptions?.destinationBucket\n\t\t\t\t|| this.bucket\n\t\t} as BucketDeploymentProps);\n\t}\n}"]}
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ var constructs = require('constructs');
4
+ var awsCdkLib = require('aws-cdk-lib');
5
+ var awsSns = require('aws-cdk-lib/aws-sns');
6
+ var awsSnsSubscriptions = require('aws-cdk-lib/aws-sns-subscriptions');
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ var BaseSnsConstruct = class extends constructs.Construct {
11
+ static {
12
+ __name(this, "BaseSnsConstruct");
13
+ }
14
+ /** The created SNS topic instance */
15
+ topic;
16
+ /**
17
+ * @param scope Parent construct
18
+ * @param id Unique construct identifier
19
+ * @param props Configuration for topic and subscriptions
20
+ */
21
+ constructor(scope, id, props) {
22
+ super(scope, id);
23
+ this.topic = new awsSns.Topic(this, id, props.options?.topicOptions);
24
+ if (props.options?.targetFunctions?.length) {
25
+ props.options.targetFunctions.forEach((targetFunction) => {
26
+ this.topic.addSubscription(
27
+ /**
28
+ * Lambda subscription target
29
+ */
30
+ new awsSnsSubscriptions.LambdaSubscription(targetFunction)
31
+ );
32
+ });
33
+ }
34
+ this.topic.applyRemovalPolicy(awsCdkLib.RemovalPolicy.DESTROY);
35
+ new awsCdkLib.CfnOutput(this, "SnsTopicArn", {
36
+ value: this.topic.topicArn
37
+ });
38
+ }
39
+ };
40
+
41
+ exports.BaseSnsConstruct = BaseSnsConstruct;
42
+ //# sourceMappingURL=sns-construct.cjs.map
43
+ //# sourceMappingURL=sns-construct.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/aws/cdk/constructs/sns-construct.ts"],"names":["Construct","Topic","LambdaSubscription","RemovalPolicy","CfnOutput"],"mappings":";;;;;;;;;AAoCO,IAAM,gBAAA,GAAN,cAA+BA,oBAAA,CAAU;AAAA,EApChD;AAoCgD,IAAA,MAAA,CAAA,IAAA,EAAA,kBAAA,CAAA;AAAA;AAAA;AAAA,EAEtC,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAA2B;AACpE,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,QAAQ,IAAIC,YAAA,CAAM,MAAM,EAAA,EAAI,KAAA,CAAM,SAAS,YAAY,CAAA;AAK5D,IAAA,IAAI,KAAA,CAAM,OAAA,EAAS,eAAA,EAAiB,MAAA,EAAQ;AAC3C,MAAA,KAAA,CAAM,OAAA,CAAQ,eAAA,CAAgB,OAAA,CAAQ,CAAC,cAAA,KAAmB;AACzD,QAAA,IAAA,CAAK,KAAA,CAAM,eAAA;AAAA;AAAA;AAAA;AAAA,UAIV,IAAIC,uCAAmB,cAAc;AAAA,SACtC;AAAA,MACD,CAAC,CAAA;AAAA,IACF;AAKA,IAAA,IAAA,CAAK,KAAA,CAAM,kBAAA,CAAmBC,uBAAA,CAAc,OAAO,CAAA;AAKnD,IAAA,IAAIC,mBAAA,CAAU,MAAM,aAAA,EAAe;AAAA,MAClC,KAAA,EAAO,KAAK,KAAA,CAAM;AAAA,KAClB,CAAA;AAAA,EACF;AACD","file":"sns-construct.cjs","sourcesContent":["import { Construct } from 'constructs';\nimport { Function } from 'aws-cdk-lib/aws-lambda';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { Topic, TopicProps } from 'aws-cdk-lib/aws-sns';\nimport { LambdaSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseSnsConstruct\n *\n * Provides configuration for:\n * - SNS topic creation\n * - Lambda subscriptions\n */\ninterface ISnsConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** SNS topic configuration options */\n\treadonly topicOptions: TopicProps;\n\n\t/**\n\t * Lambda functions to subscribe to the topic\n\t *\n\t * Each function will receive messages published to the topic\n\t */\n\treadonly targetFunctions: Function[];\n}>, 'appName' | 'stage' | 'stackName'> { }\n\n/**\n * CDK construct for SNS topic with Lambda subscriptions\n *\n * Responsibilities:\n * - Creates an SNS topic with configurable options\n * - Subscribes one or more Lambda functions to the topic\n * - Applies a removal policy\n * - Exposes the topic ARN as a CloudFormation output\n */\nexport class BaseSnsConstruct extends Construct {\n\t/** The created SNS topic instance */\n\treadonly topic: Topic;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for topic and subscriptions\n\t */\n\tconstructor(scope: Construct, id: string, props: ISnsConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.topic = new Topic(this, id, props.options?.topicOptions);\n\n\t\t/**\n\t\t * Attach Lambda subscriptions to the topic\n\t\t */\n\t\tif (props.options?.targetFunctions?.length) {\n\t\t\tprops.options.targetFunctions.forEach((targetFunction) => {\n\t\t\t\tthis.topic.addSubscription(\n\t\t\t\t\t/**\n\t\t\t\t\t * Lambda subscription target\n\t\t\t\t\t */\n\t\t\t\t\tnew LambdaSubscription(targetFunction)\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * Apply removal policy (useful for non-production environments)\n\t\t */\n\t\tthis.topic.applyRemovalPolicy(RemovalPolicy.DESTROY);\n\n\t\t/**\n\t\t * CloudFormation output exposing the topic ARN\n\t\t */\n\t\tnew CfnOutput(this, 'SnsTopicArn', {\n\t\t\tvalue: this.topic.topicArn,\n\t\t});\n\t}\n}"]}
@@ -0,0 +1,45 @@
1
+ import { Construct } from 'constructs';
2
+ import { Function } from 'aws-cdk-lib/aws-lambda';
3
+ import { Topic, TopicProps } from 'aws-cdk-lib/aws-sns';
4
+ import { IBaseCdkConstructProps } from '../../types/index.cjs';
5
+ import '@incloodsolutions/toolkit';
6
+
7
+ /**
8
+ * Props for BaseSnsConstruct
9
+ *
10
+ * Provides configuration for:
11
+ * - SNS topic creation
12
+ * - Lambda subscriptions
13
+ */
14
+ interface ISnsConstructProps extends Omit<IBaseCdkConstructProps<{
15
+ /** SNS topic configuration options */
16
+ readonly topicOptions: TopicProps;
17
+ /**
18
+ * Lambda functions to subscribe to the topic
19
+ *
20
+ * Each function will receive messages published to the topic
21
+ */
22
+ readonly targetFunctions: Function[];
23
+ }>, 'appName' | 'stage' | 'stackName'> {
24
+ }
25
+ /**
26
+ * CDK construct for SNS topic with Lambda subscriptions
27
+ *
28
+ * Responsibilities:
29
+ * - Creates an SNS topic with configurable options
30
+ * - Subscribes one or more Lambda functions to the topic
31
+ * - Applies a removal policy
32
+ * - Exposes the topic ARN as a CloudFormation output
33
+ */
34
+ declare class BaseSnsConstruct extends Construct {
35
+ /** The created SNS topic instance */
36
+ readonly topic: Topic;
37
+ /**
38
+ * @param scope Parent construct
39
+ * @param id Unique construct identifier
40
+ * @param props Configuration for topic and subscriptions
41
+ */
42
+ constructor(scope: Construct, id: string, props: ISnsConstructProps);
43
+ }
44
+
45
+ export { BaseSnsConstruct };
@@ -0,0 +1,45 @@
1
+ import { Construct } from 'constructs';
2
+ import { Function } from 'aws-cdk-lib/aws-lambda';
3
+ import { Topic, TopicProps } from 'aws-cdk-lib/aws-sns';
4
+ import { IBaseCdkConstructProps } from '../../types/index.js';
5
+ import '@incloodsolutions/toolkit';
6
+
7
+ /**
8
+ * Props for BaseSnsConstruct
9
+ *
10
+ * Provides configuration for:
11
+ * - SNS topic creation
12
+ * - Lambda subscriptions
13
+ */
14
+ interface ISnsConstructProps extends Omit<IBaseCdkConstructProps<{
15
+ /** SNS topic configuration options */
16
+ readonly topicOptions: TopicProps;
17
+ /**
18
+ * Lambda functions to subscribe to the topic
19
+ *
20
+ * Each function will receive messages published to the topic
21
+ */
22
+ readonly targetFunctions: Function[];
23
+ }>, 'appName' | 'stage' | 'stackName'> {
24
+ }
25
+ /**
26
+ * CDK construct for SNS topic with Lambda subscriptions
27
+ *
28
+ * Responsibilities:
29
+ * - Creates an SNS topic with configurable options
30
+ * - Subscribes one or more Lambda functions to the topic
31
+ * - Applies a removal policy
32
+ * - Exposes the topic ARN as a CloudFormation output
33
+ */
34
+ declare class BaseSnsConstruct extends Construct {
35
+ /** The created SNS topic instance */
36
+ readonly topic: Topic;
37
+ /**
38
+ * @param scope Parent construct
39
+ * @param id Unique construct identifier
40
+ * @param props Configuration for topic and subscriptions
41
+ */
42
+ constructor(scope: Construct, id: string, props: ISnsConstructProps);
43
+ }
44
+
45
+ export { BaseSnsConstruct };
@@ -0,0 +1,41 @@
1
+ import { Construct } from 'constructs';
2
+ import { RemovalPolicy, CfnOutput } from 'aws-cdk-lib';
3
+ import { Topic } from 'aws-cdk-lib/aws-sns';
4
+ import { LambdaSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var BaseSnsConstruct = class extends Construct {
9
+ static {
10
+ __name(this, "BaseSnsConstruct");
11
+ }
12
+ /** The created SNS topic instance */
13
+ topic;
14
+ /**
15
+ * @param scope Parent construct
16
+ * @param id Unique construct identifier
17
+ * @param props Configuration for topic and subscriptions
18
+ */
19
+ constructor(scope, id, props) {
20
+ super(scope, id);
21
+ this.topic = new Topic(this, id, props.options?.topicOptions);
22
+ if (props.options?.targetFunctions?.length) {
23
+ props.options.targetFunctions.forEach((targetFunction) => {
24
+ this.topic.addSubscription(
25
+ /**
26
+ * Lambda subscription target
27
+ */
28
+ new LambdaSubscription(targetFunction)
29
+ );
30
+ });
31
+ }
32
+ this.topic.applyRemovalPolicy(RemovalPolicy.DESTROY);
33
+ new CfnOutput(this, "SnsTopicArn", {
34
+ value: this.topic.topicArn
35
+ });
36
+ }
37
+ };
38
+
39
+ export { BaseSnsConstruct };
40
+ //# sourceMappingURL=sns-construct.js.map
41
+ //# sourceMappingURL=sns-construct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/aws/cdk/constructs/sns-construct.ts"],"names":[],"mappings":";;;;;;;AAoCO,IAAM,gBAAA,GAAN,cAA+B,SAAA,CAAU;AAAA,EApChD;AAoCgD,IAAA,MAAA,CAAA,IAAA,EAAA,kBAAA,CAAA;AAAA;AAAA;AAAA,EAEtC,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAA2B;AACpE,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,QAAQ,IAAI,KAAA,CAAM,MAAM,EAAA,EAAI,KAAA,CAAM,SAAS,YAAY,CAAA;AAK5D,IAAA,IAAI,KAAA,CAAM,OAAA,EAAS,eAAA,EAAiB,MAAA,EAAQ;AAC3C,MAAA,KAAA,CAAM,OAAA,CAAQ,eAAA,CAAgB,OAAA,CAAQ,CAAC,cAAA,KAAmB;AACzD,QAAA,IAAA,CAAK,KAAA,CAAM,eAAA;AAAA;AAAA;AAAA;AAAA,UAIV,IAAI,mBAAmB,cAAc;AAAA,SACtC;AAAA,MACD,CAAC,CAAA;AAAA,IACF;AAKA,IAAA,IAAA,CAAK,KAAA,CAAM,kBAAA,CAAmB,aAAA,CAAc,OAAO,CAAA;AAKnD,IAAA,IAAI,SAAA,CAAU,MAAM,aAAA,EAAe;AAAA,MAClC,KAAA,EAAO,KAAK,KAAA,CAAM;AAAA,KAClB,CAAA;AAAA,EACF;AACD","file":"sns-construct.js","sourcesContent":["import { Construct } from 'constructs';\nimport { Function } from 'aws-cdk-lib/aws-lambda';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { Topic, TopicProps } from 'aws-cdk-lib/aws-sns';\nimport { LambdaSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseSnsConstruct\n *\n * Provides configuration for:\n * - SNS topic creation\n * - Lambda subscriptions\n */\ninterface ISnsConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** SNS topic configuration options */\n\treadonly topicOptions: TopicProps;\n\n\t/**\n\t * Lambda functions to subscribe to the topic\n\t *\n\t * Each function will receive messages published to the topic\n\t */\n\treadonly targetFunctions: Function[];\n}>, 'appName' | 'stage' | 'stackName'> { }\n\n/**\n * CDK construct for SNS topic with Lambda subscriptions\n *\n * Responsibilities:\n * - Creates an SNS topic with configurable options\n * - Subscribes one or more Lambda functions to the topic\n * - Applies a removal policy\n * - Exposes the topic ARN as a CloudFormation output\n */\nexport class BaseSnsConstruct extends Construct {\n\t/** The created SNS topic instance */\n\treadonly topic: Topic;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for topic and subscriptions\n\t */\n\tconstructor(scope: Construct, id: string, props: ISnsConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.topic = new Topic(this, id, props.options?.topicOptions);\n\n\t\t/**\n\t\t * Attach Lambda subscriptions to the topic\n\t\t */\n\t\tif (props.options?.targetFunctions?.length) {\n\t\t\tprops.options.targetFunctions.forEach((targetFunction) => {\n\t\t\t\tthis.topic.addSubscription(\n\t\t\t\t\t/**\n\t\t\t\t\t * Lambda subscription target\n\t\t\t\t\t */\n\t\t\t\t\tnew LambdaSubscription(targetFunction)\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * Apply removal policy (useful for non-production environments)\n\t\t */\n\t\tthis.topic.applyRemovalPolicy(RemovalPolicy.DESTROY);\n\n\t\t/**\n\t\t * CloudFormation output exposing the topic ARN\n\t\t */\n\t\tnew CfnOutput(this, 'SnsTopicArn', {\n\t\t\tvalue: this.topic.topicArn,\n\t\t});\n\t}\n}"]}
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var constructs = require('constructs');
4
+ var awsCdkLib = require('aws-cdk-lib');
5
+ var awsSqs = require('aws-cdk-lib/aws-sqs');
6
+ var awsLambda = require('aws-cdk-lib/aws-lambda');
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ var BaseSqsConstruct = class extends constructs.Construct {
11
+ static {
12
+ __name(this, "BaseSqsConstruct");
13
+ }
14
+ /** The created SQS queue instance */
15
+ queue;
16
+ /**
17
+ * @param scope Parent construct
18
+ * @param id Unique construct identifier
19
+ * @param props Configuration for queue and Lambda consumers
20
+ */
21
+ constructor(scope, id, props) {
22
+ super(scope, id);
23
+ this.queue = new awsSqs.Queue(this, id, {
24
+ ...props?.options?.queueOptions,
25
+ /**
26
+ * Removal policy applied to the queue
27
+ * Defaults to DESTROY if not explicitly defined
28
+ */
29
+ removalPolicy: props?.options?.queueOptions?.removalPolicy || awsCdkLib.RemovalPolicy.DESTROY
30
+ });
31
+ if (props?.targetFunctions?.length) {
32
+ props.targetFunctions.forEach((targetFunction, index) => {
33
+ new awsLambda.EventSourceMapping(this, `${id}-eventSourceMap${index + 1}`, {
34
+ ...props?.options?.eventSourceMappingOptions,
35
+ /** Target Lambda function */
36
+ target: targetFunction,
37
+ /** Source SQS queue ARN */
38
+ eventSourceArn: this.queue.queueArn,
39
+ /**
40
+ * Retry attempts for failed batch processing
41
+ * Defaults to 3 if not explicitly defined
42
+ */
43
+ retryAttempts: props?.options?.eventSourceMappingOptions?.retryAttempts || 3
44
+ });
45
+ });
46
+ }
47
+ new awsCdkLib.CfnOutput(this, "SqsQueueArn", {
48
+ value: this.queue.queueArn
49
+ });
50
+ }
51
+ };
52
+
53
+ exports.BaseSqsConstruct = BaseSqsConstruct;
54
+ //# sourceMappingURL=sqs-construct.cjs.map
55
+ //# sourceMappingURL=sqs-construct.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/aws/cdk/constructs/sqs-construct.ts"],"names":["Construct","Queue","RemovalPolicy","EventSourceMapping","CfnOutput"],"mappings":";;;;;;;;;AA2CO,IAAM,gBAAA,GAAN,cAA+BA,oBAAA,CAAU;AAAA,EA3ChD;AA2CgD,IAAA,MAAA,CAAA,IAAA,EAAA,kBAAA,CAAA;AAAA;AAAA;AAAA,EAEtC,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAA2B;AACpE,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAIC,YAAA,CAAM,IAAA,EAAM,EAAA,EAAI;AAAA,MAChC,GAAG,OAAO,OAAA,EAAS,YAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMnB,aAAA,EACC,KAAA,EAAO,OAAA,EAAS,YAAA,EAAc,iBAC3BC,uBAAA,CAAc;AAAA,KAClB,CAAA;AAKD,IAAA,IAAI,KAAA,EAAO,iBAAiB,MAAA,EAAQ;AACnC,MAAA,KAAA,CAAM,eAAA,CAAgB,OAAA,CAAQ,CAAC,cAAA,EAAgB,KAAA,KAAU;AACxD,QAAA,IAAIC,6BAAmB,IAAA,EAAM,CAAA,EAAG,EAAE,CAAA,eAAA,EAAkB,KAAA,GAAQ,CAAC,CAAA,CAAA,EAAI;AAAA,UAChE,GAAG,OAAO,OAAA,EAAS,yBAAA;AAAA;AAAA,UAGnB,MAAA,EAAQ,cAAA;AAAA;AAAA,UAGR,cAAA,EAAgB,KAAK,KAAA,CAAM,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAM3B,aAAA,EACC,KAAA,EAAO,OAAA,EAAS,yBAAA,EAA2B,aAAA,IACxC;AAAA,SACJ,CAAA;AAAA,MACF,CAAC,CAAA;AAAA,IACF;AAKA,IAAA,IAAIC,mBAAA,CAAU,MAAM,aAAA,EAAe;AAAA,MAClC,KAAA,EAAO,KAAK,KAAA,CAAM;AAAA,KAClB,CAAA;AAAA,EACF;AACD","file":"sqs-construct.cjs","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { Queue, QueueProps } from 'aws-cdk-lib/aws-sqs';\nimport { EventSourceMapping, EventSourceMappingProps, Function } from 'aws-cdk-lib/aws-lambda';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseSqsConstruct\n *\n * Provides configuration for:\n * - SQS queue creation\n * - Lambda event source mappings\n */\ninterface ISqsConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** Configuration options for the SQS queue */\n\treadonly queueOptions?: QueueProps;\n\n\t/**\n\t * Configuration for Lambda event source mapping\n\t *\n\t * Note:\n\t * `eventSourceArn` and `target` are managed internally\n\t */\n\treadonly eventSourceMappingOptions?: Omit<EventSourceMappingProps, 'eventSourceArn' | 'target'>;\n}>, 'appName' | 'stage' | 'stackName'> {\n\t/**\n\t * Lambda functions to be triggered by SQS messages\n\t *\n\t * Each function will be connected via an event source mapping\n\t */\n\treadonly targetFunctions?: Function[];\n}\n\n/**\n * CDK construct for SQS queue with Lambda integration\n *\n * Responsibilities:\n * - Creates an SQS queue with configurable options\n * - Attaches one or more Lambda consumers via event source mappings\n * - Applies default retry behaviour\n * - Exposes the queue ARN as a CloudFormation output\n */\nexport class BaseSqsConstruct extends Construct {\n\t/** The created SQS queue instance */\n\treadonly queue: Queue;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for queue and Lambda consumers\n\t */\n\tconstructor(scope: Construct, id: string, props: ISqsConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.queue = new Queue(this, id, {\n\t\t\t...props?.options?.queueOptions,\n\n\t\t\t/**\n\t\t\t * Removal policy applied to the queue\n\t\t\t * Defaults to DESTROY if not explicitly defined\n\t\t\t */\n\t\t\tremovalPolicy:\n\t\t\t\tprops?.options?.queueOptions?.removalPolicy\n\t\t\t\t|| RemovalPolicy.DESTROY\n\t\t});\n\n\t\t/**\n\t\t * Attach Lambda event source mappings for queue consumption\n\t\t */\n\t\tif (props?.targetFunctions?.length) {\n\t\t\tprops.targetFunctions.forEach((targetFunction, index) => {\n\t\t\t\tnew EventSourceMapping(this, `${id}-eventSourceMap${index + 1}`, {\n\t\t\t\t\t...props?.options?.eventSourceMappingOptions,\n\n\t\t\t\t\t/** Target Lambda function */\n\t\t\t\t\ttarget: targetFunction,\n\n\t\t\t\t\t/** Source SQS queue ARN */\n\t\t\t\t\teventSourceArn: this.queue.queueArn,\n\n\t\t\t\t\t/**\n\t\t\t\t\t * Retry attempts for failed batch processing\n\t\t\t\t\t * Defaults to 3 if not explicitly defined\n\t\t\t\t\t */\n\t\t\t\t\tretryAttempts:\n\t\t\t\t\t\tprops?.options?.eventSourceMappingOptions?.retryAttempts\n\t\t\t\t\t\t|| 3\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * CloudFormation output exposing the SQS queue ARN\n\t\t */\n\t\tnew CfnOutput(this, 'SqsQueueArn', {\n\t\t\tvalue: this.queue.queueArn\n\t\t});\n\t}\n}"]}
@@ -0,0 +1,52 @@
1
+ import { Construct } from 'constructs';
2
+ import { Queue, QueueProps } from 'aws-cdk-lib/aws-sqs';
3
+ import { EventSourceMappingProps, Function } from 'aws-cdk-lib/aws-lambda';
4
+ import { IBaseCdkConstructProps } from '../../types/index.cjs';
5
+ import '@incloodsolutions/toolkit';
6
+
7
+ /**
8
+ * Props for BaseSqsConstruct
9
+ *
10
+ * Provides configuration for:
11
+ * - SQS queue creation
12
+ * - Lambda event source mappings
13
+ */
14
+ interface ISqsConstructProps extends Omit<IBaseCdkConstructProps<{
15
+ /** Configuration options for the SQS queue */
16
+ readonly queueOptions?: QueueProps;
17
+ /**
18
+ * Configuration for Lambda event source mapping
19
+ *
20
+ * Note:
21
+ * `eventSourceArn` and `target` are managed internally
22
+ */
23
+ readonly eventSourceMappingOptions?: Omit<EventSourceMappingProps, 'eventSourceArn' | 'target'>;
24
+ }>, 'appName' | 'stage' | 'stackName'> {
25
+ /**
26
+ * Lambda functions to be triggered by SQS messages
27
+ *
28
+ * Each function will be connected via an event source mapping
29
+ */
30
+ readonly targetFunctions?: Function[];
31
+ }
32
+ /**
33
+ * CDK construct for SQS queue with Lambda integration
34
+ *
35
+ * Responsibilities:
36
+ * - Creates an SQS queue with configurable options
37
+ * - Attaches one or more Lambda consumers via event source mappings
38
+ * - Applies default retry behaviour
39
+ * - Exposes the queue ARN as a CloudFormation output
40
+ */
41
+ declare class BaseSqsConstruct extends Construct {
42
+ /** The created SQS queue instance */
43
+ readonly queue: Queue;
44
+ /**
45
+ * @param scope Parent construct
46
+ * @param id Unique construct identifier
47
+ * @param props Configuration for queue and Lambda consumers
48
+ */
49
+ constructor(scope: Construct, id: string, props: ISqsConstructProps);
50
+ }
51
+
52
+ export { BaseSqsConstruct };
@@ -0,0 +1,52 @@
1
+ import { Construct } from 'constructs';
2
+ import { Queue, QueueProps } from 'aws-cdk-lib/aws-sqs';
3
+ import { EventSourceMappingProps, Function } from 'aws-cdk-lib/aws-lambda';
4
+ import { IBaseCdkConstructProps } from '../../types/index.js';
5
+ import '@incloodsolutions/toolkit';
6
+
7
+ /**
8
+ * Props for BaseSqsConstruct
9
+ *
10
+ * Provides configuration for:
11
+ * - SQS queue creation
12
+ * - Lambda event source mappings
13
+ */
14
+ interface ISqsConstructProps extends Omit<IBaseCdkConstructProps<{
15
+ /** Configuration options for the SQS queue */
16
+ readonly queueOptions?: QueueProps;
17
+ /**
18
+ * Configuration for Lambda event source mapping
19
+ *
20
+ * Note:
21
+ * `eventSourceArn` and `target` are managed internally
22
+ */
23
+ readonly eventSourceMappingOptions?: Omit<EventSourceMappingProps, 'eventSourceArn' | 'target'>;
24
+ }>, 'appName' | 'stage' | 'stackName'> {
25
+ /**
26
+ * Lambda functions to be triggered by SQS messages
27
+ *
28
+ * Each function will be connected via an event source mapping
29
+ */
30
+ readonly targetFunctions?: Function[];
31
+ }
32
+ /**
33
+ * CDK construct for SQS queue with Lambda integration
34
+ *
35
+ * Responsibilities:
36
+ * - Creates an SQS queue with configurable options
37
+ * - Attaches one or more Lambda consumers via event source mappings
38
+ * - Applies default retry behaviour
39
+ * - Exposes the queue ARN as a CloudFormation output
40
+ */
41
+ declare class BaseSqsConstruct extends Construct {
42
+ /** The created SQS queue instance */
43
+ readonly queue: Queue;
44
+ /**
45
+ * @param scope Parent construct
46
+ * @param id Unique construct identifier
47
+ * @param props Configuration for queue and Lambda consumers
48
+ */
49
+ constructor(scope: Construct, id: string, props: ISqsConstructProps);
50
+ }
51
+
52
+ export { BaseSqsConstruct };
@@ -0,0 +1,53 @@
1
+ import { Construct } from 'constructs';
2
+ import { RemovalPolicy, CfnOutput } from 'aws-cdk-lib';
3
+ import { Queue } from 'aws-cdk-lib/aws-sqs';
4
+ import { EventSourceMapping } from 'aws-cdk-lib/aws-lambda';
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var BaseSqsConstruct = class extends Construct {
9
+ static {
10
+ __name(this, "BaseSqsConstruct");
11
+ }
12
+ /** The created SQS queue instance */
13
+ queue;
14
+ /**
15
+ * @param scope Parent construct
16
+ * @param id Unique construct identifier
17
+ * @param props Configuration for queue and Lambda consumers
18
+ */
19
+ constructor(scope, id, props) {
20
+ super(scope, id);
21
+ this.queue = new Queue(this, id, {
22
+ ...props?.options?.queueOptions,
23
+ /**
24
+ * Removal policy applied to the queue
25
+ * Defaults to DESTROY if not explicitly defined
26
+ */
27
+ removalPolicy: props?.options?.queueOptions?.removalPolicy || RemovalPolicy.DESTROY
28
+ });
29
+ if (props?.targetFunctions?.length) {
30
+ props.targetFunctions.forEach((targetFunction, index) => {
31
+ new EventSourceMapping(this, `${id}-eventSourceMap${index + 1}`, {
32
+ ...props?.options?.eventSourceMappingOptions,
33
+ /** Target Lambda function */
34
+ target: targetFunction,
35
+ /** Source SQS queue ARN */
36
+ eventSourceArn: this.queue.queueArn,
37
+ /**
38
+ * Retry attempts for failed batch processing
39
+ * Defaults to 3 if not explicitly defined
40
+ */
41
+ retryAttempts: props?.options?.eventSourceMappingOptions?.retryAttempts || 3
42
+ });
43
+ });
44
+ }
45
+ new CfnOutput(this, "SqsQueueArn", {
46
+ value: this.queue.queueArn
47
+ });
48
+ }
49
+ };
50
+
51
+ export { BaseSqsConstruct };
52
+ //# sourceMappingURL=sqs-construct.js.map
53
+ //# sourceMappingURL=sqs-construct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/aws/cdk/constructs/sqs-construct.ts"],"names":[],"mappings":";;;;;;;AA2CO,IAAM,gBAAA,GAAN,cAA+B,SAAA,CAAU;AAAA,EA3ChD;AA2CgD,IAAA,MAAA,CAAA,IAAA,EAAA,kBAAA,CAAA;AAAA;AAAA;AAAA,EAEtC,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAA2B;AACpE,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,KAAA,CAAM,IAAA,EAAM,EAAA,EAAI;AAAA,MAChC,GAAG,OAAO,OAAA,EAAS,YAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMnB,aAAA,EACC,KAAA,EAAO,OAAA,EAAS,YAAA,EAAc,iBAC3B,aAAA,CAAc;AAAA,KAClB,CAAA;AAKD,IAAA,IAAI,KAAA,EAAO,iBAAiB,MAAA,EAAQ;AACnC,MAAA,KAAA,CAAM,eAAA,CAAgB,OAAA,CAAQ,CAAC,cAAA,EAAgB,KAAA,KAAU;AACxD,QAAA,IAAI,mBAAmB,IAAA,EAAM,CAAA,EAAG,EAAE,CAAA,eAAA,EAAkB,KAAA,GAAQ,CAAC,CAAA,CAAA,EAAI;AAAA,UAChE,GAAG,OAAO,OAAA,EAAS,yBAAA;AAAA;AAAA,UAGnB,MAAA,EAAQ,cAAA;AAAA;AAAA,UAGR,cAAA,EAAgB,KAAK,KAAA,CAAM,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAM3B,aAAA,EACC,KAAA,EAAO,OAAA,EAAS,yBAAA,EAA2B,aAAA,IACxC;AAAA,SACJ,CAAA;AAAA,MACF,CAAC,CAAA;AAAA,IACF;AAKA,IAAA,IAAI,SAAA,CAAU,MAAM,aAAA,EAAe;AAAA,MAClC,KAAA,EAAO,KAAK,KAAA,CAAM;AAAA,KAClB,CAAA;AAAA,EACF;AACD","file":"sqs-construct.js","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { Queue, QueueProps } from 'aws-cdk-lib/aws-sqs';\nimport { EventSourceMapping, EventSourceMappingProps, Function } from 'aws-cdk-lib/aws-lambda';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseSqsConstruct\n *\n * Provides configuration for:\n * - SQS queue creation\n * - Lambda event source mappings\n */\ninterface ISqsConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** Configuration options for the SQS queue */\n\treadonly queueOptions?: QueueProps;\n\n\t/**\n\t * Configuration for Lambda event source mapping\n\t *\n\t * Note:\n\t * `eventSourceArn` and `target` are managed internally\n\t */\n\treadonly eventSourceMappingOptions?: Omit<EventSourceMappingProps, 'eventSourceArn' | 'target'>;\n}>, 'appName' | 'stage' | 'stackName'> {\n\t/**\n\t * Lambda functions to be triggered by SQS messages\n\t *\n\t * Each function will be connected via an event source mapping\n\t */\n\treadonly targetFunctions?: Function[];\n}\n\n/**\n * CDK construct for SQS queue with Lambda integration\n *\n * Responsibilities:\n * - Creates an SQS queue with configurable options\n * - Attaches one or more Lambda consumers via event source mappings\n * - Applies default retry behaviour\n * - Exposes the queue ARN as a CloudFormation output\n */\nexport class BaseSqsConstruct extends Construct {\n\t/** The created SQS queue instance */\n\treadonly queue: Queue;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for queue and Lambda consumers\n\t */\n\tconstructor(scope: Construct, id: string, props: ISqsConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.queue = new Queue(this, id, {\n\t\t\t...props?.options?.queueOptions,\n\n\t\t\t/**\n\t\t\t * Removal policy applied to the queue\n\t\t\t * Defaults to DESTROY if not explicitly defined\n\t\t\t */\n\t\t\tremovalPolicy:\n\t\t\t\tprops?.options?.queueOptions?.removalPolicy\n\t\t\t\t|| RemovalPolicy.DESTROY\n\t\t});\n\n\t\t/**\n\t\t * Attach Lambda event source mappings for queue consumption\n\t\t */\n\t\tif (props?.targetFunctions?.length) {\n\t\t\tprops.targetFunctions.forEach((targetFunction, index) => {\n\t\t\t\tnew EventSourceMapping(this, `${id}-eventSourceMap${index + 1}`, {\n\t\t\t\t\t...props?.options?.eventSourceMappingOptions,\n\n\t\t\t\t\t/** Target Lambda function */\n\t\t\t\t\ttarget: targetFunction,\n\n\t\t\t\t\t/** Source SQS queue ARN */\n\t\t\t\t\teventSourceArn: this.queue.queueArn,\n\n\t\t\t\t\t/**\n\t\t\t\t\t * Retry attempts for failed batch processing\n\t\t\t\t\t * Defaults to 3 if not explicitly defined\n\t\t\t\t\t */\n\t\t\t\t\tretryAttempts:\n\t\t\t\t\t\tprops?.options?.eventSourceMappingOptions?.retryAttempts\n\t\t\t\t\t\t|| 3\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * CloudFormation output exposing the SQS queue ARN\n\t\t */\n\t\tnew CfnOutput(this, 'SqsQueueArn', {\n\t\t\tvalue: this.queue.queueArn\n\t\t});\n\t}\n}"]}