@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.
Files changed (148) hide show
  1. package/app/api-destined-function/package.json +1 -1
  2. package/dist/src/lib/common/construct.d.ts +32 -32
  3. package/dist/src/lib/common/construct.js +36 -59
  4. package/dist/src/lib/common/stack.d.ts +8 -7
  5. package/dist/src/lib/common/stack.js +17 -37
  6. package/dist/src/lib/common/types.d.ts +2 -2
  7. package/dist/src/lib/construct/api-to-eventbridge-target/api.d.ts +22 -22
  8. package/dist/src/lib/construct/api-to-eventbridge-target/event.d.ts +9 -9
  9. package/dist/src/lib/construct/api-to-eventbridge-target/main.d.ts +3 -3
  10. package/dist/src/lib/construct/api-to-eventbridge-target/main.js +37 -60
  11. package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.d.ts +9 -9
  12. package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.d.ts +3 -3
  13. package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.js +40 -63
  14. package/dist/src/lib/construct/api-to-lambda-target/api.d.ts +23 -23
  15. package/dist/src/lib/construct/api-to-lambda-target/main.d.ts +2 -2
  16. package/dist/src/lib/construct/api-to-lambda-target/main.js +15 -38
  17. package/dist/src/lib/construct/application-configuration/main.d.ts +7 -7
  18. package/dist/src/lib/construct/application-configuration/main.js +17 -41
  19. package/dist/src/lib/construct/graphql-api-lambda/main.d.ts +17 -17
  20. package/dist/src/lib/construct/graphql-api-lambda/main.js +6 -29
  21. package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts +5 -5
  22. package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +7 -7
  23. package/dist/src/lib/construct/lambda-with-iam-access/main.d.ts +16 -16
  24. package/dist/src/lib/construct/lambda-with-iam-access/main.js +8 -31
  25. package/dist/src/lib/construct/lambda-with-iam-access/types.d.ts +4 -4
  26. package/dist/src/lib/construct/rest-api-lambda/main.d.ts +16 -16
  27. package/dist/src/lib/construct/rest-api-lambda/main.js +5 -28
  28. package/dist/src/lib/construct/rest-api-lambda-with-cache/main.d.ts +5 -5
  29. package/dist/src/lib/construct/rest-api-lambda-with-cache/main.js +9 -32
  30. package/dist/src/lib/construct/site-with-ecs-backend/main.d.ts +38 -39
  31. package/dist/src/lib/construct/site-with-ecs-backend/main.js +33 -54
  32. package/dist/src/lib/construct/static-asset-deployment/main.d.ts +4 -4
  33. package/dist/src/lib/construct/static-asset-deployment/main.js +3 -26
  34. package/dist/src/lib/construct/static-site/main.d.ts +15 -15
  35. package/dist/src/lib/construct/static-site/main.js +4 -27
  36. package/dist/src/lib/services/aws/api-gateway/main.d.ts +10 -10
  37. package/dist/src/lib/services/aws/api-gateway/main.js +21 -44
  38. package/dist/src/lib/services/aws/api-gateway/types.d.ts +2 -2
  39. package/dist/src/lib/services/aws/appconfig/main.d.ts +7 -7
  40. package/dist/src/lib/services/aws/appconfig/main.js +14 -37
  41. package/dist/src/lib/services/aws/certificate-manager/main.d.ts +5 -5
  42. package/dist/src/lib/services/aws/certificate-manager/main.js +10 -33
  43. package/dist/src/lib/services/aws/certificate-manager/types.d.ts +2 -2
  44. package/dist/src/lib/services/aws/cloudfront/main.d.ts +18 -18
  45. package/dist/src/lib/services/aws/cloudfront/main.js +46 -45
  46. package/dist/src/lib/services/aws/cloudfront/types.d.ts +2 -3
  47. package/dist/src/lib/services/aws/cloudtrail/main.d.ts +5 -5
  48. package/dist/src/lib/services/aws/cloudtrail/main.js +5 -28
  49. package/dist/src/lib/services/aws/codebuild/main.d.ts +3 -3
  50. package/dist/src/lib/services/aws/codebuild/main.js +7 -30
  51. package/dist/src/lib/services/aws/dynamodb/main.d.ts +3 -3
  52. package/dist/src/lib/services/aws/dynamodb/main.js +8 -31
  53. package/dist/src/lib/services/aws/elastic-container-registry/main.d.ts +2 -2
  54. package/dist/src/lib/services/aws/elastic-container-registry/main.js +4 -27
  55. package/dist/src/lib/services/aws/elastic-container-service/main.d.ts +10 -10
  56. package/dist/src/lib/services/aws/elastic-container-service/main.js +27 -50
  57. package/dist/src/lib/services/aws/elastic-container-service/types.d.ts +4 -4
  58. package/dist/src/lib/services/aws/elastic-file-system/main.d.ts +3 -3
  59. package/dist/src/lib/services/aws/elastic-file-system/main.js +12 -35
  60. package/dist/src/lib/services/aws/elastic-kubernetes-service/main.d.ts +4 -4
  61. package/dist/src/lib/services/aws/elastic-kubernetes-service/main.js +8 -31
  62. package/dist/src/lib/services/aws/elasticache/main.d.ts +4 -4
  63. package/dist/src/lib/services/aws/elasticache/main.js +10 -33
  64. package/dist/src/lib/services/aws/eventbridge/main.d.ts +13 -13
  65. package/dist/src/lib/services/aws/eventbridge/main.js +26 -49
  66. package/dist/src/lib/services/aws/eventbridge/target.d.ts +10 -10
  67. package/dist/src/lib/services/aws/eventbridge/target.js +6 -29
  68. package/dist/src/lib/services/aws/evidently/main.d.ts +7 -7
  69. package/dist/src/lib/services/aws/evidently/main.js +18 -41
  70. package/dist/src/lib/services/aws/identity-access-management/main.d.ts +48 -49
  71. package/dist/src/lib/services/aws/identity-access-management/main.js +110 -133
  72. package/dist/src/lib/services/aws/key-management-service/main.d.ts +2 -2
  73. package/dist/src/lib/services/aws/key-management-service/main.js +5 -28
  74. package/dist/src/lib/services/aws/lambda/main.d.ts +11 -13
  75. package/dist/src/lib/services/aws/lambda/main.js +31 -58
  76. package/dist/src/lib/services/aws/route53/main.d.ts +9 -9
  77. package/dist/src/lib/services/aws/route53/main.js +21 -44
  78. package/dist/src/lib/services/aws/secrets-manager/main.d.ts +5 -6
  79. package/dist/src/lib/services/aws/secrets-manager/main.js +10 -33
  80. package/dist/src/lib/services/aws/simple-notification-service/main.d.ts +4 -4
  81. package/dist/src/lib/services/aws/simple-notification-service/main.js +11 -34
  82. package/dist/src/lib/services/aws/simple-queue-service/main.d.ts +6 -7
  83. package/dist/src/lib/services/aws/simple-queue-service/main.js +15 -38
  84. package/dist/src/lib/services/aws/simple-storage-service/main.d.ts +10 -11
  85. package/dist/src/lib/services/aws/simple-storage-service/main.js +31 -54
  86. package/dist/src/lib/services/aws/step-function/main.d.ts +31 -32
  87. package/dist/src/lib/services/aws/step-function/main.js +33 -57
  88. package/dist/src/lib/services/aws/systems-manager/main.d.ts +4 -4
  89. package/dist/src/lib/services/aws/systems-manager/main.js +10 -33
  90. package/dist/src/lib/services/aws/virtual-private-cloud/main.d.ts +5 -6
  91. package/dist/src/lib/services/aws/virtual-private-cloud/main.js +14 -37
  92. package/dist/src/lib/services/aws/web-application-firewall/main.d.ts +3 -3
  93. package/dist/src/lib/services/aws/web-application-firewall/main.js +8 -31
  94. package/dist/src/lib/utils/aws/index.d.ts +6 -3
  95. package/dist/src/lib/utils/aws/index.js +9 -26
  96. package/package.json +15 -15
  97. package/src/lib/common/construct.ts +97 -67
  98. package/src/lib/common/stack.ts +12 -12
  99. package/src/lib/common/types.ts +2 -2
  100. package/src/lib/construct/api-to-eventbridge-target/api.ts +31 -22
  101. package/src/lib/construct/api-to-eventbridge-target/event.ts +9 -9
  102. package/src/lib/construct/api-to-eventbridge-target/main.ts +56 -41
  103. package/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.ts +9 -9
  104. package/src/lib/construct/api-to-eventbridge-target-with-sns/main.ts +62 -47
  105. package/src/lib/construct/api-to-lambda-target/api.ts +33 -23
  106. package/src/lib/construct/api-to-lambda-target/main.ts +24 -18
  107. package/src/lib/construct/application-configuration/main.ts +31 -24
  108. package/src/lib/construct/graphql-api-lambda/main.ts +22 -22
  109. package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +13 -13
  110. package/src/lib/construct/lambda-with-iam-access/main.ts +25 -25
  111. package/src/lib/construct/lambda-with-iam-access/types.ts +4 -4
  112. package/src/lib/construct/rest-api-lambda/main.ts +21 -21
  113. package/src/lib/construct/rest-api-lambda-with-cache/main.ts +14 -14
  114. package/src/lib/construct/site-with-ecs-backend/main.ts +79 -60
  115. package/src/lib/construct/static-asset-deployment/main.ts +6 -6
  116. package/src/lib/construct/static-site/main.ts +23 -17
  117. package/src/lib/services/aws/api-gateway/main.ts +42 -36
  118. package/src/lib/services/aws/api-gateway/types.ts +2 -2
  119. package/src/lib/services/aws/appconfig/main.ts +19 -19
  120. package/src/lib/services/aws/certificate-manager/main.ts +14 -14
  121. package/src/lib/services/aws/certificate-manager/types.ts +2 -2
  122. package/src/lib/services/aws/cloudfront/main.ts +88 -74
  123. package/src/lib/services/aws/cloudfront/types.ts +6 -3
  124. package/src/lib/services/aws/cloudtrail/main.ts +11 -11
  125. package/src/lib/services/aws/codebuild/main.ts +7 -7
  126. package/src/lib/services/aws/dynamodb/main.ts +8 -8
  127. package/src/lib/services/aws/elastic-container-registry/main.ts +4 -4
  128. package/src/lib/services/aws/elastic-container-service/main.ts +48 -37
  129. package/src/lib/services/aws/elastic-container-service/types.ts +4 -4
  130. package/src/lib/services/aws/elastic-file-system/main.ts +16 -16
  131. package/src/lib/services/aws/elastic-kubernetes-service/main.ts +11 -11
  132. package/src/lib/services/aws/elasticache/main.ts +10 -10
  133. package/src/lib/services/aws/eventbridge/main.ts +37 -37
  134. package/src/lib/services/aws/eventbridge/target.ts +14 -14
  135. package/src/lib/services/aws/evidently/main.ts +18 -18
  136. package/src/lib/services/aws/identity-access-management/main.ts +142 -134
  137. package/src/lib/services/aws/key-management-service/main.ts +5 -5
  138. package/src/lib/services/aws/lambda/main.ts +65 -59
  139. package/src/lib/services/aws/route53/main.ts +31 -31
  140. package/src/lib/services/aws/secrets-manager/main.ts +11 -15
  141. package/src/lib/services/aws/simple-notification-service/main.ts +13 -13
  142. package/src/lib/services/aws/simple-queue-service/main.ts +18 -18
  143. package/src/lib/services/aws/simple-storage-service/main.ts +40 -40
  144. package/src/lib/services/aws/step-function/main.ts +77 -65
  145. package/src/lib/services/aws/systems-manager/main.ts +17 -12
  146. package/src/lib/services/aws/virtual-private-cloud/main.ts +16 -16
  147. package/src/lib/services/aws/web-application-firewall/main.ts +8 -8
  148. package/src/lib/utils/aws/index.ts +8 -5
