@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,41 @@
|
|
|
1
|
+
import { BucketDeploymentProps, S3BucketProps } from '../../services/index.js';
|
|
2
|
+
import { CommonStackProps } from '../../common/index.js';
|
|
3
|
+
export interface AssetExport {
|
|
4
|
+
key: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The CloudFront distribution to associate with the bucket.
|
|
9
|
+
* When value is configured, the construct will invalidate the distribution after the deployment.
|
|
10
|
+
* Use either domainName or distributionId or domainNameRef or distributionIdRef.
|
|
11
|
+
*/
|
|
12
|
+
export interface StaticCloudFrontDistribution {
|
|
13
|
+
/**
|
|
14
|
+
* @summary The domain name to associate with the bucket.
|
|
15
|
+
*/
|
|
16
|
+
domainName?: string;
|
|
17
|
+
/**
|
|
18
|
+
* @summary The distribution ID to associate with the bucket.
|
|
19
|
+
*/
|
|
20
|
+
distributionId?: string;
|
|
21
|
+
/**
|
|
22
|
+
* @summary The reference to domain name to associate with the bucket.
|
|
23
|
+
*/
|
|
24
|
+
domainNameRef?: string;
|
|
25
|
+
/**
|
|
26
|
+
* @summary The reference to distribution ID to associate with the bucket.
|
|
27
|
+
*/
|
|
28
|
+
distributionIdRef?: string;
|
|
29
|
+
/**
|
|
30
|
+
* @summary The paths to invalidate after deployment. Default is ['/*']
|
|
31
|
+
*/
|
|
32
|
+
invalidationPaths: string[];
|
|
33
|
+
}
|
|
34
|
+
export interface StaticAssetDeploymentProps extends CommonStackProps {
|
|
35
|
+
staticAssetBucket: S3BucketProps;
|
|
36
|
+
staticAssetDeployment: BucketDeploymentProps;
|
|
37
|
+
staticAssetSources: any[] | string[];
|
|
38
|
+
staticAssetsForExport?: AssetExport[];
|
|
39
|
+
destinationKeyPrefix?: string;
|
|
40
|
+
cloudFrontDistribution?: StaticCloudFrontDistribution;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager';
|
|
2
|
+
import { FunctionAssociation, IDistribution, IFunction, OriginAccessIdentity } from 'aws-cdk-lib/aws-cloudfront';
|
|
3
|
+
import { ARecord, IHostedZone } from 'aws-cdk-lib/aws-route53';
|
|
4
|
+
import { IBucket } from 'aws-cdk-lib/aws-s3';
|
|
5
|
+
import { Construct } from 'constructs';
|
|
6
|
+
import { CommonConstruct } from '../../common/index.js';
|
|
7
|
+
import { StaticSiteProps } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* @classdesc Provides a construct to create and deploy a s3 hosted static site
|
|
10
|
+
* @example
|
|
11
|
+
* import { StaticSite, StaticSiteProps } '@gradientedge/cdk-utils'
|
|
12
|
+
* import { Construct } from 'constructs'
|
|
13
|
+
*
|
|
14
|
+
* class CustomConstruct extends StaticSite {
|
|
15
|
+
* constructor(parent: Construct, id: string, props: StaticSiteProps) {
|
|
16
|
+
* super(parent, id, props)
|
|
17
|
+
* this.props = props
|
|
18
|
+
* this.id = id
|
|
19
|
+
* this.initResources()
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
export declare class StaticSite extends CommonConstruct {
|
|
24
|
+
props: StaticSiteProps;
|
|
25
|
+
id: string;
|
|
26
|
+
siteHostedZone: IHostedZone;
|
|
27
|
+
siteCertificate: ICertificate;
|
|
28
|
+
siteARecord: ARecord;
|
|
29
|
+
siteBucket: IBucket;
|
|
30
|
+
siteDistribution: IDistribution;
|
|
31
|
+
siteLogBucket: IBucket;
|
|
32
|
+
siteOriginAccessIdentity: OriginAccessIdentity;
|
|
33
|
+
siteCloudfrontFunction: IFunction;
|
|
34
|
+
siteFunctionAssociations: FunctionAssociation[];
|
|
35
|
+
constructor(parent: Construct, id: string, props: StaticSiteProps);
|
|
36
|
+
/**
|
|
37
|
+
* @summary Initialise and provision resources
|
|
38
|
+
*/
|
|
39
|
+
initResources(): void;
|
|
40
|
+
/**
|
|
41
|
+
* @summary Method to resolve a hosted zone based on domain attributes
|
|
42
|
+
*/
|
|
43
|
+
protected resolveHostedZone(): void;
|
|
44
|
+
/**
|
|
45
|
+
* @summary Method to resolve a certificate based on attributes
|
|
46
|
+
*/
|
|
47
|
+
protected resolveCertificate(): void;
|
|
48
|
+
/**
|
|
49
|
+
* @summary Method to create a site log bucket
|
|
50
|
+
*/
|
|
51
|
+
protected createSiteLogBucket(): void;
|
|
52
|
+
/**
|
|
53
|
+
* @summary Method to create a site bucket
|
|
54
|
+
*/
|
|
55
|
+
protected createSiteBucket(): void;
|
|
56
|
+
/**
|
|
57
|
+
* @summary Method to create a site cloudfront function
|
|
58
|
+
*/
|
|
59
|
+
protected createSiteCloudfrontFunction(): void;
|
|
60
|
+
/**
|
|
61
|
+
* @summary Method to create a site cloudfront function associations
|
|
62
|
+
*/
|
|
63
|
+
protected resolveSiteFunctionAssociations(): void;
|
|
64
|
+
/**
|
|
65
|
+
* @summary Method to create a site origin access identity
|
|
66
|
+
*/
|
|
67
|
+
protected createSiteOriginAccessIdentity(): void;
|
|
68
|
+
/**
|
|
69
|
+
* @summary Method to create a site cloudfront distribution
|
|
70
|
+
*/
|
|
71
|
+
protected createSiteDistribution(): void;
|
|
72
|
+
/**
|
|
73
|
+
* @summary Method to create route53 records for static site
|
|
74
|
+
*/
|
|
75
|
+
protected createSiteRouteAssets(): void;
|
|
76
|
+
/**
|
|
77
|
+
* @summary Method to deploy the static assets into s3 bucket for static site
|
|
78
|
+
*/
|
|
79
|
+
protected deploySite(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Method to invalidation the cloudfront distribution cache after a deployment
|
|
82
|
+
*/
|
|
83
|
+
protected invalidateDistributionCache(): void;
|
|
84
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { FunctionEventType, } from 'aws-cdk-lib/aws-cloudfront';
|
|
2
|
+
import { CommonConstruct } from '../../common/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* @classdesc Provides a construct to create and deploy a s3 hosted static site
|
|
5
|
+
* @example
|
|
6
|
+
* import { StaticSite, StaticSiteProps } '@gradientedge/cdk-utils'
|
|
7
|
+
* import { Construct } from 'constructs'
|
|
8
|
+
*
|
|
9
|
+
* class CustomConstruct extends StaticSite {
|
|
10
|
+
* constructor(parent: Construct, id: string, props: StaticSiteProps) {
|
|
11
|
+
* super(parent, id, props)
|
|
12
|
+
* this.props = props
|
|
13
|
+
* this.id = id
|
|
14
|
+
* this.initResources()
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
export class StaticSite extends CommonConstruct {
|
|
19
|
+
/* static site properties */
|
|
20
|
+
props;
|
|
21
|
+
id;
|
|
22
|
+
/* static site resources */
|
|
23
|
+
siteHostedZone;
|
|
24
|
+
siteCertificate;
|
|
25
|
+
siteARecord;
|
|
26
|
+
siteBucket;
|
|
27
|
+
siteDistribution;
|
|
28
|
+
siteLogBucket;
|
|
29
|
+
siteOriginAccessIdentity;
|
|
30
|
+
siteCloudfrontFunction;
|
|
31
|
+
siteFunctionAssociations;
|
|
32
|
+
constructor(parent, id, props) {
|
|
33
|
+
super(parent, id, props);
|
|
34
|
+
this.props = props;
|
|
35
|
+
this.id = id;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @summary Initialise and provision resources
|
|
39
|
+
*/
|
|
40
|
+
initResources() {
|
|
41
|
+
this.resolveHostedZone();
|
|
42
|
+
this.resolveCertificate();
|
|
43
|
+
this.createSiteLogBucket();
|
|
44
|
+
this.createSiteBucket();
|
|
45
|
+
this.createSiteCloudfrontFunction();
|
|
46
|
+
this.resolveSiteFunctionAssociations();
|
|
47
|
+
this.createSiteOriginAccessIdentity();
|
|
48
|
+
this.createSiteDistribution();
|
|
49
|
+
this.createSiteRouteAssets();
|
|
50
|
+
this.deploySite();
|
|
51
|
+
this.invalidateDistributionCache();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @summary Method to resolve a hosted zone based on domain attributes
|
|
55
|
+
*/
|
|
56
|
+
resolveHostedZone() {
|
|
57
|
+
this.siteHostedZone = this.route53Manager.withHostedZoneFromFullyQualifiedDomainName(`${this.id}-hosted-zone`, this, this.props.useExistingHostedZone);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @summary Method to resolve a certificate based on attributes
|
|
61
|
+
*/
|
|
62
|
+
resolveCertificate() {
|
|
63
|
+
if (this.props.siteCertificate.useExistingCertificate &&
|
|
64
|
+
this.props.siteCertificate.certificateSsmName &&
|
|
65
|
+
this.props.siteCertificate.certificateRegion) {
|
|
66
|
+
this.props.siteCertificate.certificateArn = this.ssmManager.readStringParameterFromRegion(`${this.id}-certificate-param`, this, this.props.siteCertificate.certificateSsmName, this.props.siteCertificate.certificateRegion);
|
|
67
|
+
}
|
|
68
|
+
this.siteCertificate = this.acmManager.resolveCertificate(`${this.id}-certificate`, this, this.props.siteCertificate);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @summary Method to create a site log bucket
|
|
72
|
+
*/
|
|
73
|
+
createSiteLogBucket() {
|
|
74
|
+
this.siteLogBucket = this.s3Manager.createS3Bucket(`${this.id}-site-logs`, this, this.props.siteLogBucket);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @summary Method to create a site bucket
|
|
78
|
+
*/
|
|
79
|
+
createSiteBucket() {
|
|
80
|
+
this.siteBucket = this.s3Manager.createS3Bucket(`${this.id}-site`, this, this.props.siteBucket);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* @summary Method to create a site cloudfront function
|
|
84
|
+
*/
|
|
85
|
+
createSiteCloudfrontFunction() {
|
|
86
|
+
if (this.props.siteCloudfrontFunctionProps) {
|
|
87
|
+
this.siteCloudfrontFunction = this.cloudFrontManager.createCloudfrontFunction(`${this.id}-function`, this, this.props.siteCloudfrontFunctionProps);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @summary Method to create a site cloudfront function associations
|
|
92
|
+
*/
|
|
93
|
+
resolveSiteFunctionAssociations() {
|
|
94
|
+
if (this.props.siteCloudfrontFunctionProps) {
|
|
95
|
+
this.siteFunctionAssociations = [
|
|
96
|
+
{
|
|
97
|
+
eventType: FunctionEventType.VIEWER_REQUEST,
|
|
98
|
+
function: this.siteCloudfrontFunction,
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @summary Method to create a site origin access identity
|
|
105
|
+
*/
|
|
106
|
+
createSiteOriginAccessIdentity() { }
|
|
107
|
+
/**
|
|
108
|
+
* @summary Method to create a site cloudfront distribution
|
|
109
|
+
*/
|
|
110
|
+
createSiteDistribution() {
|
|
111
|
+
if (!this.props.siteDistribution)
|
|
112
|
+
throw 'SiteDistribution props undefined';
|
|
113
|
+
this.siteDistribution = this.cloudFrontManager.createDistributionWithS3Origin(`${this.id}-distribution`, this, this.props.siteDistribution, this.siteBucket, this.siteLogBucket, this.siteOriginAccessIdentity, this.siteCertificate, this.props.siteAliases, this.siteFunctionAssociations);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @summary Method to create route53 records for static site
|
|
117
|
+
*/
|
|
118
|
+
createSiteRouteAssets() {
|
|
119
|
+
this.siteARecord = this.route53Manager.createCloudFrontTargetARecord(`${this.id}-domain-a-record`, this, this.siteDistribution, this.siteHostedZone, this.props.siteRecordName, this.props.skipStageForARecords);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @summary Method to deploy the static assets into s3 bucket for static site
|
|
123
|
+
*/
|
|
124
|
+
deploySite() {
|
|
125
|
+
const prune = this.props.pruneOnDeployment ?? true;
|
|
126
|
+
this.s3Manager.doBucketDeployment(`${this.id}-deployment`, this, this.siteBucket, this.siteDistribution, [this.props.siteSource], '', prune);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Method to invalidation the cloudfront distribution cache after a deployment
|
|
130
|
+
*/
|
|
131
|
+
invalidateDistributionCache() {
|
|
132
|
+
if (this.props.siteCacheInvalidationDockerFilePath) {
|
|
133
|
+
this.cloudFrontManager.invalidateCache(`${this.id}-cache-invalidation`, this, this.props.siteCacheInvalidationDockerFilePath, this.siteDistribution.distributionId);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CommonStackProps } from '../../common/index.js';
|
|
2
|
+
import { AcmProps, CloudfrontFunctionProps, DistributionProps, S3BucketProps } from '../../services/index.js';
|
|
3
|
+
import { ISource } from 'aws-cdk-lib/aws-s3-deployment';
|
|
4
|
+
/**
|
|
5
|
+
*/
|
|
6
|
+
export interface StaticSiteProps extends CommonStackProps {
|
|
7
|
+
logLevel: string;
|
|
8
|
+
nodeEnv: string;
|
|
9
|
+
siteAliases?: string[];
|
|
10
|
+
siteBucket: S3BucketProps;
|
|
11
|
+
siteCacheInvalidationDockerFilePath?: string;
|
|
12
|
+
siteCertificate: AcmProps;
|
|
13
|
+
siteCloudfrontFunctionProps?: CloudfrontFunctionProps;
|
|
14
|
+
siteCreateAltARecord: boolean;
|
|
15
|
+
siteDistribution?: DistributionProps;
|
|
16
|
+
siteFunctionFilePath?: string;
|
|
17
|
+
siteHostedZoneDomainName?: string;
|
|
18
|
+
siteLogBucket: S3BucketProps;
|
|
19
|
+
siteRecordName?: string;
|
|
20
|
+
siteSource: ISource;
|
|
21
|
+
siteSubDomain?: string;
|
|
22
|
+
timezone: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to prune the contents of the bucket when deploying assets.
|
|
25
|
+
*
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
pruneOnDeployment?: boolean;
|
|
29
|
+
useExistingHostedZone: boolean;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { DomainName, IAuthorizer, IResource, IRestApi, Integration, LambdaRestApi, MethodResponse } from 'aws-cdk-lib/aws-apigateway';
|
|
2
|
+
import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager';
|
|
3
|
+
import { IFunction } from 'aws-cdk-lib/aws-lambda';
|
|
4
|
+
import { CommonConstruct } from '../../common/index.js';
|
|
5
|
+
import { LambdaRestApiProps } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides operations on AWS API Gateway.
|
|
8
|
+
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
9
|
+
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
10
|
+
* @example
|
|
11
|
+
* import { CommonConstruct } from '@gradientedge/cdk-utils'
|
|
12
|
+
*
|
|
13
|
+
* class CustomConstruct extends CommonConstruct {
|
|
14
|
+
* constructor(parent: Construct, id: string, props: common.CommonStackProps) {
|
|
15
|
+
* super(parent, id, props)
|
|
16
|
+
* this.props = props
|
|
17
|
+
* const lambdaFunction = this.lambdaManager.createLambdaFunction('MyFunction', this, role, layers, code)
|
|
18
|
+
* this.apiManager.createLambdaRestApi('MyCertificate', this, props, lambdaFunction)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* @see [CDK API Gateway Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway-readme.html}
|
|
22
|
+
*/
|
|
23
|
+
export declare class ApiManager {
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to create a Rest API with Lambda backend/target
|
|
26
|
+
* @param id scoped id of the resource
|
|
27
|
+
* @param scope scope in which this resource is defined
|
|
28
|
+
* @param props lambda rest restApi props
|
|
29
|
+
* @param lambdaFunction
|
|
30
|
+
*/
|
|
31
|
+
createLambdaRestApi(id: string, scope: CommonConstruct, props: LambdaRestApiProps, lambdaFunction: IFunction): LambdaRestApi;
|
|
32
|
+
/**
|
|
33
|
+
* @summary Method to create custom restApi domain
|
|
34
|
+
* @param id scoped id of the resource
|
|
35
|
+
* @param scope scope in which this resource is defined
|
|
36
|
+
* @param domainName the domain name to use
|
|
37
|
+
* @param certificate the certificate used for custom restApi domain
|
|
38
|
+
*/
|
|
39
|
+
createApiDomain(id: string, scope: CommonConstruct, domainName: string, certificate: ICertificate): DomainName;
|
|
40
|
+
/**
|
|
41
|
+
* @summary Method to create an API gateway resource
|
|
42
|
+
* @param id
|
|
43
|
+
* @param scope
|
|
44
|
+
* @param parent
|
|
45
|
+
* @param path
|
|
46
|
+
* @param integration
|
|
47
|
+
* @param addProxy
|
|
48
|
+
* @param authorizer
|
|
49
|
+
* @param allowedOrigins
|
|
50
|
+
* @param allowedMethods
|
|
51
|
+
* @param allowedHeaders
|
|
52
|
+
* @param methodRequestParameters
|
|
53
|
+
* @param proxyIntegration
|
|
54
|
+
* @param enableDefaultCors
|
|
55
|
+
* @param mockIntegration
|
|
56
|
+
* @param mockMethodResponses
|
|
57
|
+
*/
|
|
58
|
+
createApiResource(id: string, scope: CommonConstruct, parent: IResource, path: string, integration: Integration, addProxy: boolean, authorizer?: IAuthorizer, allowedOrigins?: string[], allowedMethods?: string[], allowedHeaders?: string[], methodRequestParameters?: {
|
|
59
|
+
[param: string]: boolean;
|
|
60
|
+
}, proxyIntegration?: Integration, enableDefaultCors?: boolean, mockIntegration?: Integration, mockMethodResponses?: MethodResponse[]): import("aws-cdk-lib/aws-apigateway").Resource;
|
|
61
|
+
/**
|
|
62
|
+
* @summary Method to create an api deployment
|
|
63
|
+
* @param id
|
|
64
|
+
* @param scope
|
|
65
|
+
* @param api
|
|
66
|
+
*/
|
|
67
|
+
createApiDeployment(id: string, scope: CommonConstruct, api: IRestApi): void;
|
|
68
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { RemovalPolicy, Size, Tags } from 'aws-cdk-lib';
|
|
2
|
+
import { Cors, Deployment, DomainName, EndpointType, LambdaRestApi, LogGroupLogDestination, SecurityPolicy, } from 'aws-cdk-lib/aws-apigateway';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import { createCfnOutput } from '../../utils/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* @classdesc Provides operations on AWS API Gateway.
|
|
7
|
+
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
8
|
+
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
9
|
+
* @example
|
|
10
|
+
* import { CommonConstruct } from '@gradientedge/cdk-utils'
|
|
11
|
+
*
|
|
12
|
+
* class CustomConstruct extends CommonConstruct {
|
|
13
|
+
* constructor(parent: Construct, id: string, props: common.CommonStackProps) {
|
|
14
|
+
* super(parent, id, props)
|
|
15
|
+
* this.props = props
|
|
16
|
+
* const lambdaFunction = this.lambdaManager.createLambdaFunction('MyFunction', this, role, layers, code)
|
|
17
|
+
* this.apiManager.createLambdaRestApi('MyCertificate', this, props, lambdaFunction)
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* @see [CDK API Gateway Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway-readme.html}
|
|
21
|
+
*/
|
|
22
|
+
export class ApiManager {
|
|
23
|
+
/**
|
|
24
|
+
* @summary Method to create a Rest API with Lambda backend/target
|
|
25
|
+
* @param id scoped id of the resource
|
|
26
|
+
* @param scope scope in which this resource is defined
|
|
27
|
+
* @param props lambda rest restApi props
|
|
28
|
+
* @param lambdaFunction
|
|
29
|
+
*/
|
|
30
|
+
createLambdaRestApi(id, scope, props, lambdaFunction) {
|
|
31
|
+
if (!props)
|
|
32
|
+
throw `Api props undefined for ${id}`;
|
|
33
|
+
if (!props.restApiName)
|
|
34
|
+
throw `Api restApiName undefined for ${id}`;
|
|
35
|
+
const restApiName = scope.resourceNameFormatter.format(props.restApiName, scope.props.resourceNameOptions?.apigateway);
|
|
36
|
+
const restApiAccessLogName = scope.resourceNameFormatter.format(`${props.restApiName}-access`, scope.props.resourceNameOptions?.apigateway);
|
|
37
|
+
const accessLogGroup = scope.logManager.createLogGroup(`${id}-rest-api-access-log`, scope, {
|
|
38
|
+
logGroupName: restApiAccessLogName,
|
|
39
|
+
removalPolicy: RemovalPolicy.DESTROY,
|
|
40
|
+
});
|
|
41
|
+
const api = new LambdaRestApi(scope, `${id}`, {
|
|
42
|
+
...props,
|
|
43
|
+
cloudWatchRole: props.cloudWatchRole || false,
|
|
44
|
+
deploy: props.deploy || true,
|
|
45
|
+
deployOptions: {
|
|
46
|
+
...props.deployOptions,
|
|
47
|
+
accessLogDestination: new LogGroupLogDestination(accessLogGroup),
|
|
48
|
+
description: `${id} - ${scope.props.stage} stage`,
|
|
49
|
+
stageName: scope.props.stage,
|
|
50
|
+
},
|
|
51
|
+
endpointConfiguration: {
|
|
52
|
+
...props.endpointConfiguration,
|
|
53
|
+
types: props.endpointConfiguration?.types || [EndpointType.REGIONAL],
|
|
54
|
+
},
|
|
55
|
+
failOnWarnings: props.failOnWarnings || false,
|
|
56
|
+
handler: lambdaFunction,
|
|
57
|
+
minCompressionSize: props.minCompressionSizeInBytes ? Size.bytes(props.minCompressionSizeInBytes) : undefined,
|
|
58
|
+
proxy: props.proxy ?? true,
|
|
59
|
+
restApiName,
|
|
60
|
+
});
|
|
61
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
62
|
+
_.forEach(props.tags, tag => {
|
|
63
|
+
Tags.of(api).add(tag.key, tag.value);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
createCfnOutput(`${id}-restApiId`, scope, api.restApiId);
|
|
67
|
+
createCfnOutput(`${id}-restApiName`, scope, api.restApiName);
|
|
68
|
+
return api;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @summary Method to create custom restApi domain
|
|
72
|
+
* @param id scoped id of the resource
|
|
73
|
+
* @param scope scope in which this resource is defined
|
|
74
|
+
* @param domainName the domain name to use
|
|
75
|
+
* @param certificate the certificate used for custom restApi domain
|
|
76
|
+
*/
|
|
77
|
+
createApiDomain(id, scope, domainName, certificate) {
|
|
78
|
+
const apiDomain = new DomainName(scope, `${id}`, {
|
|
79
|
+
certificate,
|
|
80
|
+
domainName,
|
|
81
|
+
endpointType: scope.isProductionStage() ? EndpointType.EDGE : EndpointType.REGIONAL,
|
|
82
|
+
securityPolicy: SecurityPolicy.TLS_1_2,
|
|
83
|
+
});
|
|
84
|
+
createCfnOutput(`${id}-customDomainName`, scope, apiDomain.domainName);
|
|
85
|
+
return apiDomain;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @summary Method to create an API gateway resource
|
|
89
|
+
* @param id
|
|
90
|
+
* @param scope
|
|
91
|
+
* @param parent
|
|
92
|
+
* @param path
|
|
93
|
+
* @param integration
|
|
94
|
+
* @param addProxy
|
|
95
|
+
* @param authorizer
|
|
96
|
+
* @param allowedOrigins
|
|
97
|
+
* @param allowedMethods
|
|
98
|
+
* @param allowedHeaders
|
|
99
|
+
* @param methodRequestParameters
|
|
100
|
+
* @param proxyIntegration
|
|
101
|
+
* @param enableDefaultCors
|
|
102
|
+
* @param mockIntegration
|
|
103
|
+
* @param mockMethodResponses
|
|
104
|
+
*/
|
|
105
|
+
createApiResource(id, scope, parent, path, integration, addProxy, authorizer, allowedOrigins, allowedMethods, allowedHeaders, methodRequestParameters, proxyIntegration, enableDefaultCors, mockIntegration, mockMethodResponses) {
|
|
106
|
+
const methods = allowedMethods ?? Cors.ALL_METHODS;
|
|
107
|
+
let defaultCorsPreflightOptions;
|
|
108
|
+
if (enableDefaultCors === false) {
|
|
109
|
+
defaultCorsPreflightOptions = undefined;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
defaultCorsPreflightOptions = {
|
|
113
|
+
allowCredentials: true,
|
|
114
|
+
allowHeaders: allowedHeaders ?? Cors.DEFAULT_HEADERS,
|
|
115
|
+
allowMethods: [...methods, 'OPTIONS'],
|
|
116
|
+
allowOrigins: allowedOrigins ?? Cors.ALL_ORIGINS,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const resource = parent.addResource(path, {
|
|
120
|
+
defaultCorsPreflightOptions: defaultCorsPreflightOptions,
|
|
121
|
+
});
|
|
122
|
+
_.forEach(methods, method => {
|
|
123
|
+
if (enableDefaultCors === false && mockIntegration && method === 'OPTIONS') {
|
|
124
|
+
resource.addMethod(method, mockIntegration, {
|
|
125
|
+
authorizer,
|
|
126
|
+
requestParameters: methodRequestParameters,
|
|
127
|
+
methodResponses: mockMethodResponses,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
resource.addMethod(method, integration, {
|
|
132
|
+
authorizer,
|
|
133
|
+
requestParameters: methodRequestParameters,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
createCfnOutput(`${id}-${path}ResourceId`, scope, resource.resourceId);
|
|
138
|
+
if (addProxy) {
|
|
139
|
+
const resourceProxy = resource.addResource(`{${path}+}`, {
|
|
140
|
+
defaultCorsPreflightOptions: defaultCorsPreflightOptions,
|
|
141
|
+
});
|
|
142
|
+
_.forEach(methods, method => {
|
|
143
|
+
if (enableDefaultCors === false && mockIntegration && method === 'OPTIONS') {
|
|
144
|
+
resourceProxy.addMethod(method, mockIntegration, {
|
|
145
|
+
authorizer,
|
|
146
|
+
requestParameters: methodRequestParameters,
|
|
147
|
+
methodResponses: mockMethodResponses,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
resourceProxy.addMethod(method, proxyIntegration ?? integration, {
|
|
152
|
+
authorizer,
|
|
153
|
+
requestParameters: methodRequestParameters,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
createCfnOutput(`${id}-${path}ProxyResourceId`, scope, resourceProxy.resourceId);
|
|
158
|
+
}
|
|
159
|
+
return resource;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @summary Method to create an api deployment
|
|
163
|
+
* @param id
|
|
164
|
+
* @param scope
|
|
165
|
+
* @param api
|
|
166
|
+
*/
|
|
167
|
+
createApiDeployment(id, scope, api) {
|
|
168
|
+
new Deployment(scope, `${id}`, {
|
|
169
|
+
api,
|
|
170
|
+
retainDeployments: false,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LambdaRestApiProps as LambdaRestApigProps, RestApiProps } from 'aws-cdk-lib/aws-apigateway';
|
|
2
|
+
import { TagProps } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
*/
|
|
5
|
+
export interface LambdaRestApiProps extends LambdaRestApigProps {
|
|
6
|
+
tags?: TagProps[];
|
|
7
|
+
minCompressionSizeInBytes?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface RestApigProps extends RestApiProps {
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @returns { Map<string, string> } AppConfig extension ARN by region for x84
|
|
3
|
+
*/
|
|
4
|
+
export declare const ArnsByRegionForX86_64: {
|
|
5
|
+
[region: string]: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* @returns { Map<string, string> } AppConfig extension ARN by region for arm64
|
|
9
|
+
*/
|
|
10
|
+
export declare const ArnsByRegionForArm64: {
|
|
11
|
+
[region: string]: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @returns { Map<string, string> } AppConfig extension ARN by region for x84
|
|
3
|
+
*/
|
|
4
|
+
export const ArnsByRegionForX86_64 = {
|
|
5
|
+
'af-south-1': 'arn:aws:lambda:af-south-1:574348263942:layer:AWS-AppConfig-Extension:116',
|
|
6
|
+
'ap-east-1': 'arn:aws:lambda:ap-east-1:630222743974:layer:AWS-AppConfig-Extension:106',
|
|
7
|
+
'ap-northeast-1': 'arn:aws:lambda:ap-northeast-1:980059726660:layer:AWS-AppConfig-Extension:119',
|
|
8
|
+
'ap-northeast-2': 'arn:aws:lambda:ap-northeast-2:826293736237:layer:AWS-AppConfig-Extension:129',
|
|
9
|
+
'ap-northeast-3': 'arn:aws:lambda:ap-northeast-3:706869817123:layer:AWS-AppConfig-Extension:123',
|
|
10
|
+
'ap-south-1': 'arn:aws:lambda:ap-south-1:554480029851:layer:AWS-AppConfig-Extension:139',
|
|
11
|
+
'ap-south-2': 'arn:aws:lambda:ap-south-2:489524808438:layer:AWS-AppConfig-Extension:68',
|
|
12
|
+
'ap-southeast-1': 'arn:aws:lambda:ap-southeast-1:421114256042:layer:AWS-AppConfig-Extension:127',
|
|
13
|
+
'ap-southeast-2': 'arn:aws:lambda:ap-southeast-2:080788657173:layer:AWS-AppConfig-Extension:158',
|
|
14
|
+
'ap-southeast-3': 'arn:aws:lambda:ap-southeast-3:418787028745:layer:AWS-AppConfig-Extension:114',
|
|
15
|
+
'ap-southeast-4': 'arn:aws:lambda:ap-southeast-4:307021474294:layer:AWS-AppConfig-Extension:42',
|
|
16
|
+
'ca-central-1': 'arn:aws:lambda:ca-central-1:039592058896:layer:AWS-AppConfig-Extension:116',
|
|
17
|
+
'cn-north-1': 'arn:aws-cn:lambda:cn-north-1:615057806174:layer:AWS-AppConfig-Extension:99',
|
|
18
|
+
'cn-northwest-1': 'arn:aws-cn:lambda:cn-northwest-1:615084187847:layer:AWS-AppConfig-Extension:97',
|
|
19
|
+
'eu-central-1': 'arn:aws:lambda:eu-central-1:066940009817:layer:AWS-AppConfig-Extension:152',
|
|
20
|
+
'eu-central-2': 'arn:aws:lambda:eu-central-2:758369105281:layer:AWS-AppConfig-Extension:70',
|
|
21
|
+
'eu-north-1': 'arn:aws:lambda:eu-north-1:646970417810:layer:AWS-AppConfig-Extension:218',
|
|
22
|
+
'eu-south-1': 'arn:aws:lambda:eu-south-1:203683718741:layer:AWS-AppConfig-Extension:104',
|
|
23
|
+
'eu-south-2': 'arn:aws:lambda:eu-south-2:586093569114:layer:AWS-AppConfig-Extension:67',
|
|
24
|
+
'eu-west-1': 'arn:aws:lambda:eu-west-1:434848589818:layer:AWS-AppConfig-Extension:153',
|
|
25
|
+
'eu-west-2': 'arn:aws:lambda:eu-west-2:282860088358:layer:AWS-AppConfig-Extension:114',
|
|
26
|
+
'eu-west-3': 'arn:aws:lambda:eu-west-3:493207061005:layer:AWS-AppConfig-Extension:126',
|
|
27
|
+
'me-central-1': 'arn:aws:lambda:me-central-1:662846165436:layer:AWS-AppConfig-Extension:84',
|
|
28
|
+
'me-south-1': 'arn:aws:lambda:me-south-1:559955524753:layer:AWS-AppConfig-Extension:118',
|
|
29
|
+
'sa-east-1': 'arn:aws:lambda:sa-east-1:000010852771:layer:AWS-AppConfig-Extension:172',
|
|
30
|
+
'us-east-1': 'arn:aws:lambda:us-east-1:027255383542:layer:AWS-AppConfig-Extension:167',
|
|
31
|
+
'us-east-2': 'arn:aws:lambda:us-east-2:728743619870:layer:AWS-AppConfig-Extension:126',
|
|
32
|
+
'us-gov-east-1': 'arn:aws-us-gov:lambda:us-gov-east-1:946561847325:layer:AWS-AppConfig-Extension:73',
|
|
33
|
+
'us-gov-west-1': 'arn:aws-us-gov:lambda:us-gov-west-1:946746059096:layer:AWS-AppConfig-Extension:73',
|
|
34
|
+
'us-west-1': 'arn:aws:lambda:us-west-1:958113053741:layer:AWS-AppConfig-Extension:213',
|
|
35
|
+
'us-west-2': 'arn:aws:lambda:us-west-2:359756378197:layer:AWS-AppConfig-Extension:223',
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* @returns { Map<string, string> } AppConfig extension ARN by region for arm64
|
|
39
|
+
*/
|
|
40
|
+
export const ArnsByRegionForArm64 = {
|
|
41
|
+
'ap-northeast-1': 'arn:aws:lambda:ap-northeast-1:980059726660:layer:AWS-AppConfig-Extension-Arm64:72',
|
|
42
|
+
'ap-south-1': 'arn:aws:lambda:ap-south-1:554480029851:layer:AWS-AppConfig-Extension-Arm64:81',
|
|
43
|
+
'ap-southeast-1': 'arn:aws:lambda:ap-southeast-1:421114256042:layer:AWS-AppConfig-Extension-Arm64:79',
|
|
44
|
+
'ap-southeast-2': 'arn:aws:lambda:ap-southeast-2:080788657173:layer:AWS-AppConfig-Extension-Arm64:101',
|
|
45
|
+
'eu-central-1': 'arn:aws:lambda:eu-central-1:066940009817:layer:AWS-AppConfig-Extension-Arm64:95',
|
|
46
|
+
'eu-west-1': 'arn:aws:lambda:eu-west-1:434848589818:layer:AWS-AppConfig-Extension-Arm64:91',
|
|
47
|
+
'eu-west-2': 'arn:aws:lambda:eu-west-2:282860088358:layer:AWS-AppConfig-Extension-Arm64:66',
|
|
48
|
+
'us-east-1': 'arn:aws:lambda:us-east-1:027255383542:layer:AWS-AppConfig-Extension-Arm64:100',
|
|
49
|
+
'us-east-2': 'arn:aws:lambda:us-east-2:728743619870:layer:AWS-AppConfig-Extension-Arm64:78',
|
|
50
|
+
'us-west-2': 'arn:aws:lambda:us-west-2:359756378197:layer:AWS-AppConfig-Extension-Arm64:125',
|
|
51
|
+
};
|