@gradientedge/cdk-utils 8.118.0 → 8.119.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/app/api-destined-function/package.json +1 -1
- package/dist/src/lib/common/construct.d.ts +32 -32
- package/dist/src/lib/common/construct.js +36 -59
- package/dist/src/lib/common/stack.d.ts +8 -7
- package/dist/src/lib/common/stack.js +17 -37
- package/dist/src/lib/common/types.d.ts +2 -2
- package/dist/src/lib/construct/api-to-eventbridge-target/api.d.ts +22 -22
- package/dist/src/lib/construct/api-to-eventbridge-target/event.d.ts +9 -9
- package/dist/src/lib/construct/api-to-eventbridge-target/main.d.ts +3 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/main.js +37 -60
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.d.ts +9 -9
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.d.ts +3 -3
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.js +40 -63
- package/dist/src/lib/construct/api-to-lambda-target/api.d.ts +23 -23
- package/dist/src/lib/construct/api-to-lambda-target/main.d.ts +2 -2
- package/dist/src/lib/construct/api-to-lambda-target/main.js +15 -38
- package/dist/src/lib/construct/application-configuration/main.d.ts +7 -7
- package/dist/src/lib/construct/application-configuration/main.js +17 -41
- package/dist/src/lib/construct/graphql-api-lambda/main.d.ts +17 -17
- package/dist/src/lib/construct/graphql-api-lambda/main.js +6 -29
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts +5 -5
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +7 -7
- package/dist/src/lib/construct/lambda-with-iam-access/main.d.ts +16 -16
- package/dist/src/lib/construct/lambda-with-iam-access/main.js +8 -31
- package/dist/src/lib/construct/lambda-with-iam-access/types.d.ts +4 -4
- package/dist/src/lib/construct/rest-api-lambda/main.d.ts +16 -16
- package/dist/src/lib/construct/rest-api-lambda/main.js +5 -28
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.d.ts +5 -5
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.js +9 -32
- package/dist/src/lib/construct/site-with-ecs-backend/main.d.ts +38 -39
- package/dist/src/lib/construct/site-with-ecs-backend/main.js +33 -54
- package/dist/src/lib/construct/static-asset-deployment/main.d.ts +4 -4
- package/dist/src/lib/construct/static-asset-deployment/main.js +3 -26
- package/dist/src/lib/construct/static-site/main.d.ts +15 -15
- package/dist/src/lib/construct/static-site/main.js +4 -27
- package/dist/src/lib/services/aws/api-gateway/main.d.ts +10 -10
- package/dist/src/lib/services/aws/api-gateway/main.js +21 -44
- package/dist/src/lib/services/aws/api-gateway/types.d.ts +2 -2
- package/dist/src/lib/services/aws/appconfig/main.d.ts +7 -7
- package/dist/src/lib/services/aws/appconfig/main.js +14 -37
- package/dist/src/lib/services/aws/certificate-manager/main.d.ts +5 -5
- package/dist/src/lib/services/aws/certificate-manager/main.js +10 -33
- package/dist/src/lib/services/aws/certificate-manager/types.d.ts +2 -2
- package/dist/src/lib/services/aws/cloudfront/main.d.ts +18 -18
- package/dist/src/lib/services/aws/cloudfront/main.js +46 -45
- package/dist/src/lib/services/aws/cloudfront/types.d.ts +2 -3
- package/dist/src/lib/services/aws/cloudtrail/main.d.ts +5 -5
- package/dist/src/lib/services/aws/cloudtrail/main.js +5 -28
- package/dist/src/lib/services/aws/codebuild/main.d.ts +3 -3
- package/dist/src/lib/services/aws/codebuild/main.js +7 -30
- package/dist/src/lib/services/aws/dynamodb/main.d.ts +3 -3
- package/dist/src/lib/services/aws/dynamodb/main.js +8 -31
- package/dist/src/lib/services/aws/elastic-container-registry/main.d.ts +2 -2
- package/dist/src/lib/services/aws/elastic-container-registry/main.js +4 -27
- package/dist/src/lib/services/aws/elastic-container-service/main.d.ts +10 -10
- package/dist/src/lib/services/aws/elastic-container-service/main.js +27 -50
- package/dist/src/lib/services/aws/elastic-container-service/types.d.ts +4 -4
- package/dist/src/lib/services/aws/elastic-file-system/main.d.ts +3 -3
- package/dist/src/lib/services/aws/elastic-file-system/main.js +12 -35
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.d.ts +4 -4
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.js +8 -31
- package/dist/src/lib/services/aws/elasticache/main.d.ts +4 -4
- package/dist/src/lib/services/aws/elasticache/main.js +10 -33
- package/dist/src/lib/services/aws/eventbridge/main.d.ts +13 -13
- package/dist/src/lib/services/aws/eventbridge/main.js +26 -49
- package/dist/src/lib/services/aws/eventbridge/target.d.ts +10 -10
- package/dist/src/lib/services/aws/eventbridge/target.js +6 -29
- package/dist/src/lib/services/aws/evidently/main.d.ts +7 -7
- package/dist/src/lib/services/aws/evidently/main.js +18 -41
- package/dist/src/lib/services/aws/identity-access-management/main.d.ts +48 -49
- package/dist/src/lib/services/aws/identity-access-management/main.js +110 -133
- package/dist/src/lib/services/aws/key-management-service/main.d.ts +2 -2
- package/dist/src/lib/services/aws/key-management-service/main.js +5 -28
- package/dist/src/lib/services/aws/lambda/main.d.ts +11 -13
- package/dist/src/lib/services/aws/lambda/main.js +31 -58
- package/dist/src/lib/services/aws/route53/main.d.ts +9 -9
- package/dist/src/lib/services/aws/route53/main.js +21 -44
- package/dist/src/lib/services/aws/secrets-manager/main.d.ts +5 -6
- package/dist/src/lib/services/aws/secrets-manager/main.js +10 -33
- package/dist/src/lib/services/aws/simple-notification-service/main.d.ts +4 -4
- package/dist/src/lib/services/aws/simple-notification-service/main.js +11 -34
- package/dist/src/lib/services/aws/simple-queue-service/main.d.ts +6 -7
- package/dist/src/lib/services/aws/simple-queue-service/main.js +15 -38
- package/dist/src/lib/services/aws/simple-storage-service/main.d.ts +10 -11
- package/dist/src/lib/services/aws/simple-storage-service/main.js +31 -54
- package/dist/src/lib/services/aws/step-function/main.d.ts +31 -32
- package/dist/src/lib/services/aws/step-function/main.js +33 -57
- package/dist/src/lib/services/aws/systems-manager/main.d.ts +4 -4
- package/dist/src/lib/services/aws/systems-manager/main.js +10 -33
- package/dist/src/lib/services/aws/virtual-private-cloud/main.d.ts +5 -6
- package/dist/src/lib/services/aws/virtual-private-cloud/main.js +14 -37
- package/dist/src/lib/services/aws/web-application-firewall/main.d.ts +3 -3
- package/dist/src/lib/services/aws/web-application-firewall/main.js +8 -31
- package/dist/src/lib/utils/aws/index.d.ts +6 -3
- package/dist/src/lib/utils/aws/index.js +9 -26
- package/package.json +15 -15
- package/src/lib/common/construct.ts +97 -67
- package/src/lib/common/stack.ts +12 -12
- package/src/lib/common/types.ts +2 -2
- package/src/lib/construct/api-to-eventbridge-target/api.ts +31 -22
- package/src/lib/construct/api-to-eventbridge-target/event.ts +9 -9
- package/src/lib/construct/api-to-eventbridge-target/main.ts +56 -41
- package/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.ts +9 -9
- package/src/lib/construct/api-to-eventbridge-target-with-sns/main.ts +62 -47
- package/src/lib/construct/api-to-lambda-target/api.ts +33 -23
- package/src/lib/construct/api-to-lambda-target/main.ts +24 -18
- package/src/lib/construct/application-configuration/main.ts +31 -24
- package/src/lib/construct/graphql-api-lambda/main.ts +22 -22
- package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +13 -13
- package/src/lib/construct/lambda-with-iam-access/main.ts +25 -25
- package/src/lib/construct/lambda-with-iam-access/types.ts +4 -4
- package/src/lib/construct/rest-api-lambda/main.ts +21 -21
- package/src/lib/construct/rest-api-lambda-with-cache/main.ts +14 -14
- package/src/lib/construct/site-with-ecs-backend/main.ts +79 -60
- package/src/lib/construct/static-asset-deployment/main.ts +6 -6
- package/src/lib/construct/static-site/main.ts +23 -17
- package/src/lib/services/aws/api-gateway/main.ts +42 -36
- package/src/lib/services/aws/api-gateway/types.ts +2 -2
- package/src/lib/services/aws/appconfig/main.ts +19 -19
- package/src/lib/services/aws/certificate-manager/main.ts +14 -14
- package/src/lib/services/aws/certificate-manager/types.ts +2 -2
- package/src/lib/services/aws/cloudfront/main.ts +88 -74
- package/src/lib/services/aws/cloudfront/types.ts +6 -3
- package/src/lib/services/aws/cloudtrail/main.ts +11 -11
- package/src/lib/services/aws/codebuild/main.ts +7 -7
- package/src/lib/services/aws/dynamodb/main.ts +8 -8
- package/src/lib/services/aws/elastic-container-registry/main.ts +4 -4
- package/src/lib/services/aws/elastic-container-service/main.ts +48 -37
- package/src/lib/services/aws/elastic-container-service/types.ts +4 -4
- package/src/lib/services/aws/elastic-file-system/main.ts +16 -16
- package/src/lib/services/aws/elastic-kubernetes-service/main.ts +11 -11
- package/src/lib/services/aws/elasticache/main.ts +10 -10
- package/src/lib/services/aws/eventbridge/main.ts +37 -37
- package/src/lib/services/aws/eventbridge/target.ts +14 -14
- package/src/lib/services/aws/evidently/main.ts +18 -18
- package/src/lib/services/aws/identity-access-management/main.ts +142 -134
- package/src/lib/services/aws/key-management-service/main.ts +5 -5
- package/src/lib/services/aws/lambda/main.ts +65 -59
- package/src/lib/services/aws/route53/main.ts +31 -31
- package/src/lib/services/aws/secrets-manager/main.ts +11 -15
- package/src/lib/services/aws/simple-notification-service/main.ts +13 -13
- package/src/lib/services/aws/simple-queue-service/main.ts +18 -18
- package/src/lib/services/aws/simple-storage-service/main.ts +40 -40
- package/src/lib/services/aws/step-function/main.ts +77 -65
- package/src/lib/services/aws/systems-manager/main.ts +17 -12
- package/src/lib/services/aws/virtual-private-cloud/main.ts +16 -16
- package/src/lib/services/aws/web-application-firewall/main.ts +8 -8
- package/src/lib/utils/aws/index.ts +8 -5
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import * as utils from '../../../utils'
|
|
5
|
-
import { AcmProps } from './types'
|
|
1
|
+
import { Stack } from 'aws-cdk-lib'
|
|
2
|
+
import { Certificate, CertificateValidation, ICertificate } from 'aws-cdk-lib/aws-certificatemanager'
|
|
3
|
+
import { IHostedZone } from 'aws-cdk-lib/aws-route53'
|
|
6
4
|
import { CommonConstruct } from '../../../common'
|
|
5
|
+
import { createCfnOutput } from '../../../utils'
|
|
6
|
+
import { AcmProps } from './types'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @classdesc Provides operations on AWS Certificates.
|
|
@@ -13,7 +13,7 @@ import { CommonConstruct } from '../../../common'
|
|
|
13
13
|
* import { CommonConstruct } from '@gradientedge/cdk-utils'
|
|
14
14
|
*
|
|
15
15
|
* class CustomConstruct extends CommonConstruct {
|
|
16
|
-
* constructor(parent:
|
|
16
|
+
* constructor(parent: Construct, id: string, props: common.CommonStackProps) {
|
|
17
17
|
* super(parent, id, props)
|
|
18
18
|
* this.props = props
|
|
19
19
|
* this.acmManager.createCertificate('MyCertificate', this)
|
|
@@ -44,8 +44,8 @@ export class AcmManager {
|
|
|
44
44
|
id: string,
|
|
45
45
|
scope: CommonConstruct,
|
|
46
46
|
props: AcmProps,
|
|
47
|
-
hostedZone?:
|
|
48
|
-
):
|
|
47
|
+
hostedZone?: IHostedZone
|
|
48
|
+
): ICertificate {
|
|
49
49
|
if (!props) throw `Certificate props undefined for ${id}`
|
|
50
50
|
|
|
51
51
|
let certificate
|
|
@@ -53,20 +53,20 @@ export class AcmManager {
|
|
|
53
53
|
if (props.useExistingCertificate) {
|
|
54
54
|
let certificateArn = props.certificateArn
|
|
55
55
|
if (!certificateArn) {
|
|
56
|
-
const certificateAccount = props.certificateAccount ? props.certificateAccount :
|
|
57
|
-
const certificateRegion = props.certificateRegion ? props.certificateRegion :
|
|
56
|
+
const certificateAccount = props.certificateAccount ? props.certificateAccount : Stack.of(scope).account
|
|
57
|
+
const certificateRegion = props.certificateRegion ? props.certificateRegion : Stack.of(scope).region
|
|
58
58
|
certificateArn = `arn:aws:acm:${certificateRegion}:${certificateAccount}:certificate/${props.certificateId}`
|
|
59
59
|
}
|
|
60
|
-
certificate =
|
|
60
|
+
certificate = Certificate.fromCertificateArn(scope, `${id}`, certificateArn)
|
|
61
61
|
} else {
|
|
62
|
-
certificate = new
|
|
62
|
+
certificate = new Certificate(scope, `${id}`, {
|
|
63
63
|
domainName: props.domainName,
|
|
64
64
|
subjectAlternativeNames: props.subjectAlternativeNames,
|
|
65
|
-
validation:
|
|
65
|
+
validation: CertificateValidation.fromDns(hostedZone),
|
|
66
66
|
})
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
createCfnOutput(`${id}-certificateArn`, scope, certificate.certificateArn)
|
|
70
70
|
|
|
71
71
|
return certificate
|
|
72
72
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CertificateProps } from 'aws-cdk-lib/aws-certificatemanager'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*/
|
|
5
|
-
export interface AcmProps extends
|
|
5
|
+
export interface AcmProps extends CertificateProps {
|
|
6
6
|
certificateAccount?: string
|
|
7
7
|
certificateArn?: string
|
|
8
8
|
certificateId?: string
|
|
@@ -1,27 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { Duration, Tags } from 'aws-cdk-lib'
|
|
2
|
+
import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager'
|
|
3
|
+
import * as cf from 'aws-cdk-lib/aws-cloudfront'
|
|
4
|
+
import {
|
|
5
|
+
CloudFrontWebDistribution,
|
|
6
|
+
Distribution,
|
|
7
|
+
Function,
|
|
8
|
+
FunctionAssociation,
|
|
9
|
+
FunctionCode,
|
|
10
|
+
HttpVersion,
|
|
11
|
+
IResponseHeadersPolicy,
|
|
12
|
+
OriginAccessIdentity,
|
|
13
|
+
PriceClass,
|
|
14
|
+
SSLMethod,
|
|
15
|
+
SecurityPolicyProtocol,
|
|
16
|
+
ViewerCertificate,
|
|
17
|
+
} from 'aws-cdk-lib/aws-cloudfront'
|
|
18
|
+
import { HttpOrigin, S3Origin } from 'aws-cdk-lib/aws-cloudfront-origins'
|
|
19
|
+
import { ISecurityGroup, IVpc } from 'aws-cdk-lib/aws-ec2'
|
|
20
|
+
import { IAccessPoint } from 'aws-cdk-lib/aws-efs'
|
|
21
|
+
import { Role } from 'aws-cdk-lib/aws-iam'
|
|
22
|
+
import { AssetCode, FileSystem, ILayerVersion } from 'aws-cdk-lib/aws-lambda'
|
|
23
|
+
import { IBucket } from 'aws-cdk-lib/aws-s3'
|
|
24
|
+
import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId } from 'aws-cdk-lib/custom-resources'
|
|
11
25
|
import { CommonConstruct, CommonStack } from '../../../common'
|
|
12
|
-
import
|
|
13
|
-
import { CloudfrontFunctionProps, CloudFrontProps, DistributionProps } from './types'
|
|
26
|
+
import { createCfnOutput } from '../../../utils'
|
|
14
27
|
import { LambdaEdgeProps } from '../lambda'
|
|
28
|
+
import { CloudFrontProps, CloudfrontFunctionProps, DistributionProps } from './types'
|
|
15
29
|
|
|
16
30
|
/**
|
|
17
|
-
* @classdesc Provides operations on AWS
|
|
31
|
+
* @classdesc Provides operations on AWS
|
|
18
32
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
19
33
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
20
34
|
* @example
|
|
21
35
|
* import { CommonConstruct } from '@gradientedge/cdk-utils'
|
|
22
36
|
*
|
|
23
37
|
* class CustomConstruct extends CommonConstruct {
|
|
24
|
-
* constructor(parent:
|
|
38
|
+
* constructor(parent: Construct, id: string, props: common.CommonStackProps) {
|
|
25
39
|
* super(parent, id, props)
|
|
26
40
|
* this.props = props
|
|
27
41
|
* this.cloudFrontManager.createCloudFrontDistribution(
|
|
@@ -37,8 +51,8 @@ import { LambdaEdgeProps } from '../lambda'
|
|
|
37
51
|
* @see [CDK CloudFront Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront-readme.html}
|
|
38
52
|
*/
|
|
39
53
|
export class CloudFrontManager {
|
|
40
|
-
public createOriginAccessIdentity(id: string, scope: CommonConstruct, accessBucket?:
|
|
41
|
-
const oai = new
|
|
54
|
+
public createOriginAccessIdentity(id: string, scope: CommonConstruct, accessBucket?: IBucket) {
|
|
55
|
+
const oai = new OriginAccessIdentity(scope, `${id}`, {
|
|
42
56
|
comment: `${id} - ${scope.props.stage} stage`,
|
|
43
57
|
})
|
|
44
58
|
if (accessBucket) accessBucket.grantRead(oai)
|
|
@@ -61,24 +75,24 @@ export class CloudFrontManager {
|
|
|
61
75
|
id: string,
|
|
62
76
|
scope: CommonConstruct,
|
|
63
77
|
props: CloudFrontProps,
|
|
64
|
-
siteBucket?:
|
|
65
|
-
logBucket?:
|
|
66
|
-
oai?:
|
|
67
|
-
certificate?:
|
|
78
|
+
siteBucket?: IBucket,
|
|
79
|
+
logBucket?: IBucket,
|
|
80
|
+
oai?: OriginAccessIdentity,
|
|
81
|
+
certificate?: ICertificate,
|
|
68
82
|
aliases?: string[]
|
|
69
83
|
) {
|
|
70
84
|
if (!siteBucket) throw `SiteBucket not defined for ${id}`
|
|
71
85
|
if (!certificate) throw `Certificate not defined for ${id}`
|
|
72
86
|
if (!props) throw `CloudFront props undefined for ${id}`
|
|
73
87
|
|
|
74
|
-
const distribution = new
|
|
88
|
+
const distribution = new CloudFrontWebDistribution(scope, `${id}`, {
|
|
75
89
|
comment: `${id} - ${scope.props.stage} stage`,
|
|
76
90
|
defaultRootObject: props.defaultRootObject,
|
|
77
91
|
enableIpV6: props.enableIpV6,
|
|
78
92
|
enabled: props.enabled ?? true,
|
|
79
93
|
errorConfigurations: props.errorConfigurations,
|
|
80
94
|
geoRestriction: props.geoRestriction,
|
|
81
|
-
httpVersion: props.httpVersion ??
|
|
95
|
+
httpVersion: props.httpVersion ?? HttpVersion.HTTP2,
|
|
82
96
|
loggingConfig: {
|
|
83
97
|
bucket: logBucket,
|
|
84
98
|
prefix: 'cloudfront/',
|
|
@@ -92,23 +106,23 @@ export class CloudFrontManager {
|
|
|
92
106
|
},
|
|
93
107
|
},
|
|
94
108
|
],
|
|
95
|
-
priceClass: props.priceClass ??
|
|
96
|
-
viewerCertificate:
|
|
109
|
+
priceClass: props.priceClass ?? PriceClass.PRICE_CLASS_ALL,
|
|
110
|
+
viewerCertificate: ViewerCertificate.fromAcmCertificate(certificate, {
|
|
97
111
|
aliases: aliases,
|
|
98
|
-
securityPolicy:
|
|
99
|
-
sslMethod:
|
|
112
|
+
securityPolicy: SecurityPolicyProtocol.TLS_V1_1_2016,
|
|
113
|
+
sslMethod: SSLMethod.SNI,
|
|
100
114
|
}),
|
|
101
115
|
webACLId: props.webACLId,
|
|
102
116
|
})
|
|
103
117
|
|
|
104
118
|
if (props.tags && props.tags.length > 0) {
|
|
105
119
|
props.tags.forEach(tag => {
|
|
106
|
-
|
|
120
|
+
Tags.of(distribution).add(tag.key, tag.value)
|
|
107
121
|
})
|
|
108
122
|
}
|
|
109
123
|
|
|
110
|
-
|
|
111
|
-
|
|
124
|
+
createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
|
|
125
|
+
createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
|
|
112
126
|
|
|
113
127
|
return distribution
|
|
114
128
|
}
|
|
@@ -130,15 +144,15 @@ export class CloudFrontManager {
|
|
|
130
144
|
id: string,
|
|
131
145
|
scope: CommonConstruct,
|
|
132
146
|
props: DistributionProps,
|
|
133
|
-
origin:
|
|
134
|
-
siteBucket:
|
|
135
|
-
logBucket?:
|
|
136
|
-
oai?:
|
|
137
|
-
certificate?:
|
|
147
|
+
origin: S3Origin,
|
|
148
|
+
siteBucket: IBucket,
|
|
149
|
+
logBucket?: IBucket,
|
|
150
|
+
oai?: OriginAccessIdentity,
|
|
151
|
+
certificate?: ICertificate,
|
|
138
152
|
aliases?: string[],
|
|
139
|
-
defaultFunctionAssociations?:
|
|
153
|
+
defaultFunctionAssociations?: FunctionAssociation[]
|
|
140
154
|
) {
|
|
141
|
-
const distribution = new
|
|
155
|
+
const distribution = new Distribution(scope, `${id}`, {
|
|
142
156
|
additionalBehaviors: props.additionalBehaviors,
|
|
143
157
|
certificate: certificate,
|
|
144
158
|
comment: `${id} - ${scope.props.stage} stage`,
|
|
@@ -157,23 +171,23 @@ export class CloudFrontManager {
|
|
|
157
171
|
enabled: props.enabled ?? true,
|
|
158
172
|
errorResponses: props.errorResponses,
|
|
159
173
|
geoRestriction: props.geoRestriction,
|
|
160
|
-
httpVersion: props.httpVersion ??
|
|
174
|
+
httpVersion: props.httpVersion ?? HttpVersion.HTTP2,
|
|
161
175
|
logBucket: logBucket,
|
|
162
176
|
logFilePrefix: props.logFilePrefix ?? `edge/`,
|
|
163
177
|
logIncludesCookies: props.logIncludesCookies ?? true,
|
|
164
|
-
minimumProtocolVersion: props.minimumProtocolVersion ??
|
|
165
|
-
priceClass: props.priceClass ??
|
|
178
|
+
minimumProtocolVersion: props.minimumProtocolVersion ?? SecurityPolicyProtocol.TLS_V1_2_2021,
|
|
179
|
+
priceClass: props.priceClass ?? PriceClass.PRICE_CLASS_ALL,
|
|
166
180
|
webAclId: props.webAclId,
|
|
167
181
|
})
|
|
168
182
|
|
|
169
183
|
if (props.tags && props.tags.length > 0) {
|
|
170
184
|
props.tags.forEach(tag => {
|
|
171
|
-
|
|
185
|
+
Tags.of(distribution).add(tag.key, tag.value)
|
|
172
186
|
})
|
|
173
187
|
}
|
|
174
188
|
|
|
175
|
-
|
|
176
|
-
|
|
189
|
+
createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
|
|
190
|
+
createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
|
|
177
191
|
|
|
178
192
|
return distribution
|
|
179
193
|
}
|
|
@@ -194,14 +208,14 @@ export class CloudFrontManager {
|
|
|
194
208
|
id: string,
|
|
195
209
|
scope: CommonConstruct,
|
|
196
210
|
props: DistributionProps,
|
|
197
|
-
origin:
|
|
211
|
+
origin: HttpOrigin,
|
|
198
212
|
domainNames: string[],
|
|
199
|
-
logBucket?:
|
|
200
|
-
certificate?:
|
|
201
|
-
defaultFunctionAssociations?:
|
|
202
|
-
responseHeadersPolicy?:
|
|
213
|
+
logBucket?: IBucket,
|
|
214
|
+
certificate?: ICertificate,
|
|
215
|
+
defaultFunctionAssociations?: FunctionAssociation[],
|
|
216
|
+
responseHeadersPolicy?: IResponseHeadersPolicy
|
|
203
217
|
) {
|
|
204
|
-
const distribution = new
|
|
218
|
+
const distribution = new Distribution(scope, `${id}`, {
|
|
205
219
|
additionalBehaviors: props.additionalBehaviors,
|
|
206
220
|
certificate: certificate,
|
|
207
221
|
comment: `${id} - ${scope.props.stage} stage`,
|
|
@@ -221,23 +235,23 @@ export class CloudFrontManager {
|
|
|
221
235
|
enabled: props.enabled ?? true,
|
|
222
236
|
errorResponses: props.errorResponses,
|
|
223
237
|
geoRestriction: props.geoRestriction,
|
|
224
|
-
httpVersion: props.httpVersion ??
|
|
238
|
+
httpVersion: props.httpVersion ?? HttpVersion.HTTP2,
|
|
225
239
|
logBucket: logBucket,
|
|
226
240
|
logFilePrefix: props.logFilePrefix ?? `edge/`,
|
|
227
241
|
logIncludesCookies: props.logIncludesCookies ?? true,
|
|
228
|
-
minimumProtocolVersion: props.minimumProtocolVersion ??
|
|
229
|
-
priceClass: props.priceClass ??
|
|
242
|
+
minimumProtocolVersion: props.minimumProtocolVersion ?? SecurityPolicyProtocol.TLS_V1_2_2021,
|
|
243
|
+
priceClass: props.priceClass ?? PriceClass.PRICE_CLASS_ALL,
|
|
230
244
|
webAclId: props.webAclId,
|
|
231
245
|
})
|
|
232
246
|
|
|
233
247
|
if (props.tags && props.tags.length > 0) {
|
|
234
248
|
props.tags.forEach(tag => {
|
|
235
|
-
|
|
249
|
+
Tags.of(distribution).add(tag.key, tag.value)
|
|
236
250
|
})
|
|
237
251
|
}
|
|
238
252
|
|
|
239
|
-
|
|
240
|
-
|
|
253
|
+
createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
|
|
254
|
+
createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
|
|
241
255
|
|
|
242
256
|
return distribution
|
|
243
257
|
}
|
|
@@ -260,24 +274,24 @@ export class CloudFrontManager {
|
|
|
260
274
|
id: string,
|
|
261
275
|
scope: CommonConstruct,
|
|
262
276
|
props: LambdaEdgeProps,
|
|
263
|
-
layers:
|
|
264
|
-
code:
|
|
265
|
-
role:
|
|
277
|
+
layers: ILayerVersion[],
|
|
278
|
+
code: AssetCode,
|
|
279
|
+
role: Role,
|
|
266
280
|
environment?: any,
|
|
267
|
-
vpc?:
|
|
268
|
-
securityGroups?:
|
|
269
|
-
accessPoint?:
|
|
281
|
+
vpc?: IVpc,
|
|
282
|
+
securityGroups?: ISecurityGroup[],
|
|
283
|
+
accessPoint?: IAccessPoint,
|
|
270
284
|
mountPath?: string
|
|
271
285
|
) {
|
|
272
286
|
if (!props) throw `EdgeFunction props undefined for ${id}`
|
|
273
287
|
|
|
274
|
-
const edgeFunction = new
|
|
288
|
+
const edgeFunction = new cf.experimental.EdgeFunction(scope, `${id}`, {
|
|
275
289
|
code: code,
|
|
276
290
|
description: props.description,
|
|
277
291
|
environment: {
|
|
278
292
|
...environment,
|
|
279
293
|
},
|
|
280
|
-
filesystem: accessPoint ?
|
|
294
|
+
filesystem: accessPoint ? FileSystem.fromEfsAccessPoint(accessPoint, mountPath ?? '/mnt/msg') : undefined,
|
|
281
295
|
functionName: `${props.functionName}-${scope.props.stage}`,
|
|
282
296
|
handler: props.handler ?? 'index.handler',
|
|
283
297
|
layers: layers,
|
|
@@ -288,19 +302,19 @@ export class CloudFrontManager {
|
|
|
288
302
|
runtime: props.runtime ?? scope.props.nodejsRuntime ?? CommonStack.NODEJS_RUNTIME,
|
|
289
303
|
securityGroups: securityGroups,
|
|
290
304
|
stackId: `${id}-stack-id-${scope.props.stage}`,
|
|
291
|
-
timeout: props.timeoutInSecs ?
|
|
305
|
+
timeout: props.timeoutInSecs ? Duration.seconds(props.timeoutInSecs) : Duration.minutes(1),
|
|
292
306
|
vpc: vpc,
|
|
293
307
|
})
|
|
294
308
|
|
|
295
309
|
if (props.tags && props.tags.length > 0) {
|
|
296
310
|
props.tags.forEach(tag => {
|
|
297
|
-
|
|
311
|
+
Tags.of(edgeFunction).add(tag.key, tag.value)
|
|
298
312
|
})
|
|
299
313
|
}
|
|
300
314
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
315
|
+
createCfnOutput(`${id}-edgeArn`, scope, edgeFunction.edgeArn)
|
|
316
|
+
createCfnOutput(`${id}-edgeFunctionArn`, scope, edgeFunction.functionArn)
|
|
317
|
+
createCfnOutput(`${id}-edgeFunctionName`, scope, edgeFunction.functionName)
|
|
304
318
|
|
|
305
319
|
return edgeFunction
|
|
306
320
|
}
|
|
@@ -320,7 +334,7 @@ export class CloudFrontManager {
|
|
|
320
334
|
distributionId: string,
|
|
321
335
|
paths?: string
|
|
322
336
|
) {
|
|
323
|
-
new
|
|
337
|
+
new AwsCustomResource(scope, `${id}-trigger-codebuild-${new Date().getTime()}`, {
|
|
324
338
|
onCreate: {
|
|
325
339
|
action: 'startBuild',
|
|
326
340
|
parameters: {
|
|
@@ -332,10 +346,10 @@ export class CloudFrontManager {
|
|
|
332
346
|
paths
|
|
333
347
|
).projectName,
|
|
334
348
|
},
|
|
335
|
-
physicalResourceId:
|
|
349
|
+
physicalResourceId: PhysicalResourceId.fromResponse('build.id'),
|
|
336
350
|
service: 'CodeBuild',
|
|
337
351
|
},
|
|
338
|
-
policy:
|
|
352
|
+
policy: AwsCustomResourcePolicy.fromSdkCalls({ resources: AwsCustomResourcePolicy.ANY_RESOURCE }),
|
|
339
353
|
})
|
|
340
354
|
}
|
|
341
355
|
|
|
@@ -346,16 +360,16 @@ export class CloudFrontManager {
|
|
|
346
360
|
* @param props
|
|
347
361
|
*/
|
|
348
362
|
public createCloudfrontFunction(id: string, scope: CommonConstruct, props: CloudfrontFunctionProps) {
|
|
349
|
-
const cloudfrontFunction = new
|
|
350
|
-
code:
|
|
363
|
+
const cloudfrontFunction = new Function(scope, `${id}`, {
|
|
364
|
+
code: FunctionCode.fromFile({
|
|
351
365
|
filePath: props.functionFilePath,
|
|
352
366
|
}),
|
|
353
367
|
comment: props.comment,
|
|
354
368
|
functionName: `${props.functionName}-${scope.props.stage}`,
|
|
355
369
|
})
|
|
356
370
|
|
|
357
|
-
|
|
358
|
-
|
|
371
|
+
createCfnOutput(`${id}-functionArn`, scope, cloudfrontFunction.functionArn)
|
|
372
|
+
createCfnOutput(`${id}-functionName`, scope, cloudfrontFunction.functionName)
|
|
359
373
|
|
|
360
374
|
return cloudfrontFunction
|
|
361
375
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DistributionProps as CfDistributionProps,
|
|
3
|
+
CloudFrontWebDistributionProps,
|
|
4
|
+
FunctionProps,
|
|
5
|
+
} from 'aws-cdk-lib/aws-cloudfront'
|
|
1
6
|
import { TagProps } from '../../../types'
|
|
2
|
-
import * as cf from 'aws-cdk-lib/aws-cloudfront'
|
|
3
|
-
import { CloudFrontWebDistributionProps, FunctionProps } from 'aws-cdk-lib/aws-cloudfront'
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
*/
|
|
@@ -10,7 +13,7 @@ export interface CloudFrontProps extends CloudFrontWebDistributionProps {
|
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
*/
|
|
13
|
-
export interface DistributionProps extends
|
|
16
|
+
export interface DistributionProps extends CfDistributionProps {
|
|
14
17
|
tags?: TagProps[]
|
|
15
18
|
}
|
|
16
19
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import * as utils from '../../../utils'
|
|
1
|
+
import { CfnTrail } from 'aws-cdk-lib/aws-cloudtrail'
|
|
2
|
+
import { CfnLogGroup } from 'aws-cdk-lib/aws-logs'
|
|
3
|
+
import { CfnBucketPolicy, IBucket } from 'aws-cdk-lib/aws-s3'
|
|
5
4
|
import { CommonConstruct } from '../../../common'
|
|
5
|
+
import { createCfnOutput } from '../../../utils'
|
|
6
6
|
import { CloudTrailProps } from './types'
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -43,16 +43,16 @@ export class CloudTrailManager {
|
|
|
43
43
|
id: string,
|
|
44
44
|
scope: CommonConstruct,
|
|
45
45
|
props: CloudTrailProps,
|
|
46
|
-
logGroup:
|
|
47
|
-
dataBucket:
|
|
48
|
-
logBucket:
|
|
49
|
-
logBucketPolicy:
|
|
46
|
+
logGroup: CfnLogGroup,
|
|
47
|
+
dataBucket: IBucket,
|
|
48
|
+
logBucket: IBucket,
|
|
49
|
+
logBucketPolicy: CfnBucketPolicy
|
|
50
50
|
) {
|
|
51
51
|
if (!props) throw `CloudTrail props undefined for ${id}`
|
|
52
52
|
|
|
53
53
|
const role = scope.iamManager.createRoleForCloudTrail(`${id}Role`, scope, logGroup)
|
|
54
54
|
|
|
55
|
-
const cloudTrail = new
|
|
55
|
+
const cloudTrail = new CfnTrail(scope, `${id}`, {
|
|
56
56
|
cloudWatchLogsLogGroupArn: logGroup.attrArn,
|
|
57
57
|
cloudWatchLogsRoleArn: role.attrArn,
|
|
58
58
|
enableLogFileValidation: props.enableLogFileValidation,
|
|
@@ -81,8 +81,8 @@ export class CloudTrailManager {
|
|
|
81
81
|
cloudTrail.addDependency(logGroup)
|
|
82
82
|
cloudTrail.addDependency(role)
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
createCfnOutput(`${id}-trailName`, scope, cloudTrail.trailName)
|
|
85
|
+
createCfnOutput(`${id}-trailArn`, scope, cloudTrail.attrArn)
|
|
86
86
|
|
|
87
87
|
return { cloudTrail, cloudTrailRole: role }
|
|
88
88
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Duration } from 'aws-cdk-lib'
|
|
2
|
+
import { BuildSpec, ComputeType, LinuxBuildImage, Project } from 'aws-cdk-lib/aws-codebuild'
|
|
3
3
|
import { CommonConstruct } from '../../../common'
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -45,8 +45,8 @@ export class CodeBuildManager {
|
|
|
45
45
|
paths?: string
|
|
46
46
|
) {
|
|
47
47
|
const invalidationPaths = paths ?? '/*'
|
|
48
|
-
return new
|
|
49
|
-
buildSpec:
|
|
48
|
+
return new Project(scope, `${id}-install-deps-project`, {
|
|
49
|
+
buildSpec: BuildSpec.fromObject({
|
|
50
50
|
phases: {
|
|
51
51
|
build: {
|
|
52
52
|
commands: [
|
|
@@ -57,10 +57,10 @@ export class CodeBuildManager {
|
|
|
57
57
|
version: '0.1',
|
|
58
58
|
}),
|
|
59
59
|
environment: {
|
|
60
|
-
buildImage:
|
|
60
|
+
buildImage: LinuxBuildImage.fromDockerRegistry(
|
|
61
61
|
this.createImageForCloudfrontInvalidation(id, scope, dockerFilepath).imageUri
|
|
62
62
|
),
|
|
63
|
-
computeType:
|
|
63
|
+
computeType: ComputeType.SMALL,
|
|
64
64
|
privileged: true,
|
|
65
65
|
},
|
|
66
66
|
logging: {
|
|
@@ -72,7 +72,7 @@ export class CodeBuildManager {
|
|
|
72
72
|
},
|
|
73
73
|
},
|
|
74
74
|
role: scope.iamManager.roleForCloudfrontInvalidation(id, scope),
|
|
75
|
-
timeout:
|
|
75
|
+
timeout: Duration.minutes(5),
|
|
76
76
|
})
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import * as cdk from 'aws-cdk-lib'
|
|
1
|
+
import { Tags } from 'aws-cdk-lib'
|
|
2
|
+
import { Table } from 'aws-cdk-lib/aws-dynamodb'
|
|
4
3
|
import { CommonConstruct } from '../../../common'
|
|
4
|
+
import { createCfnOutput } from '../../../utils'
|
|
5
5
|
import { TableProps } from './types'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @classdesc Provides operations on AWS DynamoDB
|
|
8
|
+
* @classdesc Provides operations on AWS DynamoDB
|
|
9
9
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
10
10
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
11
11
|
* @example
|
|
@@ -30,7 +30,7 @@ export class DynamodbManager {
|
|
|
30
30
|
public createTable(id: string, scope: CommonConstruct, props: TableProps) {
|
|
31
31
|
if (!props) throw `Table props undefined for ${id}`
|
|
32
32
|
|
|
33
|
-
const table = new
|
|
33
|
+
const table = new Table(scope, `${id}`, {
|
|
34
34
|
billingMode: props.billingMode,
|
|
35
35
|
contributorInsightsEnabled: props.contributorInsightsEnabled,
|
|
36
36
|
encryption: props.encryption,
|
|
@@ -52,12 +52,12 @@ export class DynamodbManager {
|
|
|
52
52
|
|
|
53
53
|
if (props.tags && props.tags.length > 0) {
|
|
54
54
|
props.tags.forEach(tag => {
|
|
55
|
-
|
|
55
|
+
Tags.of(table).add(tag.key, tag.value)
|
|
56
56
|
})
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
createCfnOutput(`${id}-tableName`, scope, table.tableName)
|
|
60
|
+
createCfnOutput(`${id}-tableArn`, scope, table.tableArn)
|
|
61
61
|
|
|
62
62
|
return table
|
|
63
63
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as utils from '../../../utils'
|
|
1
|
+
import { DockerImageAsset } from 'aws-cdk-lib/aws-ecr-assets'
|
|
3
2
|
import { CommonConstruct } from '../../../common'
|
|
3
|
+
import { createCfnOutput } from '../../../utils'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @classdesc Provides operations on AWS Elastic Container Registry.
|
|
@@ -26,11 +26,11 @@ export class EcrManager {
|
|
|
26
26
|
* @param dockerfilePath
|
|
27
27
|
*/
|
|
28
28
|
public createDockerImage(id: string, scope: CommonConstruct, dockerfilePath: string) {
|
|
29
|
-
const asset = new
|
|
29
|
+
const asset = new DockerImageAsset(scope, `${id}`, {
|
|
30
30
|
directory: dockerfilePath,
|
|
31
31
|
})
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
createCfnOutput(`${id}-dockerImageArn`, scope, asset.imageUri)
|
|
34
34
|
|
|
35
35
|
return asset
|
|
36
36
|
}
|