@@ -1,9 +1,9 @@
1
- import * as cdk from 'aws-cdk-lib'
2
- import * as acm from 'aws-cdk-lib/aws-certificatemanager'
3
- import * as route53 from 'aws-cdk-lib/aws-route53'
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: cdk.Construct, id: string, props: common.CommonStackProps) {
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?: route53.IHostedZone
48
- ): acm.ICertificate {
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 : cdk.Stack.of(scope).account
57
- const certificateRegion = props.certificateRegion ? props.certificateRegion : cdk.Stack.of(scope).region
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 = acm.Certificate.fromCertificateArn(scope, `${id}`, certificateArn)
60
+ certificate = Certificate.fromCertificateArn(scope, `${id}`, certificateArn)
61
61
  } else {
62
- certificate = new acm.Certificate(scope, `${id}`, {
62
+ certificate = new Certificate(scope, `${id}`, {
63
63
  domainName: props.domainName,
64
64
  subjectAlternativeNames: props.subjectAlternativeNames,
65
- validation: acm.CertificateValidation.fromDns(hostedZone),
65
+ validation: CertificateValidation.fromDns(hostedZone),
66
66
  })
67
67
  }
68
68
 
69
- utils.createCfnOutput(`${id}-certificateArn`, scope, certificate.certificateArn)
69
+ createCfnOutput(`${id}-certificateArn`, scope, certificate.certificateArn)
70
70
 
71
71
  return certificate
72
72
  }
@@ -1,8 +1,8 @@
1
- import * as acm from 'aws-cdk-lib/aws-certificatemanager'
1
+ import { CertificateProps } from 'aws-cdk-lib/aws-certificatemanager'
2
2
 
3
3
  /**
4
4
  */
5
- export interface AcmProps extends acm.CertificateProps {
5
+ export interface AcmProps extends CertificateProps {
6
6
  certificateAccount?: string
7
7
  certificateArn?: string
8
8
  certificateId?: string
@@ -1,27 +1,41 @@
1
- import * as cdk from 'aws-cdk-lib'
2
- import * as acm from 'aws-cdk-lib/aws-certificatemanager'
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 efs from 'aws-cdk-lib/aws-efs'
7
- import * as iam from 'aws-cdk-lib/aws-iam'
8
- import * as lambda from 'aws-cdk-lib/aws-lambda'
9
- import * as s3 from 'aws-cdk-lib/aws-s3'
10
- import * as cr from 'aws-cdk-lib/custom-resources'
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 * as utils from '../../../utils'
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 CloudFront.
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: cdk.Construct, id: string, props: common.CommonStackProps) {
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?: s3.IBucket) {
41
- const oai = new cloudfront.OriginAccessIdentity(scope, `${id}`, {
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?: s3.IBucket,
65
- logBucket?: s3.IBucket,
66
- oai?: cloudfront.OriginAccessIdentity,
67
- certificate?: acm.ICertificate,
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 cloudfront.CloudFrontWebDistribution(scope, `${id}`, {
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 ?? cloudfront.HttpVersion.HTTP2,
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 ?? cloudfront.PriceClass.PRICE_CLASS_ALL,
96
- viewerCertificate: cloudfront.ViewerCertificate.fromAcmCertificate(certificate, {
109
+ priceClass: props.priceClass ?? PriceClass.PRICE_CLASS_ALL,
110
+ viewerCertificate: ViewerCertificate.fromAcmCertificate(certificate, {
97
111
  aliases: aliases,
98
- securityPolicy: cloudfront.SecurityPolicyProtocol.TLS_V1_1_2016,
99
- sslMethod: cloudfront.SSLMethod.SNI,
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
- cdk.Tags.of(distribution).add(tag.key, tag.value)
120
+ Tags.of(distribution).add(tag.key, tag.value)
107
121
  })
108
122
  }
109
123
 
110
- utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
111
- utils.createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
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: origins.S3Origin,
134
- siteBucket: s3.IBucket,
135
- logBucket?: s3.IBucket,
136
- oai?: cloudfront.OriginAccessIdentity,
137
- certificate?: acm.ICertificate,
147
+ origin: S3Origin,
148
+ siteBucket: IBucket,
149
+ logBucket?: IBucket,
150
+ oai?: OriginAccessIdentity,
151
+ certificate?: ICertificate,
138
152
  aliases?: string[],
139
- defaultFunctionAssociations?: cloudfront.FunctionAssociation[]
153
+ defaultFunctionAssociations?: FunctionAssociation[]
140
154
  ) {
141
- const distribution = new cloudfront.Distribution(scope, `${id}`, {
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 ?? cloudfront.HttpVersion.HTTP2,
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 ?? cloudfront.SecurityPolicyProtocol.TLS_V1_2_2021,
165
- priceClass: props.priceClass ?? cloudfront.PriceClass.PRICE_CLASS_ALL,
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
- cdk.Tags.of(distribution).add(tag.key, tag.value)
185
+ Tags.of(distribution).add(tag.key, tag.value)
172
186
  })
173
187
  }
174
188
 
175
- utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
176
- utils.createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
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: origins.HttpOrigin,
211
+ origin: HttpOrigin,
198
212
  domainNames: string[],
199
- logBucket?: s3.IBucket,
200
- certificate?: acm.ICertificate,
201
- defaultFunctionAssociations?: cloudfront.FunctionAssociation[],
202
- responseHeadersPolicy?: cloudfront.IResponseHeadersPolicy
213
+ logBucket?: IBucket,
214
+ certificate?: ICertificate,
215
+ defaultFunctionAssociations?: FunctionAssociation[],
216
+ responseHeadersPolicy?: IResponseHeadersPolicy
203
217
  ) {
204
- const distribution = new cloudfront.Distribution(scope, `${id}`, {
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 ?? cloudfront.HttpVersion.HTTP2,
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 ?? cloudfront.SecurityPolicyProtocol.TLS_V1_2_2021,
229
- priceClass: props.priceClass ?? cloudfront.PriceClass.PRICE_CLASS_ALL,
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
- cdk.Tags.of(distribution).add(tag.key, tag.value)
249
+ Tags.of(distribution).add(tag.key, tag.value)
236
250
  })
237
251
  }
238
252
 
239
- utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
240
- utils.createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
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: lambda.ILayerVersion[],
264
- code: lambda.AssetCode,
265
- role: iam.Role,
277
+ layers: ILayerVersion[],
278
+ code: AssetCode,
279
+ role: Role,
266
280
  environment?: any,
267
- vpc?: ec2.IVpc,
268
- securityGroups?: ec2.ISecurityGroup[],
269
- accessPoint?: efs.IAccessPoint,
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 cloudfront.experimental.EdgeFunction(scope, `${id}`, {
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 ? lambda.FileSystem.fromEfsAccessPoint(accessPoint, mountPath ?? '/mnt/msg') : undefined,
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 ? cdk.Duration.seconds(props.timeoutInSecs) : cdk.Duration.minutes(1),
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
- cdk.Tags.of(edgeFunction).add(tag.key, tag.value)
311
+ Tags.of(edgeFunction).add(tag.key, tag.value)
298
312
  })
299
313
  }
300
314
 
301
- utils.createCfnOutput(`${id}-edgeArn`, scope, edgeFunction.edgeArn)
302
- utils.createCfnOutput(`${id}-edgeFunctionArn`, scope, edgeFunction.functionArn)
303
- utils.createCfnOutput(`${id}-edgeFunctionName`, scope, edgeFunction.functionName)
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 cr.AwsCustomResource(scope, `${id}-trigger-codebuild-${new Date().getTime()}`, {
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: cr.PhysicalResourceId.fromResponse('build.id'),
349
+ physicalResourceId: PhysicalResourceId.fromResponse('build.id'),
336
350
  service: 'CodeBuild',
337
351
  },
338
- policy: cr.AwsCustomResourcePolicy.fromSdkCalls({ resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE }),
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 cloudfront.Function(scope, `${id}`, {
350
- code: cloudfront.FunctionCode.fromFile({
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
- utils.createCfnOutput(`${id}-functionArn`, scope, cloudfrontFunction.functionArn)
358
- utils.createCfnOutput(`${id}-functionName`, scope, cloudfrontFunction.functionName)
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 cf.DistributionProps {
16
+ export interface DistributionProps extends CfDistributionProps {
14
17
  tags?: TagProps[]
15
18
  }
16
19
 
@@ -1,8 +1,8 @@
1
- import * as cloudtrail from 'aws-cdk-lib/aws-cloudtrail'
2
- import * as logs from 'aws-cdk-lib/aws-logs'
3
- import * as s3 from 'aws-cdk-lib/aws-s3'
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: logs.CfnLogGroup,
47
- dataBucket: s3.IBucket,
48
- logBucket: s3.IBucket,
49
- logBucketPolicy: s3.CfnBucketPolicy
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 cloudtrail.CfnTrail(scope, `${id}`, {
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
- utils.createCfnOutput(`${id}-trailName`, scope, cloudTrail.trailName)
85
- utils.createCfnOutput(`${id}-trailArn`, scope, cloudTrail.attrArn)
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 * as cdk from 'aws-cdk-lib'
2
- import * as codebuild from 'aws-cdk-lib/aws-codebuild'
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 codebuild.Project(scope, `${id}-install-deps-project`, {
49
- buildSpec: codebuild.BuildSpec.fromObject({
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: codebuild.LinuxBuildImage.fromDockerRegistry(
60
+ buildImage: LinuxBuildImage.fromDockerRegistry(
61
61
  this.createImageForCloudfrontInvalidation(id, scope, dockerFilepath).imageUri
62
62
  ),
63
- computeType: codebuild.ComputeType.SMALL,
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: cdk.Duration.minutes(5),
75
+ timeout: Duration.minutes(5),
76
76
  })
77
77
  }
78
78
  }
@@ -1,11 +1,11 @@
1
- import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'
2
- import * as utils from '../../../utils'
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 dynamodb.Table(scope, `${id}`, {
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
- cdk.Tags.of(table).add(tag.key, tag.value)
55
+ Tags.of(table).add(tag.key, tag.value)
56
56
  })
57
57
  }
58
58
 
59
- utils.createCfnOutput(`${id}-tableName`, scope, table.tableName)
60
- utils.createCfnOutput(`${id}-tableArn`, scope, table.tableArn)
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 * as ecr from 'aws-cdk-lib/aws-ecr-assets'
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 ecr.DockerImageAsset(scope, `${id}`, {
29
+ const asset = new DockerImageAsset(scope, `${id}`, {
30
30
  directory: dockerfilePath,
31
31
  })
32
32
 
33
- utils.createCfnOutput(`${id}-dockerImageArn`, scope, asset.imageUri)
33
+ createCfnOutput(`${id}-dockerImageArn`, scope, asset.imageUri)
34
34
 
35
35
  return asset
36
36
  }