@gradientedge/cdk-utils-aws 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/common/stack.d.ts +2 -2
- package/dist/src/common/stack.js +4 -4
- package/dist/src/construct/api-to-any-target/main.js +1 -1
- package/dist/src/construct/api-to-eventbridge-target/main.js +3 -3
- package/dist/src/construct/api-to-eventbridge-target-with-sns/main.js +3 -3
- package/dist/src/construct/api-to-eventbridge-target-with-sns/types.d.ts +1 -1
- package/dist/src/construct/api-to-lambda-target/main.js +1 -1
- package/dist/src/construct/api-to-lambda-target/types.d.ts +2 -2
- package/dist/src/construct/rest-api-lambda/types.d.ts +1 -1
- package/dist/src/construct/rest-api-lambda-with-cache/main.d.ts +1 -1
- package/dist/src/construct/site-with-ecs-backend/main.js +3 -3
- package/dist/src/construct/site-with-ecs-backend/types.d.ts +2 -2
- package/dist/src/construct/site-with-lambda-backend/main.js +3 -3
- package/dist/src/construct/static-asset-deployment/main.js +2 -2
- package/dist/src/construct/static-site/main.js +1 -1
- package/dist/src/construct/static-site/types.d.ts +1 -1
- package/dist/src/services/api-gateway/main.js +2 -2
- package/dist/src/services/appconfig/main.js +6 -6
- package/dist/src/services/certificate-manager/main.js +1 -1
- package/dist/src/services/cloudfront/main.js +4 -4
- package/dist/src/services/cloudtrail/main.js +2 -2
- package/dist/src/services/cloudwatch/logs.js +5 -5
- package/dist/src/services/cloudwatch/main.js +27 -27
- package/dist/src/services/dynamodb/main.js +4 -4
- package/dist/src/services/elastic-container-service/main.js +6 -6
- package/dist/src/services/elastic-file-system/main.js +3 -3
- package/dist/src/services/elastic-kubernetes-service/main.js +2 -2
- package/dist/src/services/elasticache/main.js +3 -3
- package/dist/src/services/eventbridge/main.js +15 -15
- package/dist/src/services/eventbridge/target.d.ts +2 -4
- package/dist/src/services/eventbridge/target.js +1 -3
- package/dist/src/services/evidently/main.js +9 -9
- package/dist/src/services/key-management-service/main.js +2 -2
- package/dist/src/services/lambda/main.js +5 -5
- package/dist/src/services/route53/main.js +5 -5
- package/dist/src/services/secrets-manager/main.js +3 -3
- package/dist/src/services/simple-notification-service/main.js +4 -4
- package/dist/src/services/simple-queue-service/main.js +2 -2
- package/dist/src/services/simple-storage-service/main.js +3 -3
- package/dist/src/services/step-function/main.js +15 -15
- package/dist/src/services/systems-manager/main.js +8 -8
- package/dist/src/services/virtual-private-cloud/main.js +2 -2
- package/dist/src/services/web-application-firewall/main.js +4 -4
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { App, Stack, StackProps } from 'aws-cdk-lib';
|
|
2
1
|
import { Runtime } from 'aws-cdk-lib/aws-lambda';
|
|
3
|
-
import {
|
|
2
|
+
import { App, Stack, StackProps } from 'aws-cdk-lib';
|
|
4
3
|
import { CommonStackProps } from './types.js';
|
|
4
|
+
import { CommonConstruct } from './construct.js';
|
|
5
5
|
/**
|
|
6
6
|
* @classdesc Common stack to use as a base for all higher level constructs.
|
|
7
7
|
* @example
|
package/dist/src/common/stack.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Stack } from 'aws-cdk-lib';
|
|
2
|
-
import { Runtime } from 'aws-cdk-lib/aws-lambda';
|
|
3
1
|
import fs from 'fs';
|
|
4
2
|
import path from 'path';
|
|
5
|
-
import {
|
|
3
|
+
import { Runtime } from 'aws-cdk-lib/aws-lambda';
|
|
4
|
+
import { Stack } from 'aws-cdk-lib';
|
|
6
5
|
import appRoot from 'app-root-path';
|
|
7
6
|
import _ from 'lodash';
|
|
8
7
|
import { isDevStage } from '@gradientedge/cdk-utils-common';
|
|
8
|
+
import { CommonConstruct } from './construct.js';
|
|
9
9
|
/**
|
|
10
10
|
* @classdesc Common stack to use as a base for all higher level constructs.
|
|
11
11
|
* @example
|
|
@@ -75,7 +75,7 @@ export class CommonStack extends Stack {
|
|
|
75
75
|
const extraContextPath = path.join(appRoot.path, context);
|
|
76
76
|
/* scenario where extra context is configured in cdk.json but absent in file system */
|
|
77
77
|
if (!fs.existsSync(extraContextPath))
|
|
78
|
-
throw `Extra context properties unavailable in path:${extraContextPath}
|
|
78
|
+
throw new Error(`Extra context properties unavailable in path:${extraContextPath}`);
|
|
79
79
|
/* read the extra properties */
|
|
80
80
|
const extraContextPropsBuffer = fs.readFileSync(extraContextPath);
|
|
81
81
|
if (debug)
|
|
@@ -75,7 +75,7 @@ export class ApiToAnyTarget extends CommonConstruct {
|
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
if (!this.props.api.restApi?.restApiName)
|
|
78
|
-
throw `RestApi name undefined for ${this.id}
|
|
78
|
+
throw new Error(`RestApi name undefined for ${this.id}`);
|
|
79
79
|
const restApiName = this.resourceNameFormatter.format(this.props.api.restApi?.restApiName, this.props.resourceNameOptions?.apigateway);
|
|
80
80
|
const restApiAccessLogName = this.resourceNameFormatter.format(`${this.props.api.restApi?.restApiName}-access`, this.props.resourceNameOptions?.apigateway);
|
|
81
81
|
this.apiToAnyTargetRestApi.accessLogGroup = this.logManager.createLogGroup(`${this.id}-rest-api-access-log`, this, {
|
|
@@ -129,7 +129,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
|
|
|
129
129
|
if (this.props.api.useExisting)
|
|
130
130
|
return;
|
|
131
131
|
if (!this.props.event.rule.ruleName)
|
|
132
|
-
throw `Event ruleName undefined for ${this.id}
|
|
132
|
+
throw new Error(`Event ruleName undefined for ${this.id}`);
|
|
133
133
|
this.props.event.rule = {
|
|
134
134
|
eventPattern: {
|
|
135
135
|
source: ['api-to-eventbridge-target'],
|
|
@@ -148,7 +148,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
|
|
|
148
148
|
*/
|
|
149
149
|
createApiToEventBridgeTargetRole() {
|
|
150
150
|
if (!this.apiToEventBridgeTargetRestApi.policy)
|
|
151
|
-
throw 'Policy undefined';
|
|
151
|
+
throw new Error('Policy undefined');
|
|
152
152
|
this.apiToEventBridgeTargetRestApi.role = new Role(this, `${this.id}-rest-api-role`, {
|
|
153
153
|
assumedBy: new ServicePrincipal('apigateway.amazonaws.com'),
|
|
154
154
|
inlinePolicies: { policy: this.apiToEventBridgeTargetRestApi.policy },
|
|
@@ -293,7 +293,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
|
|
|
293
293
|
return;
|
|
294
294
|
}
|
|
295
295
|
if (!this.props.api.restApi?.restApiName)
|
|
296
|
-
throw `RestApi name undefined for ${this.id}
|
|
296
|
+
throw new Error(`RestApi name undefined for ${this.id}`);
|
|
297
297
|
const restApiName = this.resourceNameFormatter.format(this.props.api.restApi?.restApiName, this.props.resourceNameOptions?.apigateway);
|
|
298
298
|
const restApiAccessLogName = this.resourceNameFormatter.format(`${this.props.api.restApi?.restApiName}-access`, this.props.resourceNameOptions?.apigateway);
|
|
299
299
|
this.apiToEventBridgeTargetRestApi.accessLogGroup = this.logManager.createLogGroup(`${this.id}-rest-api-access-log`, this, {
|
|
@@ -170,7 +170,7 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
|
|
|
170
170
|
if (this.props.api.useExisting)
|
|
171
171
|
return;
|
|
172
172
|
if (!this.props.lambda || !this.props.lambda.source)
|
|
173
|
-
throw 'Api Destined Lambda props undefined';
|
|
173
|
+
throw new Error('Api Destined Lambda props undefined');
|
|
174
174
|
this.apiDestinedLambda.function = this.lambdaManager.createLambdaFunction(`${this.id}-lambda-destined`, this, {
|
|
175
175
|
...this.props.lambda.function,
|
|
176
176
|
onFailure: this.apiDestinedLambda.destinationFailure,
|
|
@@ -291,7 +291,7 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
|
|
|
291
291
|
if (!this.props.api.withResource)
|
|
292
292
|
return;
|
|
293
293
|
if (!this.apiDestinedRestApi.topic)
|
|
294
|
-
throw 'Topic undefined';
|
|
294
|
+
throw new Error('Topic undefined');
|
|
295
295
|
this.apiDestinedRestApi.integrationRequestTemplates = {
|
|
296
296
|
'application/json': [
|
|
297
297
|
'Action=Publish',
|
|
@@ -407,7 +407,7 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
|
|
|
407
407
|
return;
|
|
408
408
|
}
|
|
409
409
|
if (!this.props.api.restApi?.restApiName)
|
|
410
|
-
throw `RestApi name undefined for ${this.id}
|
|
410
|
+
throw new Error(`RestApi name undefined for ${this.id}`);
|
|
411
411
|
const restApiName = this.resourceNameFormatter.format(this.props.api.restApi?.restApiName, this.props.resourceNameOptions?.apigateway);
|
|
412
412
|
const restApiAccessLogName = this.resourceNameFormatter.format(`${this.props.api.restApi?.restApiName}-access`, this.props.resourceNameOptions?.apigateway);
|
|
413
413
|
const accessLogGroup = this.logManager.createLogGroup(`${this.id}-rest-api-access-log`, this, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LambdaEnvironment } from '../../services/index.js';
|
|
2
1
|
import { EventBridgeDestination } from 'aws-cdk-lib/aws-lambda-destinations';
|
|
3
2
|
import { AssetCode, IFunction, LayerVersion } from 'aws-cdk-lib/aws-lambda';
|
|
4
3
|
import { PolicyDocument, Role } from 'aws-cdk-lib/aws-iam';
|
|
4
|
+
import { LambdaEnvironment } from '../../services/index.js';
|
|
5
5
|
/**
|
|
6
6
|
*/
|
|
7
7
|
export interface ApiDestinedLambdaEnvironment extends LambdaEnvironment {
|
|
@@ -155,7 +155,7 @@ export class ApiToLambdaTarget extends CommonConstruct {
|
|
|
155
155
|
*/
|
|
156
156
|
createApiToLambdaTargetRole() {
|
|
157
157
|
if (!this.apiToLambdaTargetRestApi.policy)
|
|
158
|
-
throw 'Policy undefined';
|
|
158
|
+
throw new Error('Policy undefined');
|
|
159
159
|
this.apiToLambdaTargetRestApi.role = new Role(this, `${this.id}-rest-api-role`, {
|
|
160
160
|
assumedBy: new ServicePrincipal('apigateway.amazonaws.com'),
|
|
161
161
|
inlinePolicies: { policy: this.apiToLambdaTargetRestApi.policy },
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CommonStackProps } from '../../common/index.js';
|
|
2
1
|
import { BasePathMapping, DomainName, IAuthorizer, Integration, IntegrationResponse, IRestApi, Method, MethodResponse, Model, Resource } from 'aws-cdk-lib/aws-apigateway';
|
|
3
|
-
import { AcmProps, LambdaRestApiProps } from '../../services/index.js';
|
|
4
2
|
import * as acm from 'aws-cdk-lib/aws-certificatemanager';
|
|
5
3
|
import * as route53 from 'aws-cdk-lib/aws-route53';
|
|
6
4
|
import { IFunction } from 'aws-cdk-lib/aws-lambda';
|
|
7
5
|
import { ITopic } from 'aws-cdk-lib/aws-sns';
|
|
8
6
|
import { PolicyDocument, Role } from 'aws-cdk-lib/aws-iam';
|
|
7
|
+
import { AcmProps, LambdaRestApiProps } from '../../services/index.js';
|
|
8
|
+
import { CommonStackProps } from '../../common/index.js';
|
|
9
9
|
/**
|
|
10
10
|
*/
|
|
11
11
|
export interface ApiToLambdaTargetRestApiType {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AssetCode } from 'aws-cdk-lib/aws-lambda';
|
|
1
2
|
import { AcmProps, LambdaEnvironment, LambdaProps, LambdaRestApiProps } from '../../services/index.js';
|
|
2
3
|
import { CommonStackProps } from '../../common/index.js';
|
|
3
|
-
import { AssetCode } from 'aws-cdk-lib/aws-lambda';
|
|
4
4
|
/**
|
|
5
5
|
*/
|
|
6
6
|
export interface RestApiLambdaEnvironment extends LambdaEnvironment {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ISecurityGroup, IVpc } from 'aws-cdk-lib/aws-ec2';
|
|
2
2
|
import { CfnReplicationGroup } from 'aws-cdk-lib/aws-elasticache';
|
|
3
3
|
import { Construct } from 'constructs';
|
|
4
|
-
import { RestApiLambdaWithCacheProps } from './types.js';
|
|
5
4
|
import { RestApiLambda } from '../rest-api-lambda/index.js';
|
|
5
|
+
import { RestApiLambdaWithCacheProps } from './types.js';
|
|
6
6
|
/**
|
|
7
7
|
* @classdesc Provides a construct to create and deploy a RestApi API as Lambda with Caching
|
|
8
8
|
*
|
|
@@ -323,7 +323,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
323
323
|
}
|
|
324
324
|
createSiteCachePolicy(id, siteCachePolicy) {
|
|
325
325
|
if (!siteCachePolicy.cachePolicyName)
|
|
326
|
-
throw `SiteCachePolicy cachePolicyName undefined for ${id}
|
|
326
|
+
throw new Error(`SiteCachePolicy cachePolicyName undefined for ${id}`);
|
|
327
327
|
return new CachePolicy(this, `${id}`, {
|
|
328
328
|
cachePolicyName: this.resourceNameFormatter.format(siteCachePolicy.cachePolicyName),
|
|
329
329
|
comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
@@ -348,7 +348,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
348
348
|
if (!this.props.siteOriginRequestPolicy)
|
|
349
349
|
return;
|
|
350
350
|
if (!this.props.siteOriginRequestPolicy.originRequestPolicyName)
|
|
351
|
-
throw `SiteOriginRequestPolicy originRequestPolicyName undefined for ${this.id}
|
|
351
|
+
throw new Error(`SiteOriginRequestPolicy originRequestPolicyName undefined for ${this.id}`);
|
|
352
352
|
this.siteOriginRequestPolicy = new OriginRequestPolicy(this, `${this.id}-sorp`, {
|
|
353
353
|
comment: `Request Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
354
354
|
cookieBehavior: this.props.siteOriginRequestPolicy.cookieBehavior,
|
|
@@ -364,7 +364,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
364
364
|
if (!props)
|
|
365
365
|
return undefined;
|
|
366
366
|
if (!props.responseHeadersPolicyName)
|
|
367
|
-
throw `SiteResponseHeadersPolicy responseHeadersPolicyName undefined for ${this.id}
|
|
367
|
+
throw new Error(`SiteResponseHeadersPolicy responseHeadersPolicyName undefined for ${this.id}`);
|
|
368
368
|
return new ResponseHeadersPolicy(this, `${this.id}-${props.type}-srhp`, {
|
|
369
369
|
...props,
|
|
370
370
|
comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CommonStackProps } from '../../common/index.js';
|
|
2
|
-
import { AcmProps, CloudfrontFunctionProps, DistributionProps, EcsApplicationLoadBalancedFargateServiceProps, EcsClusterProps, EfsAccessPointOptions, EfsFileSystemProps, HealthCheck, LogProps, S3BucketProps } from '../../services/index.js';
|
|
3
1
|
import { VpcProps } from 'aws-cdk-lib/aws-ec2';
|
|
4
2
|
import { OriginRequestPolicyProps, ResponseHeadersStrictTransportSecurity, ResponseSecurityHeadersBehavior, ResponseHeadersPolicyProps, CachePolicyProps } from 'aws-cdk-lib/aws-cloudfront';
|
|
3
|
+
import { CommonStackProps } from '../../common/index.js';
|
|
4
|
+
import { AcmProps, CloudfrontFunctionProps, DistributionProps, EcsApplicationLoadBalancedFargateServiceProps, EcsClusterProps, EfsAccessPointOptions, EfsFileSystemProps, HealthCheck, LogProps, S3BucketProps } from '../../services/index.js';
|
|
5
5
|
import { SiteResponseHeaderPolicyType } from './constants.js';
|
|
6
6
|
/**
|
|
7
7
|
*/
|
|
@@ -131,7 +131,7 @@ export class SiteWithLambdaBackend extends CommonConstruct {
|
|
|
131
131
|
}
|
|
132
132
|
createSiteCachePolicy(id, siteCachePolicy) {
|
|
133
133
|
if (!siteCachePolicy.cachePolicyName)
|
|
134
|
-
throw `SiteCachePolicy cachePolicyName undefined for ${id}
|
|
134
|
+
throw new Error(`SiteCachePolicy cachePolicyName undefined for ${id}`);
|
|
135
135
|
return new CachePolicy(this, `${id}`, {
|
|
136
136
|
cachePolicyName: this.resourceNameFormatter.format(siteCachePolicy.cachePolicyName),
|
|
137
137
|
comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
@@ -156,7 +156,7 @@ export class SiteWithLambdaBackend extends CommonConstruct {
|
|
|
156
156
|
if (!this.props.siteOriginRequestPolicy)
|
|
157
157
|
return;
|
|
158
158
|
if (!this.props.siteOriginRequestPolicy.originRequestPolicyName)
|
|
159
|
-
throw `SiteOriginRequestPolicy originRequestPolicyName undefined for ${this.id}
|
|
159
|
+
throw new Error(`SiteOriginRequestPolicy originRequestPolicyName undefined for ${this.id}`);
|
|
160
160
|
this.siteOriginRequestPolicy = new OriginRequestPolicy(this, `${this.id}-sorp`, {
|
|
161
161
|
comment: `Request Policy for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
162
162
|
cookieBehavior: this.props.siteOriginRequestPolicy.cookieBehavior,
|
|
@@ -172,7 +172,7 @@ export class SiteWithLambdaBackend extends CommonConstruct {
|
|
|
172
172
|
if (!props)
|
|
173
173
|
return undefined;
|
|
174
174
|
if (!props.responseHeadersPolicyName)
|
|
175
|
-
throw `SiteResponseHeadersPolicy responseHeadersPolicyName undefined for ${this.id}
|
|
175
|
+
throw new Error(`SiteResponseHeadersPolicy responseHeadersPolicyName undefined for ${this.id}`);
|
|
176
176
|
return new ResponseHeadersPolicy(this, `${this.id}-${props.type}-srhp`, {
|
|
177
177
|
...props,
|
|
178
178
|
comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import path from 'path';
|
|
1
2
|
import { Fn } from 'aws-cdk-lib';
|
|
2
3
|
import { BucketDeployment, Source } from 'aws-cdk-lib/aws-s3-deployment';
|
|
3
4
|
import _ from 'lodash';
|
|
4
|
-
import { CommonConstruct } from '../../common/index.js';
|
|
5
5
|
import appRoot from 'app-root-path';
|
|
6
|
-
import
|
|
6
|
+
import { CommonConstruct } from '../../common/index.js';
|
|
7
7
|
/**
|
|
8
8
|
* @classdesc Provides a construct to create and deploy static assets into S3 bucket
|
|
9
9
|
* @example
|
|
@@ -109,7 +109,7 @@ export class StaticSite extends CommonConstruct {
|
|
|
109
109
|
*/
|
|
110
110
|
createSiteDistribution() {
|
|
111
111
|
if (!this.props.siteDistribution)
|
|
112
|
-
throw 'SiteDistribution props undefined';
|
|
112
|
+
throw new Error('SiteDistribution props undefined');
|
|
113
113
|
this.siteDistribution = this.cloudFrontManager.createDistributionWithS3Origin(`${this.id}-distribution`, this, this.props.siteDistribution, this.siteBucket, this.siteLogBucket, this.siteOriginAccessIdentity, this.siteCertificate, this.props.siteAliases, this.siteFunctionAssociations);
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ISource } from 'aws-cdk-lib/aws-s3-deployment';
|
|
1
2
|
import { CommonStackProps } from '../../common/index.js';
|
|
2
3
|
import { AcmProps, CloudfrontFunctionProps, DistributionProps, S3BucketProps } from '../../services/index.js';
|
|
3
|
-
import { ISource } from 'aws-cdk-lib/aws-s3-deployment';
|
|
4
4
|
/**
|
|
5
5
|
*/
|
|
6
6
|
export interface StaticSiteProps extends CommonStackProps {
|
|
@@ -29,9 +29,9 @@ export class ApiManager {
|
|
|
29
29
|
*/
|
|
30
30
|
createLambdaRestApi(id, scope, props, lambdaFunction) {
|
|
31
31
|
if (!props)
|
|
32
|
-
throw `Api props undefined for ${id}
|
|
32
|
+
throw new Error(`Api props undefined for ${id}`);
|
|
33
33
|
if (!props.restApiName)
|
|
34
|
-
throw `Api restApiName undefined for ${id}
|
|
34
|
+
throw new Error(`Api restApiName undefined for ${id}`);
|
|
35
35
|
const restApiName = scope.resourceNameFormatter.format(props.restApiName, scope.props.resourceNameOptions?.apigateway);
|
|
36
36
|
const restApiAccessLogName = scope.resourceNameFormatter.format(`${props.restApiName}-access`, scope.props.resourceNameOptions?.apigateway);
|
|
37
37
|
const accessLogGroup = scope.logManager.createLogGroup(`${id}-rest-api-access-log`, scope, {
|
|
@@ -32,7 +32,7 @@ export class AppConfigManager {
|
|
|
32
32
|
case Architecture.X86_64:
|
|
33
33
|
return ArnsByRegionForX86_64[scope.props.region];
|
|
34
34
|
default:
|
|
35
|
-
throw `Invalid type ${type} specified
|
|
35
|
+
throw new Error(`Invalid type ${type} specified`);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
@@ -44,7 +44,7 @@ export class AppConfigManager {
|
|
|
44
44
|
*/
|
|
45
45
|
createApplication(id, scope, props) {
|
|
46
46
|
if (!props)
|
|
47
|
-
throw `AppConfig props undefined for ${id}
|
|
47
|
+
throw new Error(`AppConfig props undefined for ${id}`);
|
|
48
48
|
const application = new CfnApplication(scope, `${id}`, {
|
|
49
49
|
...props.application,
|
|
50
50
|
name: scope.resourceNameFormatter.format(props.application.name, scope.props.resourceNameOptions?.appconfig),
|
|
@@ -63,7 +63,7 @@ export class AppConfigManager {
|
|
|
63
63
|
*/
|
|
64
64
|
createEnvironment(id, scope, applicationId, props) {
|
|
65
65
|
if (!props)
|
|
66
|
-
throw `AppConfig props undefined for ${id}
|
|
66
|
+
throw new Error(`AppConfig props undefined for ${id}`);
|
|
67
67
|
const environment = new CfnEnvironment(scope, `${id}`, {
|
|
68
68
|
...props.environment,
|
|
69
69
|
applicationId,
|
|
@@ -84,7 +84,7 @@ export class AppConfigManager {
|
|
|
84
84
|
*/
|
|
85
85
|
createConfigurationProfile(id, scope, applicationId, props) {
|
|
86
86
|
if (!props)
|
|
87
|
-
throw `AppConfig props undefined for ${id}
|
|
87
|
+
throw new Error(`AppConfig props undefined for ${id}`);
|
|
88
88
|
const profile = new CfnConfigurationProfile(scope, `${id}`, {
|
|
89
89
|
...props.configurationProfile,
|
|
90
90
|
applicationId,
|
|
@@ -104,9 +104,9 @@ export class AppConfigManager {
|
|
|
104
104
|
*/
|
|
105
105
|
createDeploymentStrategy(id, scope, props) {
|
|
106
106
|
if (!props)
|
|
107
|
-
throw `AppConfig props undefined for ${id}
|
|
107
|
+
throw new Error(`AppConfig props undefined for ${id}`);
|
|
108
108
|
if (!props.deploymentStrategy)
|
|
109
|
-
throw `AppConfig deploymentStrategy props undefined for ${id}
|
|
109
|
+
throw new Error(`AppConfig deploymentStrategy props undefined for ${id}`);
|
|
110
110
|
const deploymentStrategy = new DeploymentStrategy(scope, `${id}`, {
|
|
111
111
|
...props,
|
|
112
112
|
deploymentStrategyName: scope.resourceNameFormatter.format(props.deploymentStrategy.deploymentStrategyName ?? 'common-deployment-strategy', scope.props.resourceNameOptions?.appconfig),
|
|
@@ -38,7 +38,7 @@ export class AcmManager {
|
|
|
38
38
|
*/
|
|
39
39
|
resolveCertificate(id, scope, props, hostedZone) {
|
|
40
40
|
if (!props)
|
|
41
|
-
throw `Certificate props undefined for ${id}
|
|
41
|
+
throw new Error(`Certificate props undefined for ${id}`);
|
|
42
42
|
let certificate;
|
|
43
43
|
if (props.useExistingCertificate) {
|
|
44
44
|
let certificateArn = props.certificateArn;
|
|
@@ -146,9 +146,9 @@ export class CloudFrontManager {
|
|
|
146
146
|
*/
|
|
147
147
|
createEdgeFunction(id, scope, props, layers, code, role, environment, vpc, securityGroups, accessPoint, mountPath) {
|
|
148
148
|
if (!props)
|
|
149
|
-
throw `EdgeFunction props undefined for ${id}
|
|
149
|
+
throw new Error(`EdgeFunction props undefined for ${id}`);
|
|
150
150
|
if (!props.functionName)
|
|
151
|
-
throw `EdgeFunction functionName undefined for ${id}
|
|
151
|
+
throw new Error(`EdgeFunction functionName undefined for ${id}`);
|
|
152
152
|
const functionName = scope.resourceNameFormatter.format(props.functionName, scope.props.resourceNameOptions?.cloudfront);
|
|
153
153
|
const edgeFunction = new cf.experimental.EdgeFunction(scope, `${id}`, {
|
|
154
154
|
code: code,
|
|
@@ -213,9 +213,9 @@ export class CloudFrontManager {
|
|
|
213
213
|
*/
|
|
214
214
|
createCloudfrontFunction(id, scope, props) {
|
|
215
215
|
if (!props)
|
|
216
|
-
throw `CloudFront Function props undefined for ${id}
|
|
216
|
+
throw new Error(`CloudFront Function props undefined for ${id}`);
|
|
217
217
|
if (!props.functionName)
|
|
218
|
-
throw `CloudFront Function functionName undefined for ${id}
|
|
218
|
+
throw new Error(`CloudFront Function functionName undefined for ${id}`);
|
|
219
219
|
const cloudfrontFunction = new Function(scope, `${id}`, {
|
|
220
220
|
...props,
|
|
221
221
|
code: FunctionCode.fromFile({
|
|
@@ -36,9 +36,9 @@ export class CloudTrailManager {
|
|
|
36
36
|
*/
|
|
37
37
|
createCloudTrail(id, scope, props, logGroup, dataBucket, logBucket, logBucketPolicy) {
|
|
38
38
|
if (!props)
|
|
39
|
-
throw `CloudTrail props undefined for ${id}
|
|
39
|
+
throw new Error(`CloudTrail props undefined for ${id}`);
|
|
40
40
|
if (!props.trailName)
|
|
41
|
-
throw `CloudTrail trailName undefined for ${id}
|
|
41
|
+
throw new Error(`CloudTrail trailName undefined for ${id}`);
|
|
42
42
|
const role = scope.iamManager.createRoleForCloudTrail(`${id}Role`, scope, logGroup);
|
|
43
43
|
const cloudTrail = new CfnTrail(scope, `${id}`, {
|
|
44
44
|
...props,
|
|
@@ -28,7 +28,7 @@ export class LogManager {
|
|
|
28
28
|
*/
|
|
29
29
|
createMetricFilter(id, scope, props, logGroup) {
|
|
30
30
|
if (!props)
|
|
31
|
-
throw `MetricFilter props undefined for ${id}
|
|
31
|
+
throw new Error(`MetricFilter props undefined for ${id}`);
|
|
32
32
|
const metricFilter = new logs.MetricFilter(scope, `${id}`, {
|
|
33
33
|
defaultValue: props.defaultValue,
|
|
34
34
|
filterPattern: props.filterPattern,
|
|
@@ -54,9 +54,9 @@ export class LogManager {
|
|
|
54
54
|
*/
|
|
55
55
|
createCfnLogGroup(id, scope, props) {
|
|
56
56
|
if (!props)
|
|
57
|
-
throw `Logs props undefined for ${id}
|
|
57
|
+
throw new Error(`Logs props undefined for ${id}`);
|
|
58
58
|
if (!props.logGroupName)
|
|
59
|
-
throw `Logs logGroupName undefined for ${id}
|
|
59
|
+
throw new Error(`Logs logGroupName undefined for ${id}`);
|
|
60
60
|
const logGroup = new logs.CfnLogGroup(scope, `${id}`, {
|
|
61
61
|
...props,
|
|
62
62
|
logGroupName: props.logGroupName,
|
|
@@ -78,9 +78,9 @@ export class LogManager {
|
|
|
78
78
|
*/
|
|
79
79
|
createLogGroup(id, scope, props) {
|
|
80
80
|
if (!props)
|
|
81
|
-
throw `Logs props undefined for ${id}
|
|
81
|
+
throw new Error(`Logs props undefined for ${id}`);
|
|
82
82
|
if (!props.logGroupName)
|
|
83
|
-
throw `Logs logGroupName undefined for ${id}
|
|
83
|
+
throw new Error(`Logs logGroupName undefined for ${id}`);
|
|
84
84
|
const logGroup = new logs.LogGroup(scope, `${id}`, {
|
|
85
85
|
...props,
|
|
86
86
|
logGroupName: props.logGroupName,
|
|
@@ -38,11 +38,11 @@ export class CloudWatchManager {
|
|
|
38
38
|
*/
|
|
39
39
|
createAlarmForExpression(id, scope, props) {
|
|
40
40
|
if (!props)
|
|
41
|
-
throw `Alarm props undefined for ${id}
|
|
41
|
+
throw new Error(`Alarm props undefined for ${id}`);
|
|
42
42
|
if (!props.expression)
|
|
43
|
-
throw `Could not find expression for Alarm props for id:${id}
|
|
43
|
+
throw new Error(`Could not find expression for Alarm props for id:${id}`);
|
|
44
44
|
if (!props.metricProps)
|
|
45
|
-
throw `Could not find metricProps for Alarm props for id:${id}
|
|
45
|
+
throw new Error(`Could not find metricProps for Alarm props for id:${id}`);
|
|
46
46
|
const metrics = {};
|
|
47
47
|
_.map(this.determineMetrics(scope, props.metricProps), (metric, index) => {
|
|
48
48
|
metrics[`m${index}`] = metric;
|
|
@@ -69,7 +69,7 @@ export class CloudWatchManager {
|
|
|
69
69
|
*/
|
|
70
70
|
createAlarmForMetric(id, scope, props, metric) {
|
|
71
71
|
if (!props)
|
|
72
|
-
throw `Alarm props undefined for ${id}
|
|
72
|
+
throw new Error(`Alarm props undefined for ${id}`);
|
|
73
73
|
const alarm = metric.createAlarm(scope, `${id}`, {
|
|
74
74
|
...props,
|
|
75
75
|
});
|
|
@@ -86,9 +86,9 @@ export class CloudWatchManager {
|
|
|
86
86
|
*/
|
|
87
87
|
createDashboard(id, scope, props, widgets) {
|
|
88
88
|
if (!props)
|
|
89
|
-
throw `Dashboard props undefined for ${id}
|
|
89
|
+
throw new Error(`Dashboard props undefined for ${id}`);
|
|
90
90
|
if (!props.dashboardName)
|
|
91
|
-
throw `Dashboard dashboardName undefined for ${id}
|
|
91
|
+
throw new Error(`Dashboard dashboardName undefined for ${id}`);
|
|
92
92
|
const dashboard = new watch.Dashboard(scope, `${id}`, {
|
|
93
93
|
...props,
|
|
94
94
|
dashboardName: scope.resourceNameFormatter.format(props.dashboardName, scope.props.resourceNameOptions?.cloudwatch),
|
|
@@ -105,8 +105,8 @@ export class CloudWatchManager {
|
|
|
105
105
|
* @param props
|
|
106
106
|
*/
|
|
107
107
|
createWidgets(scope, props) {
|
|
108
|
-
if (!props || props.length
|
|
109
|
-
throw `Widget props undefined
|
|
108
|
+
if (!props || props.length === 0)
|
|
109
|
+
throw new Error(`Widget props undefined`);
|
|
110
110
|
const widgets = [];
|
|
111
111
|
_.forEach(props, (widgetProps) => {
|
|
112
112
|
widgets.push(this.createWidget(widgetProps.id, scope, widgetProps));
|
|
@@ -121,7 +121,7 @@ export class CloudWatchManager {
|
|
|
121
121
|
*/
|
|
122
122
|
createWidget(id, scope, props) {
|
|
123
123
|
if (!props)
|
|
124
|
-
throw `Widget props undefined for ${id}
|
|
124
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
125
125
|
const metrics = this.determineMetrics(scope, props.metricProps);
|
|
126
126
|
let alarms, logGroupNames = [];
|
|
127
127
|
switch (props.type) {
|
|
@@ -140,7 +140,7 @@ export class CloudWatchManager {
|
|
|
140
140
|
logGroupNames = props.logGroupNames.map((name) => `${name}-${scope.props.stage}`);
|
|
141
141
|
return this.createLogQueryWidget(id, scope, props, logGroupNames);
|
|
142
142
|
default:
|
|
143
|
-
throw `Unsupported widget type ${props.type}
|
|
143
|
+
throw new Error(`Unsupported widget type ${props.type}`);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
@@ -152,7 +152,7 @@ export class CloudWatchManager {
|
|
|
152
152
|
*/
|
|
153
153
|
createCloudfrontDistributionWidget(id, scope, props, distributionId) {
|
|
154
154
|
if (!props)
|
|
155
|
-
throw `Widget props undefined for ${id}
|
|
155
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
156
156
|
const metricProps = props.metricProps;
|
|
157
157
|
return this.createWidget(id, scope, {
|
|
158
158
|
...props,
|
|
@@ -168,7 +168,7 @@ export class CloudWatchManager {
|
|
|
168
168
|
*/
|
|
169
169
|
createStateWidget(id, scope, props, stateMachineArn) {
|
|
170
170
|
if (!props)
|
|
171
|
-
throw `Widget props undefined for ${id}
|
|
171
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
172
172
|
const metricProps = props.metricProps;
|
|
173
173
|
return this.createWidget(id, scope, {
|
|
174
174
|
...props,
|
|
@@ -185,7 +185,7 @@ export class CloudWatchManager {
|
|
|
185
185
|
*/
|
|
186
186
|
createEventWidget(id, scope, props, eventBusName, ruleName) {
|
|
187
187
|
if (!props)
|
|
188
|
-
throw `Widget props undefined for ${id}
|
|
188
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
189
189
|
const metricProps = props.metricProps;
|
|
190
190
|
return this.createWidget(id, scope, {
|
|
191
191
|
...props,
|
|
@@ -201,7 +201,7 @@ export class CloudWatchManager {
|
|
|
201
201
|
*/
|
|
202
202
|
createApiGatewayWidget(id, scope, props, apiName) {
|
|
203
203
|
if (!props)
|
|
204
|
-
throw `Widget props undefined for ${id}
|
|
204
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
205
205
|
const metricProps = props.metricProps;
|
|
206
206
|
return this.createWidget(id, scope, {
|
|
207
207
|
...props,
|
|
@@ -217,7 +217,7 @@ export class CloudWatchManager {
|
|
|
217
217
|
*/
|
|
218
218
|
createLambdaWidget(id, scope, props, functionName) {
|
|
219
219
|
if (!props)
|
|
220
|
-
throw `Widget props undefined for ${id}
|
|
220
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
221
221
|
const metricProps = props.metricProps;
|
|
222
222
|
return this.createWidget(id, scope, {
|
|
223
223
|
...props,
|
|
@@ -233,7 +233,7 @@ export class CloudWatchManager {
|
|
|
233
233
|
*/
|
|
234
234
|
createCustomWidget(id, scope, props, service) {
|
|
235
235
|
if (!props)
|
|
236
|
-
throw `Widget props undefined for ${id}
|
|
236
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
237
237
|
const metricProps = props.metricProps;
|
|
238
238
|
return this.createWidget(id, scope, {
|
|
239
239
|
...props,
|
|
@@ -249,7 +249,7 @@ export class CloudWatchManager {
|
|
|
249
249
|
*/
|
|
250
250
|
createEcsClusterWidget(id, scope, props, clusterName) {
|
|
251
251
|
if (!props)
|
|
252
|
-
throw `Widget props undefined for ${id}
|
|
252
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
253
253
|
const metricProps = props.metricProps;
|
|
254
254
|
return this.createWidget(id, scope, {
|
|
255
255
|
...props,
|
|
@@ -266,7 +266,7 @@ export class CloudWatchManager {
|
|
|
266
266
|
*/
|
|
267
267
|
createEcsServiceWidget(id, scope, props, clusterName, serviceName) {
|
|
268
268
|
if (!props)
|
|
269
|
-
throw `Widget props undefined for ${id}
|
|
269
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
270
270
|
const metricProps = props.metricProps;
|
|
271
271
|
return this.createWidget(id, scope, {
|
|
272
272
|
...props,
|
|
@@ -282,7 +282,7 @@ export class CloudWatchManager {
|
|
|
282
282
|
*/
|
|
283
283
|
createElbWidget(id, scope, props, loadBalancer) {
|
|
284
284
|
if (!props)
|
|
285
|
-
throw `Widget props undefined for ${id}
|
|
285
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
286
286
|
const metricProps = props.metricProps;
|
|
287
287
|
return this.createWidget(id, scope, {
|
|
288
288
|
...props,
|
|
@@ -298,7 +298,7 @@ export class CloudWatchManager {
|
|
|
298
298
|
*/
|
|
299
299
|
createCacheWidget(id, scope, props, cacheClusterId) {
|
|
300
300
|
if (!props)
|
|
301
|
-
throw `Widget props undefined for ${id}
|
|
301
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
302
302
|
const metricProps = props.metricProps;
|
|
303
303
|
return this.createWidget(id, scope, {
|
|
304
304
|
...props,
|
|
@@ -313,7 +313,7 @@ export class CloudWatchManager {
|
|
|
313
313
|
*/
|
|
314
314
|
createTextWidget(id, scope, props) {
|
|
315
315
|
if (!props)
|
|
316
|
-
throw `Widget props undefined for ${id}
|
|
316
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
317
317
|
const widget = new watch.TextWidget({
|
|
318
318
|
...props,
|
|
319
319
|
});
|
|
@@ -330,7 +330,7 @@ export class CloudWatchManager {
|
|
|
330
330
|
*/
|
|
331
331
|
createSingleValueWidget(id, scope, props, metrics) {
|
|
332
332
|
if (!props)
|
|
333
|
-
throw `Widget props undefined for ${id}
|
|
333
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
334
334
|
const widget = new watch.SingleValueWidget({
|
|
335
335
|
...props,
|
|
336
336
|
metrics,
|
|
@@ -349,7 +349,7 @@ export class CloudWatchManager {
|
|
|
349
349
|
*/
|
|
350
350
|
createGuageWidget(id, scope, props, metrics) {
|
|
351
351
|
if (!props)
|
|
352
|
-
throw `Widget props undefined for ${id}
|
|
352
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
353
353
|
const widget = new watch.GaugeWidget({
|
|
354
354
|
...props,
|
|
355
355
|
metrics,
|
|
@@ -369,7 +369,7 @@ export class CloudWatchManager {
|
|
|
369
369
|
*/
|
|
370
370
|
createGraphWidget(id, scope, props, leftYMetrics, rightYMetrics) {
|
|
371
371
|
if (!props)
|
|
372
|
-
throw `Widget props undefined for ${id}
|
|
372
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
373
373
|
const widget = new watch.GraphWidget({
|
|
374
374
|
...props,
|
|
375
375
|
left: leftYMetrics,
|
|
@@ -389,7 +389,7 @@ export class CloudWatchManager {
|
|
|
389
389
|
*/
|
|
390
390
|
createAlarmStatusWidget(id, scope, props, alarms) {
|
|
391
391
|
if (!props)
|
|
392
|
-
throw `Widget props undefined for ${id}
|
|
392
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
393
393
|
const widget = new watch.AlarmStatusWidget({
|
|
394
394
|
...props,
|
|
395
395
|
alarms,
|
|
@@ -407,7 +407,7 @@ export class CloudWatchManager {
|
|
|
407
407
|
*/
|
|
408
408
|
createLogQueryWidget(id, scope, props, logGroupNames) {
|
|
409
409
|
if (!props)
|
|
410
|
-
throw `Widget props undefined for ${id}
|
|
410
|
+
throw new Error(`Widget props undefined for ${id}`);
|
|
411
411
|
const widget = new watch.LogQueryWidget({
|
|
412
412
|
...props,
|
|
413
413
|
logGroupNames,
|
|
@@ -541,7 +541,7 @@ export class CloudWatchManager {
|
|
|
541
541
|
if (alarmProps) {
|
|
542
542
|
_.forEach(alarmProps, (alarmProp) => {
|
|
543
543
|
if (!alarmProp.alarmName)
|
|
544
|
-
throw `Alarm name undefined for ${id}
|
|
544
|
+
throw new Error(`Alarm name undefined for ${id}`);
|
|
545
545
|
const alarmArn = `arn:aws:cloudwatch:${cdk.Stack.of(scope).region}:${cdk.Stack.of(scope).account}:alarm:${alarmProp.alarmName}`;
|
|
546
546
|
const alarm = watch.Alarm.fromAlarmArn(scope, `${alarmProp.alarmName}`, alarmArn);
|
|
547
547
|
alarms.push(alarm);
|
|
@@ -27,9 +27,9 @@ export class DynamodbManager {
|
|
|
27
27
|
*/
|
|
28
28
|
createTable(id, scope, props) {
|
|
29
29
|
if (!props)
|
|
30
|
-
throw `Table props undefined for ${id}
|
|
30
|
+
throw new Error(`Table props undefined for ${id}`);
|
|
31
31
|
if (!props.tableName)
|
|
32
|
-
throw `Table tableName undefined for ${id}
|
|
32
|
+
throw new Error(`Table tableName undefined for ${id}`);
|
|
33
33
|
const table = new Table(scope, `${id}`, {
|
|
34
34
|
...props,
|
|
35
35
|
billingMode: props.billingMode ?? BillingMode.PAY_PER_REQUEST,
|
|
@@ -53,9 +53,9 @@ export class DynamodbManager {
|
|
|
53
53
|
*/
|
|
54
54
|
createTableV2(id, scope, props) {
|
|
55
55
|
if (!props)
|
|
56
|
-
throw `Table props undefined for ${id}
|
|
56
|
+
throw new Error(`Table props undefined for ${id}`);
|
|
57
57
|
if (!props.tableName)
|
|
58
|
-
throw `Table tableName undefined for ${id}
|
|
58
|
+
throw new Error(`Table tableName undefined for ${id}`);
|
|
59
59
|
const table = new TableV2(scope, `${id}`, {
|
|
60
60
|
...props,
|
|
61
61
|
tableName: scope.resourceNameFormatter.format(props.tableName, scope.props.resourceNameOptions?.table),
|