@gradientedge/cdk-utils 4.1.1 → 4.2.2
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/dist/index.d.ts +3 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -25
- package/dist/index.js.map +1 -1
- package/dist/src/lib/common/commonConstruct.d.ts +30 -50
- package/dist/src/lib/common/commonConstruct.d.ts.map +1 -1
- package/dist/src/lib/common/commonConstruct.js +53 -54
- package/dist/src/lib/common/commonConstruct.js.map +1 -1
- package/dist/src/lib/common/commonStack.d.ts +3 -2
- package/dist/src/lib/common/commonStack.d.ts.map +1 -1
- package/dist/src/lib/common/commonStack.js +2 -1
- package/dist/src/lib/common/commonStack.js.map +1 -1
- package/dist/src/lib/common/index.d.ts +3 -0
- package/dist/src/lib/common/index.d.ts.map +1 -0
- package/dist/src/lib/common/index.js +15 -0
- package/dist/src/lib/common/index.js.map +1 -0
- package/dist/src/lib/construct/graphQLApiLambda.d.ts +6 -5
- package/dist/src/lib/construct/graphQLApiLambda.d.ts.map +1 -1
- package/dist/src/lib/construct/graphQLApiLambda.js +3 -2
- package/dist/src/lib/construct/graphQLApiLambda.js.map +1 -1
- package/dist/src/lib/construct/index.d.ts +4 -0
- package/dist/src/lib/construct/index.d.ts.map +1 -0
- package/dist/src/lib/construct/index.js +16 -0
- package/dist/src/lib/construct/index.js.map +1 -0
- package/dist/src/lib/construct/siteWithEcsBackend.d.ts +21 -8
- package/dist/src/lib/construct/siteWithEcsBackend.d.ts.map +1 -1
- package/dist/src/lib/construct/siteWithEcsBackend.js +33 -5
- package/dist/src/lib/construct/siteWithEcsBackend.js.map +1 -1
- package/dist/src/lib/construct/staticSite.d.ts +18 -5
- package/dist/src/lib/construct/staticSite.d.ts.map +1 -1
- package/dist/src/lib/construct/staticSite.js +31 -2
- package/dist/src/lib/construct/staticSite.js.map +1 -1
- package/dist/src/lib/manager/{acmManager.d.ts → aws/acmManager.d.ts} +9 -8
- package/dist/src/lib/manager/aws/acmManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{acmManager.js → aws/acmManager.js} +9 -8
- package/dist/src/lib/manager/aws/acmManager.js.map +1 -0
- package/dist/src/lib/manager/{apiManager.d.ts → aws/apiManager.d.ts} +12 -11
- package/dist/src/lib/manager/aws/apiManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{apiManager.js → aws/apiManager.js} +13 -11
- package/dist/src/lib/manager/aws/apiManager.js.map +1 -0
- package/dist/src/lib/manager/{appConfigManager.d.ts → aws/appConfigManager.d.ts} +18 -17
- package/dist/src/lib/manager/aws/appConfigManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{appConfigManager.js → aws/appConfigManager.js} +20 -19
- package/dist/src/lib/manager/aws/appConfigManager.js.map +1 -0
- package/dist/src/lib/manager/aws/cloudFrontManager.d.ts +112 -0
- package/dist/src/lib/manager/aws/cloudFrontManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{cloudFrontManager.js → aws/cloudFrontManager.js} +49 -25
- package/dist/src/lib/manager/aws/cloudFrontManager.js.map +1 -0
- package/dist/src/lib/manager/{cloudTrailManager.d.ts → aws/cloudTrailManager.d.ts} +10 -9
- package/dist/src/lib/manager/aws/cloudTrailManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{cloudTrailManager.js → aws/cloudTrailManager.js} +10 -9
- package/dist/src/lib/manager/aws/cloudTrailManager.js.map +1 -0
- package/dist/src/lib/manager/aws/cloudWatchManager.d.ts +121 -0
- package/dist/src/lib/manager/aws/cloudWatchManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{cloudWatchManager.js → aws/cloudWatchManager.js} +48 -36
- package/dist/src/lib/manager/aws/cloudWatchManager.js.map +1 -0
- package/dist/src/lib/manager/aws/codeBuildManager.d.ts +40 -0
- package/dist/src/lib/manager/aws/codeBuildManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{codeBuildManager.js → aws/codeBuildManager.js} +17 -1
- package/dist/src/lib/manager/aws/codeBuildManager.js.map +1 -0
- package/dist/src/lib/manager/{ecrManager.d.ts → aws/ecrManager.d.ts} +8 -7
- package/dist/src/lib/manager/aws/ecrManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{ecrManager.js → aws/ecrManager.js} +8 -7
- package/dist/src/lib/manager/aws/ecrManager.js.map +1 -0
- package/dist/src/lib/manager/{ecsManager.d.ts → aws/ecsManager.d.ts} +13 -12
- package/dist/src/lib/manager/aws/ecsManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{ecsManager.js → aws/ecsManager.js} +13 -12
- package/dist/src/lib/manager/aws/ecsManager.js.map +1 -0
- package/dist/src/lib/manager/{eksManager.d.ts → aws/eksManager.d.ts} +10 -9
- package/dist/src/lib/manager/aws/eksManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{eksManager.js → aws/eksManager.js} +10 -9
- package/dist/src/lib/manager/aws/eksManager.js.map +1 -0
- package/dist/src/lib/manager/{eventManager.d.ts → aws/eventManager.d.ts} +13 -12
- package/dist/src/lib/manager/aws/eventManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{eventManager.js → aws/eventManager.js} +14 -13
- package/dist/src/lib/manager/aws/eventManager.js.map +1 -0
- package/dist/src/lib/manager/aws/iamManager.d.ts +156 -0
- package/dist/src/lib/manager/aws/iamManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{iamManager.js → aws/iamManager.js} +37 -35
- package/dist/src/lib/manager/aws/iamManager.js.map +1 -0
- package/dist/src/lib/manager/aws/index.d.ts +22 -0
- package/dist/src/lib/manager/aws/index.d.ts.map +1 -0
- package/dist/src/lib/manager/aws/index.js +34 -0
- package/dist/src/lib/manager/aws/index.js.map +1 -0
- package/dist/src/lib/manager/{lambdaManager.d.ts → aws/lambdaManager.d.ts} +21 -20
- package/dist/src/lib/manager/aws/lambdaManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{lambdaManager.js → aws/lambdaManager.js} +21 -20
- package/dist/src/lib/manager/aws/lambdaManager.js.map +1 -0
- package/dist/src/lib/manager/aws/logManager.d.ts +51 -0
- package/dist/src/lib/manager/aws/logManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{logManager.js → aws/logManager.js} +14 -13
- package/dist/src/lib/manager/aws/logManager.js.map +1 -0
- package/dist/src/lib/manager/{route53Manager.d.ts → aws/route53Manager.d.ts} +18 -17
- package/dist/src/lib/manager/aws/route53Manager.d.ts.map +1 -0
- package/dist/src/lib/manager/{route53Manager.js → aws/route53Manager.js} +19 -18
- package/dist/src/lib/manager/aws/route53Manager.js.map +1 -0
- package/dist/src/lib/manager/aws/s3Manager.d.ts +73 -0
- package/dist/src/lib/manager/aws/s3Manager.d.ts.map +1 -0
- package/dist/src/lib/manager/{s3Manager.js → aws/s3Manager.js} +17 -16
- package/dist/src/lib/manager/aws/s3Manager.js.map +1 -0
- package/dist/src/lib/manager/{secretsManager.d.ts → aws/secretsManager.d.ts} +8 -7
- package/dist/src/lib/manager/aws/secretsManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{secretsManager.js → aws/secretsManager.js} +6 -5
- package/dist/src/lib/manager/aws/secretsManager.js.map +1 -0
- package/dist/src/lib/manager/aws/snsManager.d.ts +42 -0
- package/dist/src/lib/manager/aws/snsManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{snsManager.js → aws/snsManager.js} +14 -13
- package/dist/src/lib/manager/aws/snsManager.js.map +1 -0
- package/dist/src/lib/manager/aws/ssmManager.d.ts +64 -0
- package/dist/src/lib/manager/aws/ssmManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{ssmManager.js → aws/ssmManager.js} +15 -14
- package/dist/src/lib/manager/aws/ssmManager.js.map +1 -0
- package/dist/src/lib/manager/{vpcManager.d.ts → aws/vpcManager.d.ts} +12 -11
- package/dist/src/lib/manager/aws/vpcManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{vpcManager.js → aws/vpcManager.js} +15 -14
- package/dist/src/lib/manager/aws/vpcManager.js.map +1 -0
- package/dist/src/lib/manager/aws/wafManager.d.ts +39 -0
- package/dist/src/lib/manager/aws/wafManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{wafManager.js → aws/wafManager.js} +14 -13
- package/dist/src/lib/manager/aws/wafManager.js.map +1 -0
- package/dist/src/lib/manager/index.d.ts +2 -0
- package/dist/src/lib/manager/index.d.ts.map +1 -0
- package/dist/src/lib/manager/index.js +14 -0
- package/dist/src/lib/manager/index.js.map +1 -0
- package/dist/src/lib/{types.d.ts → types/aws/index.d.ts} +27 -16
- package/dist/src/lib/types/aws/index.d.ts.map +1 -0
- package/dist/src/lib/{types.js → types/aws/index.js} +1 -1
- package/dist/src/lib/types/aws/index.js.map +1 -0
- package/dist/src/lib/types/index.d.ts +2 -0
- package/dist/src/lib/types/index.d.ts.map +1 -0
- package/dist/src/lib/types/index.js +14 -0
- package/dist/src/lib/types/index.js.map +1 -0
- package/dist/src/lib/utils/aws/index.d.ts +16 -0
- package/dist/src/lib/utils/aws/index.d.ts.map +1 -0
- package/dist/src/lib/utils/aws/index.js +50 -0
- package/dist/src/lib/utils/aws/index.js.map +1 -0
- package/dist/src/lib/{utils.d.ts → utils/index.d.ts} +2 -26
- package/dist/src/lib/utils/index.d.ts.map +1 -0
- package/dist/src/lib/utils/index.js +85 -0
- package/dist/src/lib/utils/index.js.map +1 -0
- package/index.ts +3 -25
- package/package.json +27 -19
- package/src/lib/common/commonConstruct.ts +58 -78
- package/src/lib/common/commonStack.ts +3 -2
- package/src/lib/common/index.ts +2 -0
- package/src/lib/construct/graphQLApiLambda.ts +6 -5
- package/src/lib/construct/index.ts +3 -0
- package/src/lib/construct/siteWithEcsBackend.ts +45 -10
- package/src/lib/construct/staticSite.ts +41 -6
- package/src/lib/manager/{acmManager.ts → aws/acmManager.ts} +13 -12
- package/src/lib/manager/{apiManager.ts → aws/apiManager.ts} +17 -15
- package/src/lib/manager/{appConfigManager.ts → aws/appConfigManager.ts} +32 -27
- package/src/lib/manager/{cloudFrontManager.ts → aws/cloudFrontManager.ts} +69 -40
- package/src/lib/manager/{cloudTrailManager.ts → aws/cloudTrailManager.ts} +14 -13
- package/src/lib/manager/{cloudWatchManager.ts → aws/cloudWatchManager.ts} +80 -57
- package/src/lib/manager/{codeBuildManager.ts → aws/codeBuildManager.ts} +20 -4
- package/src/lib/manager/{ecrManager.ts → aws/ecrManager.ts} +10 -9
- package/src/lib/manager/{ecsManager.ts → aws/ecsManager.ts} +18 -17
- package/src/lib/manager/{eksManager.ts → aws/eksManager.ts} +14 -13
- package/src/lib/manager/{eventManager.ts → aws/eventManager.ts} +20 -19
- package/src/lib/manager/{iamManager.ts → aws/iamManager.ts} +67 -55
- package/src/lib/manager/aws/index.ts +21 -0
- package/src/lib/manager/{lambdaManager.ts → aws/lambdaManager.ts} +31 -30
- package/src/lib/manager/{logManager.ts → aws/logManager.ts} +24 -18
- package/src/lib/manager/{route53Manager.ts → aws/route53Manager.ts} +26 -25
- package/src/lib/manager/{s3Manager.ts → aws/s3Manager.ts} +26 -25
- package/src/lib/manager/{secretsManager.ts → aws/secretsManager.ts} +13 -7
- package/src/lib/manager/{snsManager.ts → aws/snsManager.ts} +20 -19
- package/src/lib/manager/{ssmManager.ts → aws/ssmManager.ts} +26 -20
- package/src/lib/manager/{vpcManager.ts → aws/vpcManager.ts} +19 -18
- package/src/lib/manager/{wafManager.ts → aws/wafManager.ts} +18 -17
- package/src/lib/manager/index.ts +1 -0
- package/src/lib/{types.ts → types/aws/index.ts} +27 -15
- package/src/lib/types/index.ts +1 -0
- package/src/lib/utils/aws/index.ts +34 -0
- package/src/lib/{utils.ts → utils/index.ts} +1 -45
- package/dist/src/lib/manager/acmManager.d.ts.map +0 -1
- package/dist/src/lib/manager/acmManager.js.map +0 -1
- package/dist/src/lib/manager/apiManager.d.ts.map +0 -1
- package/dist/src/lib/manager/apiManager.js.map +0 -1
- package/dist/src/lib/manager/appConfigManager.d.ts.map +0 -1
- package/dist/src/lib/manager/appConfigManager.js.map +0 -1
- package/dist/src/lib/manager/cloudFrontManager.d.ts +0 -100
- package/dist/src/lib/manager/cloudFrontManager.d.ts.map +0 -1
- package/dist/src/lib/manager/cloudFrontManager.js.map +0 -1
- package/dist/src/lib/manager/cloudTrailManager.d.ts.map +0 -1
- package/dist/src/lib/manager/cloudTrailManager.js.map +0 -1
- package/dist/src/lib/manager/cloudWatchManager.d.ts +0 -120
- package/dist/src/lib/manager/cloudWatchManager.d.ts.map +0 -1
- package/dist/src/lib/manager/cloudWatchManager.js.map +0 -1
- package/dist/src/lib/manager/codeBuildManager.d.ts +0 -25
- package/dist/src/lib/manager/codeBuildManager.d.ts.map +0 -1
- package/dist/src/lib/manager/codeBuildManager.js.map +0 -1
- package/dist/src/lib/manager/ecrManager.d.ts.map +0 -1
- package/dist/src/lib/manager/ecrManager.js.map +0 -1
- package/dist/src/lib/manager/ecsManager.d.ts.map +0 -1
- package/dist/src/lib/manager/ecsManager.js.map +0 -1
- package/dist/src/lib/manager/eksManager.d.ts.map +0 -1
- package/dist/src/lib/manager/eksManager.js.map +0 -1
- package/dist/src/lib/manager/eventManager.d.ts.map +0 -1
- package/dist/src/lib/manager/eventManager.js.map +0 -1
- package/dist/src/lib/manager/iamManager.d.ts +0 -154
- package/dist/src/lib/manager/iamManager.d.ts.map +0 -1
- package/dist/src/lib/manager/iamManager.js.map +0 -1
- package/dist/src/lib/manager/lambdaManager.d.ts.map +0 -1
- package/dist/src/lib/manager/lambdaManager.js.map +0 -1
- package/dist/src/lib/manager/logManager.d.ts +0 -50
- package/dist/src/lib/manager/logManager.d.ts.map +0 -1
- package/dist/src/lib/manager/logManager.js.map +0 -1
- package/dist/src/lib/manager/route53Manager.d.ts.map +0 -1
- package/dist/src/lib/manager/route53Manager.js.map +0 -1
- package/dist/src/lib/manager/s3Manager.d.ts +0 -72
- package/dist/src/lib/manager/s3Manager.d.ts.map +0 -1
- package/dist/src/lib/manager/s3Manager.js.map +0 -1
- package/dist/src/lib/manager/secretsManager.d.ts.map +0 -1
- package/dist/src/lib/manager/secretsManager.js.map +0 -1
- package/dist/src/lib/manager/snsManager.d.ts +0 -41
- package/dist/src/lib/manager/snsManager.d.ts.map +0 -1
- package/dist/src/lib/manager/snsManager.js.map +0 -1
- package/dist/src/lib/manager/ssmManager.d.ts +0 -63
- package/dist/src/lib/manager/ssmManager.d.ts.map +0 -1
- package/dist/src/lib/manager/ssmManager.js.map +0 -1
- package/dist/src/lib/manager/vpcManager.d.ts.map +0 -1
- package/dist/src/lib/manager/vpcManager.js.map +0 -1
- package/dist/src/lib/manager/wafManager.d.ts +0 -38
- package/dist/src/lib/manager/wafManager.d.ts.map +0 -1
- package/dist/src/lib/manager/wafManager.js.map +0 -1
- package/dist/src/lib/types.d.ts.map +0 -1
- package/dist/src/lib/types.js.map +0 -1
- package/dist/src/lib/utils.d.ts.map +0 -1
- package/dist/src/lib/utils.js +0 -131
- package/dist/src/lib/utils.js.map +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Construct } from 'constructs'
|
|
2
|
-
import { CommonConstruct } from '../common/commonConstruct'
|
|
3
|
-
import { SiteWithEcsBackendProps } from '../types'
|
|
4
1
|
import * as cdk from 'aws-cdk-lib'
|
|
5
|
-
import * as iam from 'aws-cdk-lib/aws-iam'
|
|
6
|
-
import * as ec2 from 'aws-cdk-lib/aws-ec2'
|
|
7
|
-
import * as ecs from 'aws-cdk-lib/aws-ecs'
|
|
8
|
-
import * as logs from 'aws-cdk-lib/aws-logs'
|
|
9
|
-
import * as route53 from 'aws-cdk-lib/aws-route53'
|
|
10
2
|
import * as certificateManager from 'aws-cdk-lib/aws-certificatemanager'
|
|
11
3
|
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'
|
|
4
|
+
import * as origins from 'aws-cdk-lib/aws-cloudfront-origins'
|
|
5
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2'
|
|
6
|
+
import * as ecs from 'aws-cdk-lib/aws-ecs'
|
|
12
7
|
import * as ecsPatterns from 'aws-cdk-lib/aws-ecs-patterns'
|
|
13
8
|
import * as elb from 'aws-cdk-lib/aws-elasticloadbalancingv2'
|
|
14
|
-
import * as
|
|
9
|
+
import * as iam from 'aws-cdk-lib/aws-iam'
|
|
10
|
+
import * as logs from 'aws-cdk-lib/aws-logs'
|
|
11
|
+
import * as route53 from 'aws-cdk-lib/aws-route53'
|
|
15
12
|
import * as s3 from 'aws-cdk-lib/aws-s3'
|
|
16
13
|
import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager'
|
|
14
|
+
import { Construct } from 'constructs'
|
|
15
|
+
import { CommonConstruct } from '../common/commonConstruct'
|
|
16
|
+
import { SiteWithEcsBackendProps } from '../types'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* @stability stable
|
|
@@ -30,6 +30,7 @@ import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager'
|
|
|
30
30
|
* this.props = props
|
|
31
31
|
* this.id = id
|
|
32
32
|
* this.initResources()
|
|
33
|
+
* }
|
|
33
34
|
* }
|
|
34
35
|
*
|
|
35
36
|
* @mermaid
|
|
@@ -67,6 +68,8 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
67
68
|
siteInternalDomainName: string
|
|
68
69
|
siteExternalDomainName: string
|
|
69
70
|
siteDomainNames: string[]
|
|
71
|
+
siteCloudfrontFunction: cloudfront.Function
|
|
72
|
+
siteFunctionAssociations: cloudfront.FunctionAssociation[]
|
|
70
73
|
|
|
71
74
|
/**
|
|
72
75
|
* @summary Constructor to initialise the SiteWithEcsBackend Construct
|
|
@@ -101,6 +104,8 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
101
104
|
this.createEcsService()
|
|
102
105
|
this.createSiteLogBucket()
|
|
103
106
|
this.createSiteOrigin()
|
|
107
|
+
this.createSiteCloudfrontFunction()
|
|
108
|
+
this.resolveSiteFunctionAssociations()
|
|
104
109
|
this.createDistribution()
|
|
105
110
|
this.createNetworkMappings()
|
|
106
111
|
this.invalidateDistributionCache()
|
|
@@ -315,6 +320,35 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
315
320
|
})
|
|
316
321
|
}
|
|
317
322
|
|
|
323
|
+
/**
|
|
324
|
+
* @summary Method to create a site cloudfront function
|
|
325
|
+
* @protected
|
|
326
|
+
*/
|
|
327
|
+
protected createSiteCloudfrontFunction() {
|
|
328
|
+
if (this.props.siteCloudfrontFunctionProps) {
|
|
329
|
+
this.siteCloudfrontFunction = this.cloudFrontManager.createCloudfrontFunction(
|
|
330
|
+
`${this.id}-function`,
|
|
331
|
+
this,
|
|
332
|
+
this.props.siteCloudfrontFunctionProps
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* @summary Method to create a site cloudfront function associations
|
|
339
|
+
* @protected
|
|
340
|
+
*/
|
|
341
|
+
protected resolveSiteFunctionAssociations() {
|
|
342
|
+
if (this.props.siteCloudfrontFunctionProps) {
|
|
343
|
+
this.siteFunctionAssociations = [
|
|
344
|
+
{
|
|
345
|
+
function: this.siteCloudfrontFunction,
|
|
346
|
+
eventType: cloudfront.FunctionEventType.VIEWER_REQUEST,
|
|
347
|
+
},
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
318
352
|
/**
|
|
319
353
|
* Method to create Site distribution
|
|
320
354
|
* @protected
|
|
@@ -327,7 +361,8 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
327
361
|
this.siteOrigin,
|
|
328
362
|
this.siteDomainNames,
|
|
329
363
|
this.siteLogBucket,
|
|
330
|
-
this.siteCertificate
|
|
364
|
+
this.siteCertificate,
|
|
365
|
+
this.siteFunctionAssociations
|
|
331
366
|
)
|
|
332
367
|
}
|
|
333
368
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CommonConstruct } from '../common/commonConstruct'
|
|
2
|
-
import { StaticSiteProps } from '../types'
|
|
3
|
-
import * as route53 from 'aws-cdk-lib/aws-route53'
|
|
4
1
|
import * as certificateManager from 'aws-cdk-lib/aws-certificatemanager'
|
|
5
|
-
import * as s3 from 'aws-cdk-lib/aws-s3'
|
|
6
2
|
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'
|
|
7
|
-
import { Construct } from 'constructs'
|
|
8
3
|
import * as origins from 'aws-cdk-lib/aws-cloudfront-origins'
|
|
4
|
+
import * as route53 from 'aws-cdk-lib/aws-route53'
|
|
5
|
+
import * as s3 from 'aws-cdk-lib/aws-s3'
|
|
6
|
+
import { Construct } from 'constructs'
|
|
7
|
+
import { CommonConstruct } from '../common/commonConstruct'
|
|
8
|
+
import { StaticSiteProps } from '../types'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @stability stable
|
|
@@ -22,6 +22,7 @@ import * as origins from 'aws-cdk-lib/aws-cloudfront-origins'
|
|
|
22
22
|
* this.props = props
|
|
23
23
|
* this.id = id
|
|
24
24
|
* this.initResources()
|
|
25
|
+
* }
|
|
25
26
|
* }
|
|
26
27
|
*
|
|
27
28
|
* @mermaid
|
|
@@ -45,6 +46,8 @@ export class StaticSite extends CommonConstruct {
|
|
|
45
46
|
siteDistribution: cloudfront.Distribution
|
|
46
47
|
siteLogBucket: s3.IBucket
|
|
47
48
|
siteOriginAccessIdentity: cloudfront.OriginAccessIdentity
|
|
49
|
+
siteCloudfrontFunction: cloudfront.Function
|
|
50
|
+
siteFunctionAssociations: cloudfront.FunctionAssociation[]
|
|
48
51
|
|
|
49
52
|
/**
|
|
50
53
|
* @summary Constructor to initialise the StaticSite Construct
|
|
@@ -69,6 +72,8 @@ export class StaticSite extends CommonConstruct {
|
|
|
69
72
|
this.createSiteLogBucket()
|
|
70
73
|
this.createSiteBucket()
|
|
71
74
|
this.createSiteOrigin()
|
|
75
|
+
this.createSiteCloudfrontFunction()
|
|
76
|
+
this.resolveSiteFunctionAssociations()
|
|
72
77
|
this.createSiteDistribution()
|
|
73
78
|
this.createSiteRouteAssets()
|
|
74
79
|
this.deploySite()
|
|
@@ -130,6 +135,35 @@ export class StaticSite extends CommonConstruct {
|
|
|
130
135
|
this.siteOrigin = new origins.S3Origin(this.siteBucket)
|
|
131
136
|
}
|
|
132
137
|
|
|
138
|
+
/**
|
|
139
|
+
* @summary Method to create a site cloudfront function
|
|
140
|
+
* @protected
|
|
141
|
+
*/
|
|
142
|
+
protected createSiteCloudfrontFunction() {
|
|
143
|
+
if (this.props.siteCloudfrontFunctionProps) {
|
|
144
|
+
this.siteCloudfrontFunction = this.cloudFrontManager.createCloudfrontFunction(
|
|
145
|
+
`${this.id}-function`,
|
|
146
|
+
this,
|
|
147
|
+
this.props.siteCloudfrontFunctionProps
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @summary Method to create a site cloudfront function associations
|
|
154
|
+
* @protected
|
|
155
|
+
*/
|
|
156
|
+
protected resolveSiteFunctionAssociations() {
|
|
157
|
+
if (this.props.siteCloudfrontFunctionProps) {
|
|
158
|
+
this.siteFunctionAssociations = [
|
|
159
|
+
{
|
|
160
|
+
function: this.siteCloudfrontFunction,
|
|
161
|
+
eventType: cloudfront.FunctionEventType.VIEWER_REQUEST,
|
|
162
|
+
},
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
133
167
|
/**
|
|
134
168
|
* @summary Method to create a site cloudfront distribution
|
|
135
169
|
* @protected
|
|
@@ -146,7 +180,8 @@ export class StaticSite extends CommonConstruct {
|
|
|
146
180
|
this.siteLogBucket,
|
|
147
181
|
this.siteOriginAccessIdentity,
|
|
148
182
|
this.siteCertificate,
|
|
149
|
-
this.props.siteAliases
|
|
183
|
+
this.props.siteAliases,
|
|
184
|
+
this.siteFunctionAssociations
|
|
150
185
|
)
|
|
151
186
|
}
|
|
152
187
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import * as cdk from 'aws-cdk-lib'
|
|
1
2
|
import * as acm from 'aws-cdk-lib/aws-certificatemanager'
|
|
2
3
|
import * as route53 from 'aws-cdk-lib/aws-route53'
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { createCfnOutput } from '../utils'
|
|
4
|
+
import * as common from '../../common'
|
|
5
|
+
import * as types from '../../types'
|
|
6
|
+
import * as utils from '../../utils'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @stability stable
|
|
10
10
|
* @category Security, Identity & Compliance
|
|
11
11
|
* @summary Provides operations on AWS Certificates.
|
|
12
|
-
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
13
|
-
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
12
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
13
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
14
14
|
* @example
|
|
15
15
|
* import { CommonConstruct } from '@gradientedge/cdk-utils'
|
|
16
16
|
*
|
|
@@ -19,16 +19,17 @@ import { createCfnOutput } from '../utils'
|
|
|
19
19
|
* super(parent, id, props)
|
|
20
20
|
* this.props = props
|
|
21
21
|
* this.acmManager.createCertificate('MyCertificate', this)
|
|
22
|
+
* }
|
|
22
23
|
* }
|
|
23
24
|
*
|
|
24
|
-
* @see [CDK Certificate Module]{@link https://docs.aws.amazon.com/cdk/api/
|
|
25
|
+
* @see [CDK Certificate Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_certificatemanager-readme.html}
|
|
25
26
|
*/
|
|
26
27
|
export class AcmManager {
|
|
27
28
|
/**
|
|
28
29
|
* @summary Method to create/import a certificate
|
|
29
30
|
* @param {string} id scoped id of the resource
|
|
30
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
31
|
-
* @param {AcmProps} props certificate props
|
|
31
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
32
|
+
* @param {types.AcmProps} props certificate props
|
|
32
33
|
* @param {route53.HostedZone?} hostedZone optional hosted zone to perform DNS validation
|
|
33
34
|
* @returns {acm.ICertificate}
|
|
34
35
|
*
|
|
@@ -45,8 +46,8 @@ export class AcmManager {
|
|
|
45
46
|
*/
|
|
46
47
|
public resolveCertificate(
|
|
47
48
|
id: string,
|
|
48
|
-
scope: CommonConstruct,
|
|
49
|
-
props: AcmProps,
|
|
49
|
+
scope: common.CommonConstruct,
|
|
50
|
+
props: types.AcmProps,
|
|
50
51
|
hostedZone?: route53.IHostedZone
|
|
51
52
|
): acm.ICertificate {
|
|
52
53
|
if (!props) throw `Certificate props undefined`
|
|
@@ -69,7 +70,7 @@ export class AcmManager {
|
|
|
69
70
|
})
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
createCfnOutput(`${id}-certificateArn`, scope, certificate.certificateArn)
|
|
73
|
+
utils.createCfnOutput(`${id}-certificateArn`, scope, certificate.certificateArn)
|
|
73
74
|
|
|
74
75
|
return certificate
|
|
75
76
|
}
|
|
@@ -1,45 +1,47 @@
|
|
|
1
|
-
import { CommonConstruct } from '../common/commonConstruct'
|
|
2
1
|
import * as apig from 'aws-cdk-lib/aws-apigateway'
|
|
3
|
-
import * as lambda from 'aws-cdk-lib/aws-lambda'
|
|
4
2
|
import * as acm from 'aws-cdk-lib/aws-certificatemanager'
|
|
5
|
-
import
|
|
3
|
+
import * as lambda from 'aws-cdk-lib/aws-lambda'
|
|
4
|
+
import * as common from '../../common'
|
|
5
|
+
import * as utils from '../../utils'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @stability stable
|
|
9
9
|
* @category Networking & Content Delivery
|
|
10
10
|
* @summary Provides operations on AWS API Gateway.
|
|
11
|
-
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
12
|
-
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
11
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
12
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
13
13
|
* @example
|
|
14
|
-
* import { CommonConstruct } from '@gradientedge/cdk-utils'
|
|
14
|
+
* import { common.CommonConstruct } from '@gradientedge/cdk-utils'
|
|
15
15
|
*
|
|
16
|
-
* class CustomConstruct extends CommonConstruct {
|
|
16
|
+
* class CustomConstruct extends common.CommonConstruct {
|
|
17
17
|
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
18
18
|
* super(parent, id, props)
|
|
19
19
|
* this.props = props
|
|
20
20
|
* const lambdaFunction = this.lambdaManager.createLambdaFunction('MyFunction', this, role, layers, code)
|
|
21
21
|
* this.apiManager.createLambdaRestApi('MyCertificate', this, props, lambdaFunction)
|
|
22
|
+
* }
|
|
22
23
|
* }
|
|
23
24
|
*
|
|
24
|
-
* @see [CDK API Gateway Module]{@link https://docs.aws.amazon.com/cdk/api/
|
|
25
|
+
* @see [CDK API Gateway Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway-readme.html}
|
|
25
26
|
*/
|
|
26
27
|
export class ApiManager {
|
|
27
28
|
/**
|
|
28
29
|
* @summary Method to create a Rest API with Lambda backend/target
|
|
29
30
|
* @param {string} id scoped id of the resource
|
|
30
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
31
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
31
32
|
* @param {AcmProps} props lambda rest api props
|
|
32
33
|
* @param lambdaFunction
|
|
33
34
|
*/
|
|
34
35
|
public createLambdaRestApi(
|
|
35
36
|
id: string,
|
|
36
|
-
scope: CommonConstruct,
|
|
37
|
+
scope: common.CommonConstruct,
|
|
37
38
|
props: apig.LambdaRestApiProps,
|
|
38
39
|
lambdaFunction: lambda.Function
|
|
39
40
|
) {
|
|
40
41
|
const api = new apig.LambdaRestApi(scope, `${id}`, {
|
|
41
42
|
binaryMediaTypes: props.binaryMediaTypes,
|
|
42
43
|
minimumCompressionSize: props.minimumCompressionSize,
|
|
44
|
+
defaultMethodOptions: props.defaultMethodOptions,
|
|
43
45
|
deploy: props.deploy || true,
|
|
44
46
|
deployOptions: {
|
|
45
47
|
stageName: scope.props.stage,
|
|
@@ -74,8 +76,8 @@ export class ApiManager {
|
|
|
74
76
|
proxy: props.proxy || true,
|
|
75
77
|
})
|
|
76
78
|
|
|
77
|
-
createCfnOutput(`${id}-restApiId`, scope, api.restApiId)
|
|
78
|
-
createCfnOutput(`${id}-restApiName`, scope, api.restApiName)
|
|
79
|
+
utils.createCfnOutput(`${id}-restApiId`, scope, api.restApiId)
|
|
80
|
+
utils.createCfnOutput(`${id}-restApiName`, scope, api.restApiName)
|
|
79
81
|
|
|
80
82
|
return api
|
|
81
83
|
}
|
|
@@ -83,11 +85,11 @@ export class ApiManager {
|
|
|
83
85
|
/**
|
|
84
86
|
* @summary Method to create custom api domain
|
|
85
87
|
* @param {string} id scoped id of the resource
|
|
86
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
88
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
87
89
|
* @param domainName the domain name to use
|
|
88
90
|
* @param certificate the certificate used for custom api domain
|
|
89
91
|
*/
|
|
90
|
-
public createApiDomain(id: string, scope: CommonConstruct, domainName: string, certificate: acm.ICertificate) {
|
|
92
|
+
public createApiDomain(id: string, scope: common.CommonConstruct, domainName: string, certificate: acm.ICertificate) {
|
|
91
93
|
const apiDomain = new apig.DomainName(scope, `${id}`, {
|
|
92
94
|
domainName: domainName,
|
|
93
95
|
certificate: certificate,
|
|
@@ -95,7 +97,7 @@ export class ApiManager {
|
|
|
95
97
|
securityPolicy: apig.SecurityPolicy.TLS_1_2,
|
|
96
98
|
})
|
|
97
99
|
|
|
98
|
-
createCfnOutput(`${id}-customDomainName`, scope, apiDomain.domainName)
|
|
100
|
+
utils.createCfnOutput(`${id}-customDomainName`, scope, apiDomain.domainName)
|
|
99
101
|
|
|
100
102
|
return apiDomain
|
|
101
103
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as appconfig from 'aws-cdk-lib/aws-appconfig'
|
|
2
1
|
import * as cdk from 'aws-cdk-lib'
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
2
|
+
import * as appconfig from 'aws-cdk-lib/aws-appconfig'
|
|
3
|
+
import * as common from '../../common'
|
|
4
|
+
import * as types from '../../types'
|
|
5
|
+
import * as utils from '../../utils'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @stability stable
|
|
@@ -35,37 +35,42 @@ export const ArnsByRegion: { [key: string]: string } = {
|
|
|
35
35
|
/**
|
|
36
36
|
* @category Management & Governance
|
|
37
37
|
* @summary Provides operations on AWS AppConfig.
|
|
38
|
-
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
39
|
-
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
38
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
39
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
40
40
|
* @example
|
|
41
41
|
* import * as common from '@gradientedge/cdk-utils'
|
|
42
42
|
*
|
|
43
|
-
* class CustomConstruct extends common.CommonConstruct {
|
|
43
|
+
* class CustomConstruct extends common.common.CommonConstruct {
|
|
44
44
|
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
45
45
|
* super(parent, id, props)
|
|
46
46
|
* this.props = props
|
|
47
47
|
* this.appConfigManager.createApplication('MyApplication', this)
|
|
48
|
+
* }
|
|
48
49
|
* }
|
|
49
50
|
*
|
|
50
|
-
* @see [CDK AppConfig Module]{@link https://docs.aws.amazon.com/cdk/api/
|
|
51
|
+
* @see [CDK AppConfig Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appconfig-readme.html}
|
|
51
52
|
*/
|
|
52
53
|
export class AppConfigManager {
|
|
53
54
|
/**
|
|
54
55
|
* Method to get static ARNs for AppConfig extensions
|
|
55
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
56
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
56
57
|
*/
|
|
57
|
-
public getArnForAppConfigExtension(scope: CommonConstruct) {
|
|
58
|
+
public getArnForAppConfigExtension(scope: common.CommonConstruct) {
|
|
58
59
|
return ArnsByRegion[scope.props.region]
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* @summary Method to create an AppConfig Application
|
|
63
64
|
* @param {string} id scoped id of the resource
|
|
64
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
65
|
-
* @param {AppConfigProps} props
|
|
65
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
66
|
+
* @param {types.AppConfigProps} props
|
|
66
67
|
* @returns {appconfig.CfnApplication}
|
|
67
68
|
*/
|
|
68
|
-
public createApplication(
|
|
69
|
+
public createApplication(
|
|
70
|
+
id: string,
|
|
71
|
+
scope: common.CommonConstruct,
|
|
72
|
+
props: types.AppConfigProps
|
|
73
|
+
): appconfig.CfnApplication {
|
|
69
74
|
if (!props) throw `AppConfig props undefined`
|
|
70
75
|
|
|
71
76
|
const application = new appconfig.CfnApplication(scope, `${id}`, {
|
|
@@ -74,8 +79,8 @@ export class AppConfigManager {
|
|
|
74
79
|
tags: props.application.tags,
|
|
75
80
|
})
|
|
76
81
|
|
|
77
|
-
createCfnOutput(`${id}-ApplicationId`, scope, cdk.Fn.ref(application.logicalId))
|
|
78
|
-
createCfnOutput(`${id}-ApplicationName`, scope, application.name)
|
|
82
|
+
utils.createCfnOutput(`${id}-ApplicationId`, scope, cdk.Fn.ref(application.logicalId))
|
|
83
|
+
utils.createCfnOutput(`${id}-ApplicationName`, scope, application.name)
|
|
79
84
|
|
|
80
85
|
return application
|
|
81
86
|
}
|
|
@@ -83,16 +88,16 @@ export class AppConfigManager {
|
|
|
83
88
|
/**
|
|
84
89
|
* @summary Method to create an AppConfig Environment for a given application
|
|
85
90
|
* @param {string} id scoped id of the resource
|
|
86
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
91
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
87
92
|
* @param {string} applicationId id of the application
|
|
88
|
-
* @param {AppConfigProps} props
|
|
93
|
+
* @param {types.AppConfigProps} props
|
|
89
94
|
* @returns {appconfig.CfnEnvironment}
|
|
90
95
|
*/
|
|
91
96
|
public createEnvironment(
|
|
92
97
|
id: string,
|
|
93
|
-
scope: CommonConstruct,
|
|
98
|
+
scope: common.CommonConstruct,
|
|
94
99
|
applicationId: string,
|
|
95
|
-
props: AppConfigProps
|
|
100
|
+
props: types.AppConfigProps
|
|
96
101
|
): appconfig.CfnEnvironment {
|
|
97
102
|
if (!props) throw `AppConfig props undefined`
|
|
98
103
|
|
|
@@ -104,8 +109,8 @@ export class AppConfigManager {
|
|
|
104
109
|
tags: props.environment.tags,
|
|
105
110
|
})
|
|
106
111
|
|
|
107
|
-
createCfnOutput(`${id}-configurationEnvironmentId`, scope, cdk.Fn.ref(environment.logicalId))
|
|
108
|
-
createCfnOutput(`${id}-configurationEnvironmentName`, scope, environment.name)
|
|
112
|
+
utils.createCfnOutput(`${id}-configurationEnvironmentId`, scope, cdk.Fn.ref(environment.logicalId))
|
|
113
|
+
utils.createCfnOutput(`${id}-configurationEnvironmentName`, scope, environment.name)
|
|
109
114
|
|
|
110
115
|
return environment
|
|
111
116
|
}
|
|
@@ -114,16 +119,16 @@ export class AppConfigManager {
|
|
|
114
119
|
* @summary Method to create an AppConfig Configuration Profile for a given application
|
|
115
120
|
* - <p>⚠ The <b>locationUri</b> is defaulted to <i>hosted</i> if undefined</p>
|
|
116
121
|
* @param {string} id scoped id of the resource
|
|
117
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
122
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
118
123
|
* @param {string} applicationId id of the application
|
|
119
|
-
* @param {AppConfigProps} props
|
|
124
|
+
* @param {types.AppConfigProps} props
|
|
120
125
|
* @returns {appconfig.CfnConfigurationProfile}
|
|
121
126
|
*/
|
|
122
127
|
public createConfigurationProfile(
|
|
123
128
|
id: string,
|
|
124
|
-
scope: CommonConstruct,
|
|
129
|
+
scope: common.CommonConstruct,
|
|
125
130
|
applicationId: string,
|
|
126
|
-
props: AppConfigProps
|
|
131
|
+
props: types.AppConfigProps
|
|
127
132
|
): appconfig.CfnConfigurationProfile {
|
|
128
133
|
if (!props) throw `AppConfig props undefined`
|
|
129
134
|
|
|
@@ -137,8 +142,8 @@ export class AppConfigManager {
|
|
|
137
142
|
validators: props.configurationProfile.validators,
|
|
138
143
|
})
|
|
139
144
|
|
|
140
|
-
createCfnOutput(`${id}-configurationProfileId`, scope, cdk.Fn.ref(profile.logicalId))
|
|
141
|
-
createCfnOutput(`${id}-configurationProfileName`, scope, profile.name)
|
|
145
|
+
utils.createCfnOutput(`${id}-configurationProfileId`, scope, cdk.Fn.ref(profile.logicalId))
|
|
146
|
+
utils.createCfnOutput(`${id}-configurationProfileName`, scope, profile.name)
|
|
142
147
|
|
|
143
148
|
return profile
|
|
144
149
|
}
|