@gradientedge/cdk-utils-aws 1.0.0
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.
- package/LICENSE +21 -0
- package/dist/src/common/construct.d.ts +85 -0
- package/dist/src/common/construct.js +125 -0
- package/dist/src/common/index.d.ts +4 -0
- package/dist/src/common/index.js +4 -0
- package/dist/src/common/resource-name-formatter.d.ts +13 -0
- package/dist/src/common/resource-name-formatter.js +30 -0
- package/dist/src/common/stack.d.ts +62 -0
- package/dist/src/common/stack.js +139 -0
- package/dist/src/common/types.d.ts +30 -0
- package/dist/src/common/types.js +1 -0
- package/dist/src/construct/api-to-any-target/index.d.ts +3 -0
- package/dist/src/construct/api-to-any-target/index.js +3 -0
- package/dist/src/construct/api-to-any-target/main.d.ts +47 -0
- package/dist/src/construct/api-to-any-target/main.js +154 -0
- package/dist/src/construct/api-to-any-target/target.d.ts +23 -0
- package/dist/src/construct/api-to-any-target/target.js +14 -0
- package/dist/src/construct/api-to-any-target/types.d.ts +60 -0
- package/dist/src/construct/api-to-any-target/types.js +1 -0
- package/dist/src/construct/api-to-eventbridge-target/api.d.ts +34 -0
- package/dist/src/construct/api-to-eventbridge-target/api.js +23 -0
- package/dist/src/construct/api-to-eventbridge-target/event.d.ts +15 -0
- package/dist/src/construct/api-to-eventbridge-target/event.js +12 -0
- package/dist/src/construct/api-to-eventbridge-target/index.d.ts +4 -0
- package/dist/src/construct/api-to-eventbridge-target/index.js +4 -0
- package/dist/src/construct/api-to-eventbridge-target/main.d.ts +121 -0
- package/dist/src/construct/api-to-eventbridge-target/main.js +442 -0
- package/dist/src/construct/api-to-eventbridge-target/types.d.ts +100 -0
- package/dist/src/construct/api-to-eventbridge-target/types.js +1 -0
- package/dist/src/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.d.ts +16 -0
- package/dist/src/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.js +12 -0
- package/dist/src/construct/api-to-eventbridge-target-with-sns/index.d.ts +3 -0
- package/dist/src/construct/api-to-eventbridge-target-with-sns/index.js +3 -0
- package/dist/src/construct/api-to-eventbridge-target-with-sns/main.d.ts +159 -0
- package/dist/src/construct/api-to-eventbridge-target-with-sns/main.js +547 -0
- package/dist/src/construct/api-to-eventbridge-target-with-sns/types.d.ts +22 -0
- package/dist/src/construct/api-to-eventbridge-target-with-sns/types.js +1 -0
- package/dist/src/construct/api-to-lambda-target/api.d.ts +35 -0
- package/dist/src/construct/api-to-lambda-target/api.js +24 -0
- package/dist/src/construct/api-to-lambda-target/index.d.ts +3 -0
- package/dist/src/construct/api-to-lambda-target/index.js +3 -0
- package/dist/src/construct/api-to-lambda-target/main.d.ts +70 -0
- package/dist/src/construct/api-to-lambda-target/main.js +218 -0
- package/dist/src/construct/api-to-lambda-target/types.d.ts +62 -0
- package/dist/src/construct/api-to-lambda-target/types.js +1 -0
- package/dist/src/construct/application-configuration/index.d.ts +2 -0
- package/dist/src/construct/application-configuration/index.js +2 -0
- package/dist/src/construct/application-configuration/main.d.ts +23 -0
- package/dist/src/construct/application-configuration/main.js +79 -0
- package/dist/src/construct/application-configuration/types.d.ts +6 -0
- package/dist/src/construct/application-configuration/types.js +1 -0
- package/dist/src/construct/event-handler/handler.d.ts +29 -0
- package/dist/src/construct/event-handler/handler.js +21 -0
- package/dist/src/construct/event-handler/index.d.ts +3 -0
- package/dist/src/construct/event-handler/index.js +3 -0
- package/dist/src/construct/event-handler/main.d.ts +91 -0
- package/dist/src/construct/event-handler/main.js +196 -0
- package/dist/src/construct/event-handler/types.d.ts +41 -0
- package/dist/src/construct/event-handler/types.js +1 -0
- package/dist/src/construct/index.d.ts +14 -0
- package/dist/src/construct/index.js +14 -0
- package/dist/src/construct/lambda-with-iam-access/index.d.ts +2 -0
- package/dist/src/construct/lambda-with-iam-access/index.js +2 -0
- package/dist/src/construct/lambda-with-iam-access/main.d.ts +78 -0
- package/dist/src/construct/lambda-with-iam-access/main.js +182 -0
- package/dist/src/construct/lambda-with-iam-access/types.d.ts +20 -0
- package/dist/src/construct/lambda-with-iam-access/types.js +1 -0
- package/dist/src/construct/piped-event-handler/index.d.ts +2 -0
- package/dist/src/construct/piped-event-handler/index.js +2 -0
- package/dist/src/construct/piped-event-handler/main.d.ts +38 -0
- package/dist/src/construct/piped-event-handler/main.js +62 -0
- package/dist/src/construct/piped-event-handler/types.d.ts +9 -0
- package/dist/src/construct/piped-event-handler/types.js +1 -0
- package/dist/src/construct/rest-api-lambda/index.d.ts +2 -0
- package/dist/src/construct/rest-api-lambda/index.js +2 -0
- package/dist/src/construct/rest-api-lambda/main.d.ts +96 -0
- package/dist/src/construct/rest-api-lambda/main.js +170 -0
- package/dist/src/construct/rest-api-lambda/types.d.ts +23 -0
- package/dist/src/construct/rest-api-lambda/types.js +1 -0
- package/dist/src/construct/rest-api-lambda-with-cache/index.d.ts +2 -0
- package/dist/src/construct/rest-api-lambda-with-cache/index.js +2 -0
- package/dist/src/construct/rest-api-lambda-with-cache/main.d.ts +56 -0
- package/dist/src/construct/rest-api-lambda-with-cache/main.js +118 -0
- package/dist/src/construct/rest-api-lambda-with-cache/types.d.ts +11 -0
- package/dist/src/construct/rest-api-lambda-with-cache/types.js +1 -0
- package/dist/src/construct/site-with-ecs-backend/constants.d.ts +4 -0
- package/dist/src/construct/site-with-ecs-backend/constants.js +5 -0
- package/dist/src/construct/site-with-ecs-backend/index.d.ts +3 -0
- package/dist/src/construct/site-with-ecs-backend/index.js +3 -0
- package/dist/src/construct/site-with-ecs-backend/main.d.ts +154 -0
- package/dist/src/construct/site-with-ecs-backend/main.js +437 -0
- package/dist/src/construct/site-with-ecs-backend/types.d.ts +49 -0
- package/dist/src/construct/site-with-ecs-backend/types.js +1 -0
- package/dist/src/construct/site-with-lambda-backend/constants.d.ts +5 -0
- package/dist/src/construct/site-with-lambda-backend/constants.js +6 -0
- package/dist/src/construct/site-with-lambda-backend/index.d.ts +3 -0
- package/dist/src/construct/site-with-lambda-backend/index.js +3 -0
- package/dist/src/construct/site-with-lambda-backend/main.d.ts +116 -0
- package/dist/src/construct/site-with-lambda-backend/main.js +316 -0
- package/dist/src/construct/site-with-lambda-backend/types.d.ts +45 -0
- package/dist/src/construct/site-with-lambda-backend/types.js +1 -0
- package/dist/src/construct/static-asset-deployment/index.d.ts +2 -0
- package/dist/src/construct/static-asset-deployment/index.js +2 -0
- package/dist/src/construct/static-asset-deployment/main.d.ts +41 -0
- package/dist/src/construct/static-asset-deployment/main.js +113 -0
- package/dist/src/construct/static-asset-deployment/types.d.ts +41 -0
- package/dist/src/construct/static-asset-deployment/types.js +1 -0
- package/dist/src/construct/static-site/index.d.ts +2 -0
- package/dist/src/construct/static-site/index.js +2 -0
- package/dist/src/construct/static-site/main.d.ts +84 -0
- package/dist/src/construct/static-site/main.js +136 -0
- package/dist/src/construct/static-site/types.d.ts +30 -0
- package/dist/src/construct/static-site/types.js +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +5 -0
- package/dist/src/services/api-gateway/index.d.ts +2 -0
- package/dist/src/services/api-gateway/index.js +2 -0
- package/dist/src/services/api-gateway/main.d.ts +68 -0
- package/dist/src/services/api-gateway/main.js +173 -0
- package/dist/src/services/api-gateway/types.d.ts +10 -0
- package/dist/src/services/api-gateway/types.js +1 -0
- package/dist/src/services/appconfig/constants.d.ts +12 -0
- package/dist/src/services/appconfig/constants.js +51 -0
- package/dist/src/services/appconfig/index.d.ts +3 -0
- package/dist/src/services/appconfig/index.js +3 -0
- package/dist/src/services/appconfig/main.d.ts +63 -0
- package/dist/src/services/appconfig/main.js +119 -0
- package/dist/src/services/appconfig/types.d.ts +17 -0
- package/dist/src/services/appconfig/types.js +1 -0
- package/dist/src/services/certificate-manager/index.d.ts +2 -0
- package/dist/src/services/certificate-manager/index.js +2 -0
- package/dist/src/services/certificate-manager/main.d.ts +41 -0
- package/dist/src/services/certificate-manager/main.js +62 -0
- package/dist/src/services/certificate-manager/types.d.ts +11 -0
- package/dist/src/services/certificate-manager/types.js +1 -0
- package/dist/src/services/cloudfront/index.d.ts +2 -0
- package/dist/src/services/cloudfront/index.js +2 -0
- package/dist/src/services/cloudfront/main.d.ts +96 -0
- package/dist/src/services/cloudfront/main.js +233 -0
- package/dist/src/services/cloudfront/types.d.ts +13 -0
- package/dist/src/services/cloudfront/types.js +1 -0
- package/dist/src/services/cloudtrail/index.d.ts +2 -0
- package/dist/src/services/cloudtrail/index.js +2 -0
- package/dist/src/services/cloudtrail/main.d.ts +44 -0
- package/dist/src/services/cloudtrail/main.js +71 -0
- package/dist/src/services/cloudtrail/types.d.ts +5 -0
- package/dist/src/services/cloudtrail/types.js +1 -0
- package/dist/src/services/cloudwatch/index.d.ts +3 -0
- package/dist/src/services/cloudwatch/index.js +3 -0
- package/dist/src/services/cloudwatch/logs.d.ts +47 -0
- package/dist/src/services/cloudwatch/logs.js +98 -0
- package/dist/src/services/cloudwatch/main.d.ts +207 -0
- package/dist/src/services/cloudwatch/main.js +552 -0
- package/dist/src/services/cloudwatch/types.d.ts +89 -0
- package/dist/src/services/cloudwatch/types.js +1 -0
- package/dist/src/services/codebuild/index.d.ts +1 -0
- package/dist/src/services/codebuild/index.js +1 -0
- package/dist/src/services/codebuild/main.d.ts +36 -0
- package/dist/src/services/codebuild/main.js +67 -0
- package/dist/src/services/constants.d.ts +4 -0
- package/dist/src/services/constants.js +5 -0
- package/dist/src/services/dynamodb/index.d.ts +2 -0
- package/dist/src/services/dynamodb/index.js +2 -0
- package/dist/src/services/dynamodb/main.d.ts +35 -0
- package/dist/src/services/dynamodb/main.js +72 -0
- package/dist/src/services/dynamodb/types.d.ts +10 -0
- package/dist/src/services/dynamodb/types.js +1 -0
- package/dist/src/services/elastic-container-registry/index.d.ts +1 -0
- package/dist/src/services/elastic-container-registry/index.js +1 -0
- package/dist/src/services/elastic-container-registry/main.d.ts +27 -0
- package/dist/src/services/elastic-container-registry/main.js +33 -0
- package/dist/src/services/elastic-container-service/index.d.ts +2 -0
- package/dist/src/services/elastic-container-service/index.js +2 -0
- package/dist/src/services/elastic-container-service/main.d.ts +56 -0
- package/dist/src/services/elastic-container-service/main.js +149 -0
- package/dist/src/services/elastic-container-service/types.d.ts +45 -0
- package/dist/src/services/elastic-container-service/types.js +1 -0
- package/dist/src/services/elastic-file-system/index.d.ts +2 -0
- package/dist/src/services/elastic-file-system/index.js +2 -0
- package/dist/src/services/elastic-file-system/main.d.ts +42 -0
- package/dist/src/services/elastic-file-system/main.js +76 -0
- package/dist/src/services/elastic-file-system/types.d.ts +15 -0
- package/dist/src/services/elastic-file-system/types.js +1 -0
- package/dist/src/services/elastic-kubernetes-service/index.d.ts +2 -0
- package/dist/src/services/elastic-kubernetes-service/index.js +2 -0
- package/dist/src/services/elastic-kubernetes-service/main.d.ts +32 -0
- package/dist/src/services/elastic-kubernetes-service/main.js +85 -0
- package/dist/src/services/elastic-kubernetes-service/types.d.ts +7 -0
- package/dist/src/services/elastic-kubernetes-service/types.js +1 -0
- package/dist/src/services/elasticache/index.d.ts +2 -0
- package/dist/src/services/elasticache/index.js +2 -0
- package/dist/src/services/elasticache/main.d.ts +47 -0
- package/dist/src/services/elasticache/main.js +90 -0
- package/dist/src/services/elasticache/types.d.ts +9 -0
- package/dist/src/services/elasticache/types.js +1 -0
- package/dist/src/services/eventbridge/index.d.ts +3 -0
- package/dist/src/services/eventbridge/index.js +3 -0
- package/dist/src/services/eventbridge/main.d.ts +93 -0
- package/dist/src/services/eventbridge/main.js +295 -0
- package/dist/src/services/eventbridge/target.d.ts +57 -0
- package/dist/src/services/eventbridge/target.js +61 -0
- package/dist/src/services/eventbridge/types.d.ts +43 -0
- package/dist/src/services/eventbridge/types.js +1 -0
- package/dist/src/services/evidently/index.d.ts +2 -0
- package/dist/src/services/evidently/index.js +2 -0
- package/dist/src/services/evidently/main.d.ts +56 -0
- package/dist/src/services/evidently/main.js +114 -0
- package/dist/src/services/evidently/types.d.ts +21 -0
- package/dist/src/services/evidently/types.js +1 -0
- package/dist/src/services/identity-access-management/index.d.ts +1 -0
- package/dist/src/services/identity-access-management/index.js +1 -0
- package/dist/src/services/identity-access-management/main.d.ts +263 -0
- package/dist/src/services/identity-access-management/main.js +609 -0
- package/dist/src/services/index.d.ts +28 -0
- package/dist/src/services/index.js +28 -0
- package/dist/src/services/key-management-service/index.d.ts +2 -0
- package/dist/src/services/key-management-service/index.js +2 -0
- package/dist/src/services/key-management-service/main.d.ts +28 -0
- package/dist/src/services/key-management-service/main.js +39 -0
- package/dist/src/services/key-management-service/types.d.ts +5 -0
- package/dist/src/services/key-management-service/types.js +1 -0
- package/dist/src/services/lambda/index.d.ts +2 -0
- package/dist/src/services/lambda/index.js +2 -0
- package/dist/src/services/lambda/main.d.ts +89 -0
- package/dist/src/services/lambda/main.js +232 -0
- package/dist/src/services/lambda/types.d.ts +54 -0
- package/dist/src/services/lambda/types.js +1 -0
- package/dist/src/services/route53/index.d.ts +2 -0
- package/dist/src/services/route53/index.js +2 -0
- package/dist/src/services/route53/main.d.ts +66 -0
- package/dist/src/services/route53/main.js +136 -0
- package/dist/src/services/route53/types.d.ts +6 -0
- package/dist/src/services/route53/types.js +1 -0
- package/dist/src/services/secrets-manager/index.d.ts +2 -0
- package/dist/src/services/secrets-manager/index.js +2 -0
- package/dist/src/services/secrets-manager/main.d.ts +43 -0
- package/dist/src/services/secrets-manager/main.js +71 -0
- package/dist/src/services/secrets-manager/types.d.ts +3 -0
- package/dist/src/services/secrets-manager/types.js +1 -0
- package/dist/src/services/simple-notification-service/index.d.ts +2 -0
- package/dist/src/services/simple-notification-service/index.js +2 -0
- package/dist/src/services/simple-notification-service/main.d.ts +38 -0
- package/dist/src/services/simple-notification-service/main.js +68 -0
- package/dist/src/services/simple-notification-service/types.d.ts +5 -0
- package/dist/src/services/simple-notification-service/types.js +1 -0
- package/dist/src/services/simple-queue-service/index.d.ts +2 -0
- package/dist/src/services/simple-queue-service/index.js +2 -0
- package/dist/src/services/simple-queue-service/main.d.ts +45 -0
- package/dist/src/services/simple-queue-service/main.js +101 -0
- package/dist/src/services/simple-queue-service/types.d.ts +15 -0
- package/dist/src/services/simple-queue-service/types.js +1 -0
- package/dist/src/services/simple-storage-service/index.d.ts +2 -0
- package/dist/src/services/simple-storage-service/index.js +2 -0
- package/dist/src/services/simple-storage-service/main.d.ts +79 -0
- package/dist/src/services/simple-storage-service/main.js +191 -0
- package/dist/src/services/simple-storage-service/types.d.ts +25 -0
- package/dist/src/services/simple-storage-service/types.js +1 -0
- package/dist/src/services/step-function/index.d.ts +2 -0
- package/dist/src/services/step-function/index.js +2 -0
- package/dist/src/services/step-function/main.d.ts +161 -0
- package/dist/src/services/step-function/main.js +380 -0
- package/dist/src/services/step-function/types.d.ts +88 -0
- package/dist/src/services/step-function/types.js +1 -0
- package/dist/src/services/systems-manager/index.d.ts +2 -0
- package/dist/src/services/systems-manager/index.js +2 -0
- package/dist/src/services/systems-manager/main.d.ts +55 -0
- package/dist/src/services/systems-manager/main.js +97 -0
- package/dist/src/services/systems-manager/types.d.ts +9 -0
- package/dist/src/services/systems-manager/types.js +1 -0
- package/dist/src/services/virtual-private-cloud/index.d.ts +2 -0
- package/dist/src/services/virtual-private-cloud/index.js +2 -0
- package/dist/src/services/virtual-private-cloud/ipv6.d.ts +7 -0
- package/dist/src/services/virtual-private-cloud/ipv6.js +38 -0
- package/dist/src/services/virtual-private-cloud/main.d.ts +43 -0
- package/dist/src/services/virtual-private-cloud/main.js +87 -0
- package/dist/src/services/virtual-private-cloud/types.d.ts +4 -0
- package/dist/src/services/virtual-private-cloud/types.js +1 -0
- package/dist/src/services/web-application-firewall/index.d.ts +2 -0
- package/dist/src/services/web-application-firewall/index.js +2 -0
- package/dist/src/services/web-application-firewall/main.d.ts +35 -0
- package/dist/src/services/web-application-firewall/main.js +61 -0
- package/dist/src/services/web-application-firewall/types.d.ts +9 -0
- package/dist/src/services/web-application-firewall/types.js +1 -0
- package/dist/src/types/index.d.ts +6 -0
- package/dist/src/types/index.js +1 -0
- package/dist/src/utils/index.d.ts +45 -0
- package/dist/src/utils/index.js +61 -0
- package/package.json +44 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ISecret } from 'aws-cdk-lib/aws-secretsmanager';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
import { CommonConstruct } from '../../common/index.js';
|
|
4
|
+
import { ApiToLambdaTargetProps, ApiToLambdaTargetRestApiType } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
*/
|
|
7
|
+
export declare class ApiToLambdaTarget extends CommonConstruct {
|
|
8
|
+
props: ApiToLambdaTargetProps;
|
|
9
|
+
id: string;
|
|
10
|
+
applicationSecrets: ISecret[];
|
|
11
|
+
apiToLambdaTargetRestApi: ApiToLambdaTargetRestApiType;
|
|
12
|
+
apiResource: string;
|
|
13
|
+
constructor(parent: Construct, id: string, props: ApiToLambdaTargetProps);
|
|
14
|
+
initResources(): void;
|
|
15
|
+
/**
|
|
16
|
+
* @summary Method to resolve secrets from SecretsManager
|
|
17
|
+
* - To be implemented in the overriding method in the implementation class
|
|
18
|
+
*/
|
|
19
|
+
protected resolveSecrets(): void;
|
|
20
|
+
/**
|
|
21
|
+
* @summary Method to resolve a hosted zone based on domain attributes
|
|
22
|
+
*/
|
|
23
|
+
protected resolveHostedZone(): void;
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to resolve a certificate based on attributes
|
|
26
|
+
*/
|
|
27
|
+
protected resolveCertificate(): void;
|
|
28
|
+
/**
|
|
29
|
+
* @summary Method to create api integration method response
|
|
30
|
+
*/
|
|
31
|
+
protected createApiToLambdaTargetMethodResponse(): void;
|
|
32
|
+
/**
|
|
33
|
+
* @summary Method to create api integration method error response
|
|
34
|
+
*/
|
|
35
|
+
protected createApiToLambdaTargetMethodErrorResponse(): void;
|
|
36
|
+
protected resolveApiToLambdaTargetFunction(): void;
|
|
37
|
+
/**
|
|
38
|
+
* @summary Method to create rest restApi for Api
|
|
39
|
+
*/
|
|
40
|
+
protected createApiToLambdaTargetRestApi(): void;
|
|
41
|
+
/**
|
|
42
|
+
* @summary Method to create api integration resource
|
|
43
|
+
*/
|
|
44
|
+
protected createApiToLambdaTargetResource(): void;
|
|
45
|
+
protected createApiToLambdaTargetPolicy(): void;
|
|
46
|
+
/**
|
|
47
|
+
* @summary Method to create a role for api integration
|
|
48
|
+
*/
|
|
49
|
+
protected createApiToLambdaTargetRole(): void;
|
|
50
|
+
/**
|
|
51
|
+
* @summary Method to create api integration resource method
|
|
52
|
+
*/
|
|
53
|
+
protected createApiToLambdaTargetIntegration(): void;
|
|
54
|
+
/**
|
|
55
|
+
* @summary Method to create api integration resource method
|
|
56
|
+
*/
|
|
57
|
+
protected createApiToLambdaTargetResourceMethod(): void;
|
|
58
|
+
/**
|
|
59
|
+
* @summary Method to create custom restApi domain for Api
|
|
60
|
+
*/
|
|
61
|
+
protected createApiDomain(): void;
|
|
62
|
+
/**
|
|
63
|
+
* @summary Method to create base path mappings for Api
|
|
64
|
+
*/
|
|
65
|
+
protected createApiBasePathMapping(): void;
|
|
66
|
+
/**
|
|
67
|
+
* @summary Method to create route53 records for Api
|
|
68
|
+
*/
|
|
69
|
+
protected createApiRouteAssets(): void;
|
|
70
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { Fn } from 'aws-cdk-lib';
|
|
2
|
+
import { BasePathMapping, LambdaIntegration, Resource, RestApi } from 'aws-cdk-lib/aws-apigateway';
|
|
3
|
+
import { PolicyDocument, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
|
|
4
|
+
import { Function } from 'aws-cdk-lib/aws-lambda';
|
|
5
|
+
import { CommonConstruct } from '../../common/index.js';
|
|
6
|
+
import { ApiToLambdaTargetRestApi } from './api.js';
|
|
7
|
+
/**
|
|
8
|
+
*/
|
|
9
|
+
export class ApiToLambdaTarget extends CommonConstruct {
|
|
10
|
+
props;
|
|
11
|
+
id;
|
|
12
|
+
/* application related resources */
|
|
13
|
+
applicationSecrets;
|
|
14
|
+
/* rest restApi related resources */
|
|
15
|
+
apiToLambdaTargetRestApi;
|
|
16
|
+
apiResource;
|
|
17
|
+
constructor(parent, id, props) {
|
|
18
|
+
super(parent, id, props);
|
|
19
|
+
this.props = props;
|
|
20
|
+
this.id = id;
|
|
21
|
+
this.apiToLambdaTargetRestApi = new ApiToLambdaTargetRestApi();
|
|
22
|
+
}
|
|
23
|
+
initResources() {
|
|
24
|
+
this.resolveSecrets();
|
|
25
|
+
this.resolveHostedZone();
|
|
26
|
+
this.resolveCertificate();
|
|
27
|
+
this.createApiToLambdaTargetMethodResponse();
|
|
28
|
+
this.createApiToLambdaTargetMethodErrorResponse();
|
|
29
|
+
this.resolveApiToLambdaTargetFunction();
|
|
30
|
+
this.createApiToLambdaTargetRestApi();
|
|
31
|
+
this.createApiToLambdaTargetResource();
|
|
32
|
+
this.createApiToLambdaTargetPolicy();
|
|
33
|
+
this.createApiToLambdaTargetRole();
|
|
34
|
+
this.createApiToLambdaTargetIntegration();
|
|
35
|
+
this.createApiToLambdaTargetResourceMethod();
|
|
36
|
+
this.createApiDomain();
|
|
37
|
+
this.createApiBasePathMapping();
|
|
38
|
+
this.createApiRouteAssets();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @summary Method to resolve secrets from SecretsManager
|
|
42
|
+
* - To be implemented in the overriding method in the implementation class
|
|
43
|
+
*/
|
|
44
|
+
resolveSecrets() {
|
|
45
|
+
this.applicationSecrets = [];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @summary Method to resolve a hosted zone based on domain attributes
|
|
49
|
+
*/
|
|
50
|
+
resolveHostedZone() {
|
|
51
|
+
this.apiToLambdaTargetRestApi.hostedZone = this.route53Manager.withHostedZoneFromFullyQualifiedDomainName(`${this.id}-hosted-zone`, this, this.props.useExistingHostedZone);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @summary Method to resolve a certificate based on attributes
|
|
55
|
+
*/
|
|
56
|
+
resolveCertificate() {
|
|
57
|
+
if (this.props.api.useExisting)
|
|
58
|
+
return;
|
|
59
|
+
if (this.props.api.certificate.useExistingCertificate &&
|
|
60
|
+
this.props.api.certificate.certificateSsmName &&
|
|
61
|
+
this.props.api.certificate.certificateRegion) {
|
|
62
|
+
this.props.api.certificate.certificateArn = this.ssmManager.readStringParameterFromRegion(`${this.id}-certificate-param`, this, this.props.api.certificate.certificateSsmName, this.props.api.certificate.certificateRegion);
|
|
63
|
+
}
|
|
64
|
+
this.apiToLambdaTargetRestApi.certificate = this.acmManager.resolveCertificate(`${this.id}-certificate`, this, this.props.api.certificate);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @summary Method to create api integration method response
|
|
68
|
+
*/
|
|
69
|
+
createApiToLambdaTargetMethodResponse() {
|
|
70
|
+
if (!this.props.api.withResource)
|
|
71
|
+
return;
|
|
72
|
+
this.apiToLambdaTargetRestApi.methodResponse = {
|
|
73
|
+
...{
|
|
74
|
+
responseParameters: {
|
|
75
|
+
'method.response.header.Access-Control-Allow-Credentials': true,
|
|
76
|
+
'method.response.header.Access-Control-Allow-Origin': true,
|
|
77
|
+
'method.response.header.Content-Type': true,
|
|
78
|
+
},
|
|
79
|
+
statusCode: '200',
|
|
80
|
+
},
|
|
81
|
+
...this.props.api.methodResponse,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @summary Method to create api integration method error response
|
|
86
|
+
*/
|
|
87
|
+
createApiToLambdaTargetMethodErrorResponse() {
|
|
88
|
+
if (!this.props.api.withResource)
|
|
89
|
+
return;
|
|
90
|
+
this.apiToLambdaTargetRestApi.methodErrorResponse = {
|
|
91
|
+
...{
|
|
92
|
+
responseParameters: {
|
|
93
|
+
'method.response.header.Access-Control-Allow-Credentials': true,
|
|
94
|
+
'method.response.header.Access-Control-Allow-Origin': true,
|
|
95
|
+
'method.response.header.Content-Type': true,
|
|
96
|
+
},
|
|
97
|
+
statusCode: '400',
|
|
98
|
+
},
|
|
99
|
+
...this.props.api.methodErrorResponse,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
resolveApiToLambdaTargetFunction() {
|
|
103
|
+
this.apiToLambdaTargetRestApi.lambda = Function.fromFunctionName(this, `${this.id}-lambda`, this.resourceNameFormatter.format(this.props.lambdaFunctionName));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @summary Method to create rest restApi for Api
|
|
107
|
+
*/
|
|
108
|
+
createApiToLambdaTargetRestApi() {
|
|
109
|
+
if (this.props.api.useExisting && this.props.api.importedRestApiRef) {
|
|
110
|
+
this.apiToLambdaTargetRestApi.api = RestApi.fromRestApiId(this, `${this.id}-rest-api`, Fn.importValue(this.props.api.importedRestApiRef));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.props.api.restApi = {
|
|
114
|
+
...this.props.api.restApi,
|
|
115
|
+
defaultMethodOptions: {
|
|
116
|
+
methodResponses: [
|
|
117
|
+
this.apiToLambdaTargetRestApi.methodResponse,
|
|
118
|
+
this.apiToLambdaTargetRestApi.methodErrorResponse,
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
this.apiToLambdaTargetRestApi.api = this.apiManager.createLambdaRestApi(`${this.id}-lambda-rest-api`, this, this.props.api.restApi, this.apiToLambdaTargetRestApi.lambda);
|
|
123
|
+
this.addCfnOutput(`${this.id}-restApiId`, this.apiToLambdaTargetRestApi.api.restApiId);
|
|
124
|
+
this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiToLambdaTargetRestApi.api.root.resourceId);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @summary Method to create api integration resource
|
|
128
|
+
*/
|
|
129
|
+
createApiToLambdaTargetResource() {
|
|
130
|
+
if (!this.props.api.withResource)
|
|
131
|
+
return;
|
|
132
|
+
let rootResource;
|
|
133
|
+
if (this.props.api.withResource && this.props.api.importedRestApiRootResourceRef) {
|
|
134
|
+
rootResource = Resource.fromResourceAttributes(this, `${this.id}-root-resource`, {
|
|
135
|
+
path: '/',
|
|
136
|
+
resourceId: Fn.importValue(this.props.api.importedRestApiRootResourceRef),
|
|
137
|
+
restApi: this.apiToLambdaTargetRestApi.api,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
rootResource = this.apiToLambdaTargetRestApi.api.root;
|
|
142
|
+
}
|
|
143
|
+
this.apiToLambdaTargetRestApi.resource = rootResource.addResource(this.props.api.resource ?? this.apiResource);
|
|
144
|
+
}
|
|
145
|
+
createApiToLambdaTargetPolicy() {
|
|
146
|
+
this.apiToLambdaTargetRestApi.policy = new PolicyDocument({
|
|
147
|
+
statements: [
|
|
148
|
+
this.iamManager.statementForPutEvents(),
|
|
149
|
+
this.iamManager.statementForInvokeLambda([this.apiToLambdaTargetRestApi.lambda.functionArn]),
|
|
150
|
+
],
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* @summary Method to create a role for api integration
|
|
155
|
+
*/
|
|
156
|
+
createApiToLambdaTargetRole() {
|
|
157
|
+
if (!this.apiToLambdaTargetRestApi.policy)
|
|
158
|
+
throw 'Policy undefined';
|
|
159
|
+
this.apiToLambdaTargetRestApi.role = new Role(this, `${this.id}-rest-api-role`, {
|
|
160
|
+
assumedBy: new ServicePrincipal('apigateway.amazonaws.com'),
|
|
161
|
+
inlinePolicies: { policy: this.apiToLambdaTargetRestApi.policy },
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* @summary Method to create api integration resource method
|
|
166
|
+
*/
|
|
167
|
+
createApiToLambdaTargetIntegration() {
|
|
168
|
+
this.apiToLambdaTargetRestApi.integration = new LambdaIntegration(this.apiToLambdaTargetRestApi.lambda, {
|
|
169
|
+
allowTestInvoke: true,
|
|
170
|
+
credentialsRole: this.apiToLambdaTargetRestApi.role,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* @summary Method to create api integration resource method
|
|
175
|
+
*/
|
|
176
|
+
createApiToLambdaTargetResourceMethod() {
|
|
177
|
+
if (!this.props.api.withResource)
|
|
178
|
+
return;
|
|
179
|
+
this.apiToLambdaTargetRestApi.method = this.apiToLambdaTargetRestApi.resource.addMethod('POST', this.apiToLambdaTargetRestApi.integration, {
|
|
180
|
+
authorizer: this.apiToLambdaTargetRestApi.authoriser,
|
|
181
|
+
methodResponses: [
|
|
182
|
+
this.apiToLambdaTargetRestApi.methodResponse,
|
|
183
|
+
this.apiToLambdaTargetRestApi.methodErrorResponse,
|
|
184
|
+
],
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* @summary Method to create custom restApi domain for Api
|
|
189
|
+
*/
|
|
190
|
+
createApiDomain() {
|
|
191
|
+
if (this.props.api.useExisting)
|
|
192
|
+
return;
|
|
193
|
+
this.apiToLambdaTargetRestApi.domain = this.apiManager.createApiDomain(`${this.id}-api-domain`, this, this.isProductionStage() || this.props.skipStageForARecords
|
|
194
|
+
? `${this.props.apiSubDomain}.${this.fullyQualifiedDomainName}`
|
|
195
|
+
: `${this.props.apiSubDomain}-${this.props.stage}.${this.fullyQualifiedDomainName}`, this.apiToLambdaTargetRestApi.certificate);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* @summary Method to create base path mappings for Api
|
|
199
|
+
*/
|
|
200
|
+
createApiBasePathMapping() {
|
|
201
|
+
if (this.props.api.useExisting)
|
|
202
|
+
return;
|
|
203
|
+
new BasePathMapping(this, `${this.id}-base-bath-mapping`, {
|
|
204
|
+
basePath: '',
|
|
205
|
+
domainName: this.apiToLambdaTargetRestApi.domain,
|
|
206
|
+
restApi: this.apiToLambdaTargetRestApi.api,
|
|
207
|
+
stage: this.apiToLambdaTargetRestApi.api.deploymentStage,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @summary Method to create route53 records for Api
|
|
212
|
+
*/
|
|
213
|
+
createApiRouteAssets() {
|
|
214
|
+
if (this.props.api.useExisting)
|
|
215
|
+
return;
|
|
216
|
+
this.route53Manager.createApiGatewayARecord(`${this.id}-custom-domain-a-record`, this, this.props.apiSubDomain, this.apiToLambdaTargetRestApi.domain, this.apiToLambdaTargetRestApi.hostedZone, this.props.skipStageForARecords);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CommonStackProps } from '../../common/index.js';
|
|
2
|
+
import { BasePathMapping, DomainName, IAuthorizer, Integration, IntegrationResponse, IRestApi, Method, MethodResponse, Model, Resource } from 'aws-cdk-lib/aws-apigateway';
|
|
3
|
+
import { AcmProps, LambdaRestApiProps } from '../../services/index.js';
|
|
4
|
+
import * as acm from 'aws-cdk-lib/aws-certificatemanager';
|
|
5
|
+
import * as route53 from 'aws-cdk-lib/aws-route53';
|
|
6
|
+
import { IFunction } from 'aws-cdk-lib/aws-lambda';
|
|
7
|
+
import { ITopic } from 'aws-cdk-lib/aws-sns';
|
|
8
|
+
import { PolicyDocument, Role } from 'aws-cdk-lib/aws-iam';
|
|
9
|
+
/**
|
|
10
|
+
*/
|
|
11
|
+
export interface ApiToLambdaTargetRestApiType {
|
|
12
|
+
api: IRestApi;
|
|
13
|
+
authoriser?: IAuthorizer;
|
|
14
|
+
basePathMappings: BasePathMapping[];
|
|
15
|
+
certificate: acm.ICertificate;
|
|
16
|
+
domain: DomainName;
|
|
17
|
+
errorResponseModel: Model;
|
|
18
|
+
hostedZone: route53.IHostedZone;
|
|
19
|
+
integration: Integration;
|
|
20
|
+
integrationErrorResponse: IntegrationResponse;
|
|
21
|
+
integrationRequestParameters: {
|
|
22
|
+
[p: string]: string;
|
|
23
|
+
};
|
|
24
|
+
integrationRequestTemplates: {
|
|
25
|
+
[p: string]: string;
|
|
26
|
+
};
|
|
27
|
+
integrationResponse: IntegrationResponse;
|
|
28
|
+
lambda: IFunction;
|
|
29
|
+
method: Method;
|
|
30
|
+
methodErrorResponse: MethodResponse;
|
|
31
|
+
methodResponse: MethodResponse;
|
|
32
|
+
policy?: PolicyDocument;
|
|
33
|
+
resource: Resource;
|
|
34
|
+
responseModel: Model;
|
|
35
|
+
role?: Role;
|
|
36
|
+
topic?: ITopic;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
*/
|
|
40
|
+
export interface ApiToLambdaTargetRestApiProps {
|
|
41
|
+
certificate: AcmProps;
|
|
42
|
+
importedRestApiRef?: string;
|
|
43
|
+
importedRestApiRootResourceRef?: string;
|
|
44
|
+
methodErrorResponse: MethodResponse;
|
|
45
|
+
methodResponse: MethodResponse;
|
|
46
|
+
resource: string;
|
|
47
|
+
restApi: LambdaRestApiProps;
|
|
48
|
+
useExisting: boolean;
|
|
49
|
+
withResource?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
*/
|
|
53
|
+
export interface ApiToLambdaTargetProps extends CommonStackProps {
|
|
54
|
+
api: ApiToLambdaTargetRestApiProps;
|
|
55
|
+
apiRootPaths?: string[];
|
|
56
|
+
apiSubDomain: string;
|
|
57
|
+
lambdaFunctionName: string;
|
|
58
|
+
logLevel: string;
|
|
59
|
+
nodeEnv: string;
|
|
60
|
+
timezone: string;
|
|
61
|
+
useExistingHostedZone: boolean;
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CfnApplication, CfnConfigurationProfile, CfnEnvironment, CfnHostedConfigurationVersion, IDeploymentStrategy } from 'aws-cdk-lib/aws-appconfig';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
import { CommonConstruct } from '../../common/index.js';
|
|
4
|
+
import { ApplicationConfigurationProps } from './types.js';
|
|
5
|
+
export declare class ApplicationConfiguration extends CommonConstruct {
|
|
6
|
+
props: ApplicationConfigurationProps;
|
|
7
|
+
id: string;
|
|
8
|
+
appConfigApplication: CfnApplication;
|
|
9
|
+
appConfigEnvironment: CfnEnvironment;
|
|
10
|
+
appConfigProfile: CfnConfigurationProfile;
|
|
11
|
+
appConfigVersion: CfnHostedConfigurationVersion;
|
|
12
|
+
appConfigDeploymentStrategy: IDeploymentStrategy;
|
|
13
|
+
constructor(parent: Construct, id: string, props: ApplicationConfigurationProps);
|
|
14
|
+
initResources(): void;
|
|
15
|
+
protected createConfiguration(): void;
|
|
16
|
+
protected createAppConfigApplication(): void;
|
|
17
|
+
protected createAppConfigEnvironment(): void;
|
|
18
|
+
protected createAppConfigProfile(): void;
|
|
19
|
+
protected createAppConfigVersion(): void;
|
|
20
|
+
protected createAppConfigDeploymentStrategy(): void;
|
|
21
|
+
protected createAppConfigDeployment(): void;
|
|
22
|
+
resolveEnvironmentVariables(): any;
|
|
23
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Duration, Fn } from 'aws-cdk-lib';
|
|
2
|
+
import { CfnDeployment, CfnHostedConfigurationVersion, DeploymentStrategy, RolloutStrategy, } from 'aws-cdk-lib/aws-appconfig';
|
|
3
|
+
import { CommonConstruct } from '../../common/index.js';
|
|
4
|
+
export class ApplicationConfiguration extends CommonConstruct {
|
|
5
|
+
id;
|
|
6
|
+
appConfigApplication;
|
|
7
|
+
appConfigEnvironment;
|
|
8
|
+
appConfigProfile;
|
|
9
|
+
appConfigVersion;
|
|
10
|
+
appConfigDeploymentStrategy;
|
|
11
|
+
constructor(parent, id, props) {
|
|
12
|
+
super(parent, id, props);
|
|
13
|
+
this.props = props;
|
|
14
|
+
this.id = id;
|
|
15
|
+
}
|
|
16
|
+
initResources() {
|
|
17
|
+
this.createConfiguration();
|
|
18
|
+
this.resolveEnvironmentVariables();
|
|
19
|
+
}
|
|
20
|
+
createConfiguration() {
|
|
21
|
+
this.createAppConfigApplication();
|
|
22
|
+
this.createAppConfigEnvironment();
|
|
23
|
+
this.createAppConfigProfile();
|
|
24
|
+
this.createAppConfigVersion();
|
|
25
|
+
this.createAppConfigDeploymentStrategy();
|
|
26
|
+
this.createAppConfigDeployment();
|
|
27
|
+
}
|
|
28
|
+
createAppConfigApplication() {
|
|
29
|
+
this.appConfigApplication = this.appConfigManager.createApplication(`${this.id}-ac-application`, this, this.props.appConfig);
|
|
30
|
+
}
|
|
31
|
+
createAppConfigEnvironment() {
|
|
32
|
+
this.appConfigEnvironment = this.appConfigManager.createEnvironment(`${this.id}-ac-environment`, this, Fn.ref(this.appConfigApplication.logicalId), this.props.appConfig);
|
|
33
|
+
}
|
|
34
|
+
createAppConfigProfile() {
|
|
35
|
+
this.appConfigProfile = this.appConfigManager.createConfigurationProfile(`${this.id}-ac-profile`, this, Fn.ref(this.appConfigApplication.logicalId), this.props.appConfig);
|
|
36
|
+
}
|
|
37
|
+
createAppConfigVersion() {
|
|
38
|
+
this.appConfigVersion = new CfnHostedConfigurationVersion(this, `${this.id}-ac-configuration`, {
|
|
39
|
+
applicationId: Fn.ref(this.appConfigApplication.logicalId),
|
|
40
|
+
configurationProfileId: Fn.ref(this.appConfigProfile.logicalId),
|
|
41
|
+
content: JSON.stringify(this.props.appConfigContent),
|
|
42
|
+
contentType: 'application/json',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
createAppConfigDeploymentStrategy() {
|
|
46
|
+
if (!this.props.appConfig.deploymentStrategy)
|
|
47
|
+
return;
|
|
48
|
+
if (this.props.appConfig.deploymentStrategy?.deploymentStrategyArn) {
|
|
49
|
+
this.appConfigDeploymentStrategy = DeploymentStrategy.fromDeploymentStrategyArn(this, `${this.id}-ac-deployment-strategy`, this.props.appConfig.deploymentStrategy?.deploymentStrategyArn);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.appConfigDeploymentStrategy = new DeploymentStrategy(this, `${this.id}-ac-deployment-strategy`, {
|
|
53
|
+
...this.props.appConfig.deploymentStrategy,
|
|
54
|
+
rolloutStrategy: this.props.appConfig.deploymentStrategy?.rolloutStrategy ??
|
|
55
|
+
RolloutStrategy.linear({
|
|
56
|
+
growthFactor: 100,
|
|
57
|
+
deploymentDuration: Duration.minutes(0),
|
|
58
|
+
finalBakeTime: Duration.minutes(0),
|
|
59
|
+
}),
|
|
60
|
+
deploymentStrategyName: this.resourceNameFormatter.format(this.props.appConfig.deploymentStrategy.deploymentStrategyName ?? 'common-deployment-strategy', this.props.resourceNameOptions?.appconfig),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
createAppConfigDeployment() {
|
|
64
|
+
new CfnDeployment(this, `${this.id}-app-config-deployment`, {
|
|
65
|
+
applicationId: Fn.ref(this.appConfigApplication.logicalId),
|
|
66
|
+
configurationProfileId: Fn.ref(this.appConfigProfile.logicalId),
|
|
67
|
+
configurationVersion: Fn.ref(this.appConfigVersion.logicalId),
|
|
68
|
+
deploymentStrategyId: this.appConfigDeploymentStrategy.deploymentStrategyId,
|
|
69
|
+
environmentId: Fn.ref(this.appConfigEnvironment.logicalId),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
resolveEnvironmentVariables() {
|
|
73
|
+
return {
|
|
74
|
+
APP_CONFIG_APPLICATION_ID: Fn.ref(this.appConfigApplication.logicalId),
|
|
75
|
+
APP_CONFIG_CONFIGURATION_PROFILE_ID: Fn.ref(this.appConfigProfile.logicalId),
|
|
76
|
+
APP_CONFIG_ENVIRONMENT_ID: Fn.ref(this.appConfigEnvironment.logicalId),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Archive, IEventBus, IRuleTarget, Rule } from 'aws-cdk-lib/aws-events';
|
|
2
|
+
import { CloudWatchLogGroup, EcsTask, LambdaFunction, SfnStateMachine, SqsQueue } from 'aws-cdk-lib/aws-events-targets';
|
|
3
|
+
import { PolicyDocument, Role } from 'aws-cdk-lib/aws-iam';
|
|
4
|
+
import { IFunction } from 'aws-cdk-lib/aws-lambda';
|
|
5
|
+
import { LogGroup } from 'aws-cdk-lib/aws-logs';
|
|
6
|
+
import { Queue } from 'aws-cdk-lib/aws-sqs';
|
|
7
|
+
import { Chain, Map, StateMachine } from 'aws-cdk-lib/aws-stepfunctions';
|
|
8
|
+
import { EventHandlerType } from './types.js';
|
|
9
|
+
export declare class Handler implements EventHandlerType {
|
|
10
|
+
archive: Archive;
|
|
11
|
+
ecsTargets: EcsTask[];
|
|
12
|
+
eventBus: IEventBus;
|
|
13
|
+
eventWorkflowDefinition: Chain;
|
|
14
|
+
lambdaFunctions: IFunction[];
|
|
15
|
+
lambdaTargets: LambdaFunction[];
|
|
16
|
+
logTargets: CloudWatchLogGroup[];
|
|
17
|
+
queue: Queue;
|
|
18
|
+
rule: Rule;
|
|
19
|
+
rulePattern: any;
|
|
20
|
+
sqsTargets: SqsQueue[];
|
|
21
|
+
stepFunctionTargets: SfnStateMachine[];
|
|
22
|
+
targets: IRuleTarget[];
|
|
23
|
+
workflow: StateMachine;
|
|
24
|
+
workflowDefinition: Chain;
|
|
25
|
+
workflowLogGroup: LogGroup;
|
|
26
|
+
workflowMapState: Map;
|
|
27
|
+
workflowPolicy: PolicyDocument;
|
|
28
|
+
workflowRole: Role;
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class Handler {
|
|
2
|
+
archive;
|
|
3
|
+
ecsTargets = [];
|
|
4
|
+
eventBus;
|
|
5
|
+
eventWorkflowDefinition;
|
|
6
|
+
lambdaFunctions = [];
|
|
7
|
+
lambdaTargets = [];
|
|
8
|
+
logTargets = [];
|
|
9
|
+
queue;
|
|
10
|
+
rule;
|
|
11
|
+
rulePattern;
|
|
12
|
+
sqsTargets = [];
|
|
13
|
+
stepFunctionTargets = [];
|
|
14
|
+
targets = [];
|
|
15
|
+
workflow;
|
|
16
|
+
workflowDefinition;
|
|
17
|
+
workflowLogGroup;
|
|
18
|
+
workflowMapState;
|
|
19
|
+
workflowPolicy;
|
|
20
|
+
workflowRole;
|
|
21
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ISecurityGroup, IVpc } from 'aws-cdk-lib/aws-ec2';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
import { CommonConstruct } from '../../common/index.js';
|
|
4
|
+
import { Handler } from './handler.js';
|
|
5
|
+
import { EventHandlerProps } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides a construct to create and deploy an EventBridge Event Handler
|
|
8
|
+
* @example
|
|
9
|
+
* import { EventHandler, EventHandlerProps } '@gradientedge/cdk-utils'
|
|
10
|
+
* import { Construct } from 'constructs'
|
|
11
|
+
*
|
|
12
|
+
* class CustomConstruct extends EventHandler {
|
|
13
|
+
* constructor(parent: Construct, id: string, props: EventHandlerProps) {
|
|
14
|
+
* super(parent, id, props)
|
|
15
|
+
* this.props = props
|
|
16
|
+
* this.id = id
|
|
17
|
+
* this.initResources()
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
export declare class EventHandler extends CommonConstruct {
|
|
22
|
+
props: EventHandlerProps;
|
|
23
|
+
id: string;
|
|
24
|
+
handler: Handler;
|
|
25
|
+
provisionTarget: boolean;
|
|
26
|
+
securityGroup: ISecurityGroup;
|
|
27
|
+
useMapState: boolean;
|
|
28
|
+
vpc: IVpc;
|
|
29
|
+
constructor(parent: Construct, id: string, props: EventHandlerProps);
|
|
30
|
+
initResources(): void;
|
|
31
|
+
/**
|
|
32
|
+
* @summary Method to resolve common vpc or create a new one.
|
|
33
|
+
*/
|
|
34
|
+
protected resolveVpc(): void;
|
|
35
|
+
/**
|
|
36
|
+
* @summary Method to resolve the exported security group.
|
|
37
|
+
*/
|
|
38
|
+
protected resolveSecurityGroup(): void;
|
|
39
|
+
/**
|
|
40
|
+
* @summary Method to create sqs event source if queue targets are defined.
|
|
41
|
+
*/
|
|
42
|
+
protected createSQSEventSource(): void;
|
|
43
|
+
/**
|
|
44
|
+
* @summary Method to create the event rule pattern.
|
|
45
|
+
*/
|
|
46
|
+
protected createEventRulePattern(): void;
|
|
47
|
+
/**
|
|
48
|
+
* @summary Method to create the event rule targets.
|
|
49
|
+
*/
|
|
50
|
+
protected createEventRuleTargets(): void;
|
|
51
|
+
/**
|
|
52
|
+
* @summary Method to resolve the event bus name or use the default bus.
|
|
53
|
+
*/
|
|
54
|
+
protected resolveEventBus(): void;
|
|
55
|
+
/**
|
|
56
|
+
* @summary Method to create an event archive if the event rule is not a scheduled one.
|
|
57
|
+
*/
|
|
58
|
+
protected createEventArchive(): void;
|
|
59
|
+
/**
|
|
60
|
+
* @summary Method to create the event rule.
|
|
61
|
+
*/
|
|
62
|
+
protected createEventRule(): void;
|
|
63
|
+
/**
|
|
64
|
+
* @summary Method to create the workflow steps.
|
|
65
|
+
*/
|
|
66
|
+
protected createWorkflowSteps(): void;
|
|
67
|
+
/**
|
|
68
|
+
* @summary Method to create the workflow definition.
|
|
69
|
+
*/
|
|
70
|
+
protected createWorkflowDefinition(): void;
|
|
71
|
+
/**
|
|
72
|
+
* @summary Method to create the workflow policy.
|
|
73
|
+
*/
|
|
74
|
+
protected createWorkflowPolicy(): void;
|
|
75
|
+
/**
|
|
76
|
+
* @summary Method to create the workflow role.
|
|
77
|
+
*/
|
|
78
|
+
protected createWorkflowRole(): void;
|
|
79
|
+
/**
|
|
80
|
+
* @summary Method to create the workflow log group.
|
|
81
|
+
*/
|
|
82
|
+
protected createWorkflowLogGroup(): void;
|
|
83
|
+
/**
|
|
84
|
+
* @summary Method to create the workflow state machine.
|
|
85
|
+
*/
|
|
86
|
+
protected createWorkflowStateMachine(): void;
|
|
87
|
+
/**
|
|
88
|
+
* @summary Method to create the workflow.
|
|
89
|
+
*/
|
|
90
|
+
protected createWorkflow(): void;
|
|
91
|
+
}
|