@gradientedge/cdk-utils 7.21.0 → 8.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/lib/manager/aws/acm-manager.js +1 -1
- package/dist/src/lib/manager/aws/api-manager.js +2 -0
- package/dist/src/lib/manager/aws/app-config-manager.js +3 -3
- package/dist/src/lib/manager/aws/cloudfront-manager.js +4 -4
- package/dist/src/lib/manager/aws/cloudtrail-manager.js +4 -4
- package/dist/src/lib/manager/aws/cloudwatch-manager.d.ts +83 -1
- package/dist/src/lib/manager/aws/cloudwatch-manager.js +293 -7
- package/dist/src/lib/manager/aws/dynamodb-manager.js +1 -1
- package/dist/src/lib/manager/aws/ecs-manager.js +4 -4
- package/dist/src/lib/manager/aws/eks-manager.js +1 -1
- package/dist/src/lib/manager/aws/elasticache-manager.js +5 -6
- package/dist/src/lib/manager/aws/event-manager.js +4 -4
- package/dist/src/lib/manager/aws/kms-manager.js +1 -1
- package/dist/src/lib/manager/aws/log-manager.js +3 -3
- package/dist/src/lib/manager/aws/route53-manager.js +5 -5
- package/dist/src/lib/manager/aws/s3-manager.js +1 -1
- package/dist/src/lib/manager/aws/sfn-manager.js +11 -11
- package/dist/src/lib/manager/aws/sns-manager.js +2 -2
- package/dist/src/lib/manager/aws/sqs-manager.js +1 -1
- package/dist/src/lib/manager/aws/ssm-manager.js +3 -3
- package/dist/src/lib/manager/aws/vpc-manager.js +1 -1
- package/dist/src/lib/manager/aws/waf-manager.js +2 -2
- package/dist/src/lib/types/aws/index.d.ts +27 -3
- package/package.json +13 -13
- package/src/lib/manager/aws/acm-manager.ts +1 -1
- package/src/lib/manager/aws/api-manager.ts +1 -0
- package/src/lib/manager/aws/app-config-manager.ts +3 -3
- package/src/lib/manager/aws/cloudfront-manager.ts +4 -4
- package/src/lib/manager/aws/cloudtrail-manager.ts +4 -4
- package/src/lib/manager/aws/cloudwatch-manager.ts +312 -7
- package/src/lib/manager/aws/dynamodb-manager.ts +1 -1
- package/src/lib/manager/aws/ecs-manager.ts +4 -4
- package/src/lib/manager/aws/eks-manager.ts +1 -1
- package/src/lib/manager/aws/elasticache-manager.ts +5 -7
- package/src/lib/manager/aws/event-manager.ts +4 -4
- package/src/lib/manager/aws/kms-manager.ts +1 -1
- package/src/lib/manager/aws/log-manager.ts +3 -3
- package/src/lib/manager/aws/route53-manager.ts +5 -5
- package/src/lib/manager/aws/s3-manager.ts +1 -1
- package/src/lib/manager/aws/sfn-manager.ts +11 -11
- package/src/lib/manager/aws/sns-manager.ts +2 -2
- package/src/lib/manager/aws/sqs-manager.ts +1 -1
- package/src/lib/manager/aws/ssm-manager.ts +3 -3
- package/src/lib/manager/aws/vpc-manager.ts +1 -1
- package/src/lib/manager/aws/waf-manager.ts +2 -2
- package/src/lib/types/aws/index.ts +28 -3
|
@@ -69,7 +69,7 @@ class AcmManager {
|
|
|
69
69
|
*/
|
|
70
70
|
resolveCertificate(id, scope, props, hostedZone) {
|
|
71
71
|
if (!props)
|
|
72
|
-
throw `Certificate props undefined`;
|
|
72
|
+
throw `Certificate props undefined for ${id}`;
|
|
73
73
|
let certificate;
|
|
74
74
|
if (props.useExistingCertificate) {
|
|
75
75
|
let certificateArn = props.certificateArn;
|
|
@@ -56,6 +56,8 @@ class ApiManager {
|
|
|
56
56
|
* @param lambdaFunction
|
|
57
57
|
*/
|
|
58
58
|
createLambdaRestApi(id, scope, props, lambdaFunction) {
|
|
59
|
+
if (!props)
|
|
60
|
+
throw `Api props undefined for ${id}`;
|
|
59
61
|
const api = new apig.LambdaRestApi(scope, `${id}`, {
|
|
60
62
|
binaryMediaTypes: props.binaryMediaTypes,
|
|
61
63
|
minimumCompressionSize: props.minimumCompressionSize,
|
|
@@ -91,7 +91,7 @@ class AppConfigManager {
|
|
|
91
91
|
*/
|
|
92
92
|
createApplication(id, scope, props) {
|
|
93
93
|
if (!props)
|
|
94
|
-
throw `AppConfig props undefined`;
|
|
94
|
+
throw `AppConfig props undefined for ${id}`;
|
|
95
95
|
const application = new appconfig.CfnApplication(scope, `${id}`, {
|
|
96
96
|
name: `${props.application.name}-${scope.props.stage}`,
|
|
97
97
|
description: props.application.description,
|
|
@@ -111,7 +111,7 @@ class AppConfigManager {
|
|
|
111
111
|
*/
|
|
112
112
|
createEnvironment(id, scope, applicationId, props) {
|
|
113
113
|
if (!props)
|
|
114
|
-
throw `AppConfig props undefined`;
|
|
114
|
+
throw `AppConfig props undefined for ${id}`;
|
|
115
115
|
const environment = new appconfig.CfnEnvironment(scope, `${id}`, {
|
|
116
116
|
applicationId: applicationId,
|
|
117
117
|
name: scope.props.stage,
|
|
@@ -134,7 +134,7 @@ class AppConfigManager {
|
|
|
134
134
|
*/
|
|
135
135
|
createConfigurationProfile(id, scope, applicationId, props) {
|
|
136
136
|
if (!props)
|
|
137
|
-
throw `AppConfig props undefined`;
|
|
137
|
+
throw `AppConfig props undefined for ${id}`;
|
|
138
138
|
const profile = new appconfig.CfnConfigurationProfile(scope, `${id}`, {
|
|
139
139
|
applicationId: applicationId,
|
|
140
140
|
locationUri: props.configurationProfile.locationUri || 'hosted',
|
|
@@ -79,11 +79,11 @@ class CloudFrontManager {
|
|
|
79
79
|
*/
|
|
80
80
|
createCloudFrontDistribution(id, scope, props, siteBucket, logBucket, oai, certificate, aliases) {
|
|
81
81
|
if (!siteBucket)
|
|
82
|
-
throw `SiteBucket not defined`;
|
|
82
|
+
throw `SiteBucket not defined for ${id}`;
|
|
83
83
|
if (!certificate)
|
|
84
|
-
throw `Certificate not defined`;
|
|
84
|
+
throw `Certificate not defined for ${id}`;
|
|
85
85
|
if (!props)
|
|
86
|
-
throw `CloudFront props undefined`;
|
|
86
|
+
throw `CloudFront props undefined for ${id}`;
|
|
87
87
|
const distribution = new cloudfront.CloudFrontWebDistribution(scope, `${id}`, {
|
|
88
88
|
comment: `${id} - ${scope.props.stage} stage`,
|
|
89
89
|
defaultRootObject: props.defaultRootObject,
|
|
@@ -223,7 +223,7 @@ class CloudFrontManager {
|
|
|
223
223
|
*/
|
|
224
224
|
createEdgeFunction(id, scope, props, layers, code, environment, vpc, securityGroups, accessPoint, mountPath) {
|
|
225
225
|
if (!props)
|
|
226
|
-
throw
|
|
226
|
+
throw `EdgeFunction props undefined for ${id}`;
|
|
227
227
|
const edgeFunction = new cloudfront.experimental.EdgeFunction(scope, `${id}`, {
|
|
228
228
|
code: code,
|
|
229
229
|
environment: {
|
|
@@ -66,7 +66,7 @@ class CloudTrailManager {
|
|
|
66
66
|
*/
|
|
67
67
|
createCloudTrail(id, scope, props, logGroup, dataBucket, logBucket, logBucketPolicy) {
|
|
68
68
|
if (!props)
|
|
69
|
-
throw `CloudTrail props undefined`;
|
|
69
|
+
throw `CloudTrail props undefined for ${id}`;
|
|
70
70
|
const role = scope.iamManager.createRoleForCloudTrail(`${id}Role`, scope, logGroup);
|
|
71
71
|
const cloudTrail = new cloudtrail.CfnTrail(scope, `${id}`, {
|
|
72
72
|
cloudWatchLogsLogGroupArn: logGroup.attrArn,
|
|
@@ -92,9 +92,9 @@ class CloudTrailManager {
|
|
|
92
92
|
tags: [{ key: 'service', value: scope.props.name }],
|
|
93
93
|
trailName: `${props.trailName}-${scope.props.stage}`,
|
|
94
94
|
});
|
|
95
|
-
cloudTrail.
|
|
96
|
-
cloudTrail.
|
|
97
|
-
cloudTrail.
|
|
95
|
+
cloudTrail.addDependency(logBucketPolicy);
|
|
96
|
+
cloudTrail.addDependency(logGroup);
|
|
97
|
+
cloudTrail.addDependency(role);
|
|
98
98
|
utils.createCfnOutput(`${id}-trailName`, scope, cloudTrail.trailName);
|
|
99
99
|
utils.createCfnOutput(`${id}-trailArn`, scope, cloudTrail.attrArn);
|
|
100
100
|
return { cloudTrailRole: role, cloudTrail };
|
|
@@ -59,7 +59,81 @@ export declare class CloudWatchManager {
|
|
|
59
59
|
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
60
60
|
* @param props
|
|
61
61
|
*/
|
|
62
|
-
createWidget(id: string, scope: common.CommonConstruct, props: any): cdk.aws_cloudwatch.GraphWidget | cdk.aws_cloudwatch.SingleValueWidget | cdk.aws_cloudwatch.LogQueryWidget | cdk.aws_cloudwatch.TextWidget | cdk.aws_cloudwatch.AlarmStatusWidget;
|
|
62
|
+
createWidget(id: string, scope: common.CommonConstruct, props: any): cdk.aws_cloudwatch.GaugeWidget | cdk.aws_cloudwatch.GraphWidget | cdk.aws_cloudwatch.SingleValueWidget | cdk.aws_cloudwatch.LogQueryWidget | cdk.aws_cloudwatch.TextWidget | cdk.aws_cloudwatch.AlarmStatusWidget;
|
|
63
|
+
/**
|
|
64
|
+
* @summary Method to create a cloudfront distribution widget
|
|
65
|
+
* @param {string} id scoped id of the resource
|
|
66
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
67
|
+
* @param {types.TextWidgetProps} props
|
|
68
|
+
* @param {string} distributionId the cloudfront distribution id
|
|
69
|
+
*/
|
|
70
|
+
createCloudfrontDistributionWidget(id: string, scope: common.CommonConstruct, props: any, distributionId: string): cdk.aws_cloudwatch.GaugeWidget | cdk.aws_cloudwatch.GraphWidget | cdk.aws_cloudwatch.SingleValueWidget | cdk.aws_cloudwatch.LogQueryWidget | cdk.aws_cloudwatch.TextWidget | cdk.aws_cloudwatch.AlarmStatusWidget;
|
|
71
|
+
/**
|
|
72
|
+
* @summary Method to create a step function widget
|
|
73
|
+
* @param {string} id scoped id of the resource
|
|
74
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
75
|
+
* @param {types.TextWidgetProps} props
|
|
76
|
+
* @param {string} stateMachineArn the step function arn
|
|
77
|
+
*/
|
|
78
|
+
createStateWidget(id: string, scope: common.CommonConstruct, props: any, stateMachineArn: string): cdk.aws_cloudwatch.GaugeWidget | cdk.aws_cloudwatch.GraphWidget | cdk.aws_cloudwatch.SingleValueWidget | cdk.aws_cloudwatch.LogQueryWidget | cdk.aws_cloudwatch.TextWidget | cdk.aws_cloudwatch.AlarmStatusWidget;
|
|
79
|
+
/**
|
|
80
|
+
* @summary Method to create an event widget
|
|
81
|
+
* @param {string} id scoped id of the resource
|
|
82
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
83
|
+
* @param {types.TextWidgetProps} props
|
|
84
|
+
* @param {string} eventBusName the event bus name
|
|
85
|
+
* @param {string} ruleName the event rule name
|
|
86
|
+
*/
|
|
87
|
+
createEventWidget(id: string, scope: common.CommonConstruct, props: any, eventBusName: string, ruleName: string): cdk.aws_cloudwatch.GaugeWidget | cdk.aws_cloudwatch.GraphWidget | cdk.aws_cloudwatch.SingleValueWidget | cdk.aws_cloudwatch.LogQueryWidget | cdk.aws_cloudwatch.TextWidget | cdk.aws_cloudwatch.AlarmStatusWidget;
|
|
88
|
+
/**
|
|
89
|
+
* @summary Method to create an api gateway widget
|
|
90
|
+
* @param {string} id scoped id of the resource
|
|
91
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
92
|
+
* @param {types.TextWidgetProps} props
|
|
93
|
+
* @param {string} apiName the api name
|
|
94
|
+
*/
|
|
95
|
+
createApiGatewayWidget(id: string, scope: common.CommonConstruct, props: any, apiName: string): cdk.aws_cloudwatch.GaugeWidget | cdk.aws_cloudwatch.GraphWidget | cdk.aws_cloudwatch.SingleValueWidget | cdk.aws_cloudwatch.LogQueryWidget | cdk.aws_cloudwatch.TextWidget | cdk.aws_cloudwatch.AlarmStatusWidget;
|
|
96
|
+
/**
|
|
97
|
+
* @summary Method to create a lambda function widget
|
|
98
|
+
* @param {string} id scoped id of the resource
|
|
99
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
100
|
+
* @param {types.TextWidgetProps} props
|
|
101
|
+
* @param {string} functionName the lambda function name
|
|
102
|
+
*/
|
|
103
|
+
createLambdaWidget(id: string, scope: common.CommonConstruct, props: any, functionName: string): cdk.aws_cloudwatch.GaugeWidget | cdk.aws_cloudwatch.GraphWidget | cdk.aws_cloudwatch.SingleValueWidget | cdk.aws_cloudwatch.LogQueryWidget | cdk.aws_cloudwatch.TextWidget | cdk.aws_cloudwatch.AlarmStatusWidget;
|
|
104
|
+
/**
|
|
105
|
+
* @summary Method to create an ecs cluster widget
|
|
106
|
+
* @param {string} id scoped id of the resource
|
|
107
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
108
|
+
* @param {types.TextWidgetProps} props
|
|
109
|
+
* @param {string} clusterName the ecs cluster name
|
|
110
|
+
*/
|
|
111
|
+
createEcsClusterWidget(id: string, scope: common.CommonConstruct, props: any, clusterName: string): cdk.aws_cloudwatch.GaugeWidget | cdk.aws_cloudwatch.GraphWidget | cdk.aws_cloudwatch.SingleValueWidget | cdk.aws_cloudwatch.LogQueryWidget | cdk.aws_cloudwatch.TextWidget | cdk.aws_cloudwatch.AlarmStatusWidget;
|
|
112
|
+
/**
|
|
113
|
+
* @summary Method to create an ecs service widget
|
|
114
|
+
* @param {string} id scoped id of the resource
|
|
115
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
116
|
+
* @param {types.TextWidgetProps} props
|
|
117
|
+
* @param {string} clusterName the ecs cluster name
|
|
118
|
+
* @param {string} serviceName the ecs service name
|
|
119
|
+
*/
|
|
120
|
+
createEcsServiceWidget(id: string, scope: common.CommonConstruct, props: any, clusterName: string, serviceName: string): cdk.aws_cloudwatch.GaugeWidget | cdk.aws_cloudwatch.GraphWidget | cdk.aws_cloudwatch.SingleValueWidget | cdk.aws_cloudwatch.LogQueryWidget | cdk.aws_cloudwatch.TextWidget | cdk.aws_cloudwatch.AlarmStatusWidget;
|
|
121
|
+
/**
|
|
122
|
+
* @summary Method to create an elb widget
|
|
123
|
+
* @param {string} id scoped id of the resource
|
|
124
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
125
|
+
* @param {types.TextWidgetProps} props
|
|
126
|
+
* @param {string} loadBalancer the loadbalancer reference
|
|
127
|
+
*/
|
|
128
|
+
createElbWidget(id: string, scope: common.CommonConstruct, props: any, loadBalancer: string): cdk.aws_cloudwatch.GaugeWidget | cdk.aws_cloudwatch.GraphWidget | cdk.aws_cloudwatch.SingleValueWidget | cdk.aws_cloudwatch.LogQueryWidget | cdk.aws_cloudwatch.TextWidget | cdk.aws_cloudwatch.AlarmStatusWidget;
|
|
129
|
+
/**
|
|
130
|
+
* @summary Method to create an elasticache widget
|
|
131
|
+
* @param {string} id scoped id of the resource
|
|
132
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
133
|
+
* @param {types.TextWidgetProps} props
|
|
134
|
+
* @param {string} cacheClusterId the elasticache cluster id
|
|
135
|
+
*/
|
|
136
|
+
createCacheWidget(id: string, scope: common.CommonConstruct, props: any, cacheClusterId: string): cdk.aws_cloudwatch.GaugeWidget | cdk.aws_cloudwatch.GraphWidget | cdk.aws_cloudwatch.SingleValueWidget | cdk.aws_cloudwatch.LogQueryWidget | cdk.aws_cloudwatch.TextWidget | cdk.aws_cloudwatch.AlarmStatusWidget;
|
|
63
137
|
/**
|
|
64
138
|
* @summary Method to create a cloudwatch text widget
|
|
65
139
|
* @param {string} id scoped id of the resource
|
|
@@ -75,6 +149,14 @@ export declare class CloudWatchManager {
|
|
|
75
149
|
* @param metrics
|
|
76
150
|
*/
|
|
77
151
|
createSingleValueWidget(id: string, scope: common.CommonConstruct, props: types.NumericWidgetProps, metrics: IMetric[]): cdk.aws_cloudwatch.SingleValueWidget;
|
|
152
|
+
/**
|
|
153
|
+
* @summary Method to create a cloudwatch guage widget
|
|
154
|
+
* @param {string} id scoped id of the resource
|
|
155
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
156
|
+
* @param {types.GuageWidgetProps} props
|
|
157
|
+
* @param metrics
|
|
158
|
+
*/
|
|
159
|
+
createGuageWidget(id: string, scope: common.CommonConstruct, props: types.GuageWidgetProps, metrics: IMetric[]): cdk.aws_cloudwatch.GaugeWidget;
|
|
78
160
|
/**
|
|
79
161
|
* @summary Method to create a cloudwatch graph widget
|
|
80
162
|
* @param {string} id scoped id of the resource
|
|
@@ -35,6 +35,7 @@ var CloudWatchWidgetType;
|
|
|
35
35
|
(function (CloudWatchWidgetType) {
|
|
36
36
|
CloudWatchWidgetType["Text"] = "Text";
|
|
37
37
|
CloudWatchWidgetType["SingleValue"] = "SingleValue";
|
|
38
|
+
CloudWatchWidgetType["Gauge"] = "Gauge";
|
|
38
39
|
CloudWatchWidgetType["Graph"] = "Graph";
|
|
39
40
|
CloudWatchWidgetType["AlarmStatus"] = "AlarmStatus";
|
|
40
41
|
CloudWatchWidgetType["LogQuery"] = "LogQuery";
|
|
@@ -68,7 +69,7 @@ class CloudWatchManager {
|
|
|
68
69
|
*/
|
|
69
70
|
createAlarmForExpression(id, scope, props) {
|
|
70
71
|
if (!props)
|
|
71
|
-
throw `Alarm props undefined`;
|
|
72
|
+
throw `Alarm props undefined for ${id}`;
|
|
72
73
|
if (!props.expression)
|
|
73
74
|
throw `Could not find expression for Alarm props for id:${id}`;
|
|
74
75
|
if (!props.metricProps)
|
|
@@ -102,7 +103,7 @@ class CloudWatchManager {
|
|
|
102
103
|
*/
|
|
103
104
|
createAlarmForMetric(id, scope, props, metric) {
|
|
104
105
|
if (!props)
|
|
105
|
-
throw `Alarm props undefined`;
|
|
106
|
+
throw `Alarm props undefined for ${id}`;
|
|
106
107
|
const alarm = metric.createAlarm(scope, `${id}`, {
|
|
107
108
|
alarmName: props.alarmName,
|
|
108
109
|
alarmDescription: props.alarmDescription,
|
|
@@ -125,7 +126,7 @@ class CloudWatchManager {
|
|
|
125
126
|
*/
|
|
126
127
|
createDashboard(id, scope, props, widgets) {
|
|
127
128
|
if (!props)
|
|
128
|
-
throw `Dashboard props undefined`;
|
|
129
|
+
throw `Dashboard props undefined for ${id}`;
|
|
129
130
|
const dashboard = new watch.Dashboard(scope, `${id}`, {
|
|
130
131
|
dashboardName: props.dashboardName,
|
|
131
132
|
periodOverride: props.periodOverride,
|
|
@@ -156,7 +157,7 @@ class CloudWatchManager {
|
|
|
156
157
|
*/
|
|
157
158
|
createWidget(id, scope, props) {
|
|
158
159
|
if (!props)
|
|
159
|
-
throw `Widget props undefined`;
|
|
160
|
+
throw `Widget props undefined for ${id}`;
|
|
160
161
|
const metrics = this.determineMetrics(scope, props.metricProps);
|
|
161
162
|
let alarms, logGroupNames = [];
|
|
162
163
|
switch (props.type) {
|
|
@@ -164,6 +165,8 @@ class CloudWatchManager {
|
|
|
164
165
|
return this.createTextWidget(id, scope, props);
|
|
165
166
|
case CloudWatchWidgetType.SingleValue:
|
|
166
167
|
return this.createSingleValueWidget(id, scope, props, metrics);
|
|
168
|
+
case CloudWatchWidgetType.Gauge:
|
|
169
|
+
return this.createGuageWidget(id, scope, props, metrics);
|
|
167
170
|
case CloudWatchWidgetType.Graph:
|
|
168
171
|
return this.createGraphWidget(id, scope, props, metrics);
|
|
169
172
|
case CloudWatchWidgetType.AlarmStatus:
|
|
@@ -173,9 +176,179 @@ class CloudWatchManager {
|
|
|
173
176
|
logGroupNames = props.logGroupNames.map((name) => `${name}-${scope.props.stage}`);
|
|
174
177
|
return this.createLogQueryWidget(id, scope, props, logGroupNames);
|
|
175
178
|
default:
|
|
176
|
-
throw
|
|
179
|
+
throw `Unsupported widget type ${props.type}`;
|
|
177
180
|
}
|
|
178
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* @summary Method to create a cloudfront distribution widget
|
|
184
|
+
* @param {string} id scoped id of the resource
|
|
185
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
186
|
+
* @param {types.TextWidgetProps} props
|
|
187
|
+
* @param {string} distributionId the cloudfront distribution id
|
|
188
|
+
*/
|
|
189
|
+
createCloudfrontDistributionWidget(id, scope, props, distributionId) {
|
|
190
|
+
if (!props)
|
|
191
|
+
throw `Widget props undefined for ${id}`;
|
|
192
|
+
const metricProps = props.metricProps;
|
|
193
|
+
return this.createWidget(id, scope, {
|
|
194
|
+
...props,
|
|
195
|
+
...{
|
|
196
|
+
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ distributionId: distributionId } })),
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* @summary Method to create a step function widget
|
|
202
|
+
* @param {string} id scoped id of the resource
|
|
203
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
204
|
+
* @param {types.TextWidgetProps} props
|
|
205
|
+
* @param {string} stateMachineArn the step function arn
|
|
206
|
+
*/
|
|
207
|
+
createStateWidget(id, scope, props, stateMachineArn) {
|
|
208
|
+
if (!props)
|
|
209
|
+
throw `Widget props undefined for ${id}`;
|
|
210
|
+
const metricProps = props.metricProps;
|
|
211
|
+
return this.createWidget(id, scope, {
|
|
212
|
+
...props,
|
|
213
|
+
...{
|
|
214
|
+
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ stateMachineArn: stateMachineArn } })),
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* @summary Method to create an event widget
|
|
220
|
+
* @param {string} id scoped id of the resource
|
|
221
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
222
|
+
* @param {types.TextWidgetProps} props
|
|
223
|
+
* @param {string} eventBusName the event bus name
|
|
224
|
+
* @param {string} ruleName the event rule name
|
|
225
|
+
*/
|
|
226
|
+
createEventWidget(id, scope, props, eventBusName, ruleName) {
|
|
227
|
+
if (!props)
|
|
228
|
+
throw `Widget props undefined for ${id}`;
|
|
229
|
+
const metricProps = props.metricProps;
|
|
230
|
+
return this.createWidget(id, scope, {
|
|
231
|
+
...props,
|
|
232
|
+
...{
|
|
233
|
+
metricProps: metricProps.map(metricProp => ({
|
|
234
|
+
...metricProp,
|
|
235
|
+
...{ eventBusName: eventBusName, ruleName: ruleName },
|
|
236
|
+
})),
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* @summary Method to create an api gateway widget
|
|
242
|
+
* @param {string} id scoped id of the resource
|
|
243
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
244
|
+
* @param {types.TextWidgetProps} props
|
|
245
|
+
* @param {string} apiName the api name
|
|
246
|
+
*/
|
|
247
|
+
createApiGatewayWidget(id, scope, props, apiName) {
|
|
248
|
+
if (!props)
|
|
249
|
+
throw `Widget props undefined for ${id}`;
|
|
250
|
+
const metricProps = props.metricProps;
|
|
251
|
+
return this.createWidget(id, scope, {
|
|
252
|
+
...props,
|
|
253
|
+
...{
|
|
254
|
+
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ apiName: apiName } })),
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* @summary Method to create a lambda function widget
|
|
260
|
+
* @param {string} id scoped id of the resource
|
|
261
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
262
|
+
* @param {types.TextWidgetProps} props
|
|
263
|
+
* @param {string} functionName the lambda function name
|
|
264
|
+
*/
|
|
265
|
+
createLambdaWidget(id, scope, props, functionName) {
|
|
266
|
+
if (!props)
|
|
267
|
+
throw `Widget props undefined for ${id}`;
|
|
268
|
+
const metricProps = props.metricProps;
|
|
269
|
+
return this.createWidget(id, scope, {
|
|
270
|
+
...props,
|
|
271
|
+
...{
|
|
272
|
+
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ functionName: functionName } })),
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* @summary Method to create an ecs cluster widget
|
|
278
|
+
* @param {string} id scoped id of the resource
|
|
279
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
280
|
+
* @param {types.TextWidgetProps} props
|
|
281
|
+
* @param {string} clusterName the ecs cluster name
|
|
282
|
+
*/
|
|
283
|
+
createEcsClusterWidget(id, scope, props, clusterName) {
|
|
284
|
+
if (!props)
|
|
285
|
+
throw `Widget props undefined for ${id}`;
|
|
286
|
+
const metricProps = props.metricProps;
|
|
287
|
+
return this.createWidget(id, scope, {
|
|
288
|
+
...props,
|
|
289
|
+
...{
|
|
290
|
+
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ clusterName: clusterName } })),
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* @summary Method to create an ecs service widget
|
|
296
|
+
* @param {string} id scoped id of the resource
|
|
297
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
298
|
+
* @param {types.TextWidgetProps} props
|
|
299
|
+
* @param {string} clusterName the ecs cluster name
|
|
300
|
+
* @param {string} serviceName the ecs service name
|
|
301
|
+
*/
|
|
302
|
+
createEcsServiceWidget(id, scope, props, clusterName, serviceName) {
|
|
303
|
+
if (!props)
|
|
304
|
+
throw `Widget props undefined for ${id}`;
|
|
305
|
+
const metricProps = props.metricProps;
|
|
306
|
+
return this.createWidget(id, scope, {
|
|
307
|
+
...props,
|
|
308
|
+
...{
|
|
309
|
+
metricProps: metricProps.map(metricProp => ({
|
|
310
|
+
...metricProp,
|
|
311
|
+
...{ clusterName: clusterName, serviceName: serviceName },
|
|
312
|
+
})),
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* @summary Method to create an elb widget
|
|
318
|
+
* @param {string} id scoped id of the resource
|
|
319
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
320
|
+
* @param {types.TextWidgetProps} props
|
|
321
|
+
* @param {string} loadBalancer the loadbalancer reference
|
|
322
|
+
*/
|
|
323
|
+
createElbWidget(id, scope, props, loadBalancer) {
|
|
324
|
+
if (!props)
|
|
325
|
+
throw `Widget props undefined for ${id}`;
|
|
326
|
+
const metricProps = props.metricProps;
|
|
327
|
+
return this.createWidget(id, scope, {
|
|
328
|
+
...props,
|
|
329
|
+
...{
|
|
330
|
+
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ loadBalancer: loadBalancer } })),
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* @summary Method to create an elasticache widget
|
|
336
|
+
* @param {string} id scoped id of the resource
|
|
337
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
338
|
+
* @param {types.TextWidgetProps} props
|
|
339
|
+
* @param {string} cacheClusterId the elasticache cluster id
|
|
340
|
+
*/
|
|
341
|
+
createCacheWidget(id, scope, props, cacheClusterId) {
|
|
342
|
+
if (!props)
|
|
343
|
+
throw `Widget props undefined for ${id}`;
|
|
344
|
+
const metricProps = props.metricProps;
|
|
345
|
+
return this.createWidget(id, scope, {
|
|
346
|
+
...props,
|
|
347
|
+
...{
|
|
348
|
+
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ cacheClusterId: cacheClusterId } })),
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
}
|
|
179
352
|
/**
|
|
180
353
|
* @summary Method to create a cloudwatch text widget
|
|
181
354
|
* @param {string} id scoped id of the resource
|
|
@@ -183,6 +356,8 @@ class CloudWatchManager {
|
|
|
183
356
|
* @param {types.TextWidgetProps} props
|
|
184
357
|
*/
|
|
185
358
|
createTextWidget(id, scope, props) {
|
|
359
|
+
if (!props)
|
|
360
|
+
throw `Widget props undefined for ${id}`;
|
|
186
361
|
const widget = new watch.TextWidget({
|
|
187
362
|
markdown: props.markdown,
|
|
188
363
|
width: props.width,
|
|
@@ -200,10 +375,38 @@ class CloudWatchManager {
|
|
|
200
375
|
* @param metrics
|
|
201
376
|
*/
|
|
202
377
|
createSingleValueWidget(id, scope, props, metrics) {
|
|
378
|
+
if (!props)
|
|
379
|
+
throw `Widget props undefined for ${id}`;
|
|
203
380
|
const widget = new watch.SingleValueWidget({
|
|
381
|
+
region: props.region ?? scope.props.region,
|
|
204
382
|
metrics: metrics,
|
|
205
383
|
setPeriodToTimeRange: props.setPeriodToTimeRange,
|
|
206
384
|
fullPrecision: props.fullPrecision,
|
|
385
|
+
sparkline: props.sparkline,
|
|
386
|
+
title: props.title,
|
|
387
|
+
width: props.width,
|
|
388
|
+
height: props.height,
|
|
389
|
+
});
|
|
390
|
+
if (props.positionX && props.positionY)
|
|
391
|
+
widget.position(props.positionX, props.positionY);
|
|
392
|
+
return widget;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* @summary Method to create a cloudwatch guage widget
|
|
396
|
+
* @param {string} id scoped id of the resource
|
|
397
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
398
|
+
* @param {types.GuageWidgetProps} props
|
|
399
|
+
* @param metrics
|
|
400
|
+
*/
|
|
401
|
+
createGuageWidget(id, scope, props, metrics) {
|
|
402
|
+
if (!props)
|
|
403
|
+
throw `Widget props undefined for ${id}`;
|
|
404
|
+
const widget = new watch.GaugeWidget({
|
|
405
|
+
region: props.region ?? scope.props.region,
|
|
406
|
+
metrics: metrics,
|
|
407
|
+
leftYAxis: props.leftYAxis,
|
|
408
|
+
statistic: props.statistic,
|
|
409
|
+
setPeriodToTimeRange: props.setPeriodToTimeRange,
|
|
207
410
|
title: props.title,
|
|
208
411
|
width: props.width,
|
|
209
412
|
height: props.height,
|
|
@@ -221,7 +424,10 @@ class CloudWatchManager {
|
|
|
221
424
|
* @param rightYMetrics
|
|
222
425
|
*/
|
|
223
426
|
createGraphWidget(id, scope, props, leftYMetrics, rightYMetrics) {
|
|
427
|
+
if (!props)
|
|
428
|
+
throw `Widget props undefined for ${id}`;
|
|
224
429
|
const widget = new watch.GraphWidget({
|
|
430
|
+
region: props.region ?? scope.props.region,
|
|
225
431
|
left: leftYMetrics,
|
|
226
432
|
right: rightYMetrics,
|
|
227
433
|
leftAnnotations: props.leftAnnotations,
|
|
@@ -248,6 +454,8 @@ class CloudWatchManager {
|
|
|
248
454
|
* @param {watch.IAlarm[]} alarms
|
|
249
455
|
*/
|
|
250
456
|
createAlarmStatusWidget(id, scope, props, alarms) {
|
|
457
|
+
if (!props)
|
|
458
|
+
throw `Widget props undefined for ${id}`;
|
|
251
459
|
const widget = new watch.AlarmStatusWidget({
|
|
252
460
|
alarms: alarms,
|
|
253
461
|
title: props.title,
|
|
@@ -266,7 +474,10 @@ class CloudWatchManager {
|
|
|
266
474
|
* @param {string[]} logGroupNames
|
|
267
475
|
*/
|
|
268
476
|
createLogQueryWidget(id, scope, props, logGroupNames) {
|
|
477
|
+
if (!props)
|
|
478
|
+
throw `Widget props undefined for ${id}`;
|
|
269
479
|
const widget = new watch.LogQueryWidget({
|
|
480
|
+
region: props.region ?? scope.props.region,
|
|
270
481
|
logGroupNames: logGroupNames,
|
|
271
482
|
queryString: props.queryString,
|
|
272
483
|
queryLines: props.queryLines,
|
|
@@ -293,7 +504,65 @@ class CloudWatchManager {
|
|
|
293
504
|
metricDimensions = {
|
|
294
505
|
...metricProp.dimensionsMap,
|
|
295
506
|
...{
|
|
296
|
-
FunctionName: `${metricProp.functionName}
|
|
507
|
+
FunctionName: `${metricProp.functionName}`,
|
|
508
|
+
},
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
if (metricProp.serviceName && metricProp.clusterName) {
|
|
512
|
+
metricDimensions = {
|
|
513
|
+
...metricProp.dimensionsMap,
|
|
514
|
+
...{
|
|
515
|
+
ServiceName: `${metricProp.serviceName}`,
|
|
516
|
+
ClusterName: `${metricProp.clusterName}`,
|
|
517
|
+
},
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
if (!metricProp.serviceName && metricProp.clusterName) {
|
|
521
|
+
metricDimensions = {
|
|
522
|
+
...metricProp.dimensionsMap,
|
|
523
|
+
...{
|
|
524
|
+
ClusterName: `${metricProp.clusterName}`,
|
|
525
|
+
},
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
if (metricProp.serviceName && !metricProp.clusterName) {
|
|
529
|
+
metricDimensions = {
|
|
530
|
+
...metricProp.dimensionsMap,
|
|
531
|
+
...{
|
|
532
|
+
ServiceName: `${metricProp.serviceName}`,
|
|
533
|
+
},
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
if (metricProp.loadBalancer) {
|
|
537
|
+
metricDimensions = {
|
|
538
|
+
...metricProp.dimensionsMap,
|
|
539
|
+
...{
|
|
540
|
+
LoadBalancer: `${metricProp.loadBalancer}`,
|
|
541
|
+
},
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
if (metricProp.distributionId) {
|
|
545
|
+
metricDimensions = {
|
|
546
|
+
...metricProp.dimensionsMap,
|
|
547
|
+
...{
|
|
548
|
+
Region: `Global`,
|
|
549
|
+
DistributionId: `${metricProp.distributionId}`,
|
|
550
|
+
},
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
if (metricProp.apiName) {
|
|
554
|
+
metricDimensions = {
|
|
555
|
+
...metricProp.dimensionsMap,
|
|
556
|
+
...{
|
|
557
|
+
ApiName: `${metricProp.apiName}`,
|
|
558
|
+
},
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
if (metricProp.cacheClusterId) {
|
|
562
|
+
metricDimensions = {
|
|
563
|
+
...metricProp.dimensionsMap,
|
|
564
|
+
...{
|
|
565
|
+
CacheClusterId: `${metricProp.cacheClusterId}`,
|
|
297
566
|
},
|
|
298
567
|
};
|
|
299
568
|
}
|
|
@@ -301,7 +570,24 @@ class CloudWatchManager {
|
|
|
301
570
|
metricDimensions = {
|
|
302
571
|
...metricProp.dimensionsMap,
|
|
303
572
|
...{
|
|
304
|
-
DBClusterIdentifier: `${metricProp.dbClusterIdentifier}
|
|
573
|
+
DBClusterIdentifier: `${metricProp.dbClusterIdentifier}`,
|
|
574
|
+
},
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
if (metricProp.stateMachineArn) {
|
|
578
|
+
metricDimensions = {
|
|
579
|
+
...metricProp.dimensionsMap,
|
|
580
|
+
...{
|
|
581
|
+
StateMachineArn: `${metricProp.stateMachineArn}`,
|
|
582
|
+
},
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
if (metricProp.eventBusName && metricProp.ruleName) {
|
|
586
|
+
metricDimensions = {
|
|
587
|
+
...metricProp.dimensionsMap,
|
|
588
|
+
...{
|
|
589
|
+
EventBusName: `${metricProp.eventBusName}`,
|
|
590
|
+
RuleName: `${metricProp.ruleName}`,
|
|
305
591
|
},
|
|
306
592
|
};
|
|
307
593
|
}
|
|
@@ -55,7 +55,7 @@ class DynamodbManager {
|
|
|
55
55
|
*/
|
|
56
56
|
createTable(id, scope, props) {
|
|
57
57
|
if (!props)
|
|
58
|
-
throw `Table props undefined`;
|
|
58
|
+
throw `Table props undefined for ${id}`;
|
|
59
59
|
const table = new dynamodb.Table(scope, `${id}`, {
|
|
60
60
|
tableName: `${props.tableName}-${scope.props.stage}`,
|
|
61
61
|
partitionKey: props.partitionKey,
|
|
@@ -58,7 +58,7 @@ class EcsManager {
|
|
|
58
58
|
*/
|
|
59
59
|
createEcsCluster(id, scope, props, vpc) {
|
|
60
60
|
if (!props)
|
|
61
|
-
throw `Ecs Cluster props undefined`;
|
|
61
|
+
throw `Ecs Cluster props undefined for ${id}`;
|
|
62
62
|
const ecsCluster = new ecs.Cluster(scope, `${id}`, {
|
|
63
63
|
clusterName: `${props.clusterName}-${scope.props.stage}`,
|
|
64
64
|
vpc: vpc,
|
|
@@ -86,7 +86,7 @@ class EcsManager {
|
|
|
86
86
|
*/
|
|
87
87
|
createEcsFargateTask(id, scope, props, cluster, role, logGroup, containerImage, environment, secrets) {
|
|
88
88
|
if (!props)
|
|
89
|
-
throw `EcsTask props undefined`;
|
|
89
|
+
throw `EcsTask props undefined for ${id}`;
|
|
90
90
|
const ecsTask = new ecs.TaskDefinition(scope, `${id}`, {
|
|
91
91
|
compatibility: ecs.Compatibility.FARGATE,
|
|
92
92
|
cpu: props.cpu,
|
|
@@ -133,9 +133,9 @@ class EcsManager {
|
|
|
133
133
|
*/
|
|
134
134
|
createLoadBalancedFargateService(id, scope, props, cluster, logGroup) {
|
|
135
135
|
if (!props)
|
|
136
|
-
throw `EcsLoadbalanced Fargate Serivice props undefined`;
|
|
136
|
+
throw `EcsLoadbalanced Fargate Serivice props undefined for ${id}`;
|
|
137
137
|
if (!props.taskImageOptions)
|
|
138
|
-
throw `TaskImageOptions for EcsLoadbalanced Fargate Serivice props undefined`;
|
|
138
|
+
throw `TaskImageOptions for EcsLoadbalanced Fargate Serivice props undefined for ${id}`;
|
|
139
139
|
const fargateService = new ecsPatterns.ApplicationLoadBalancedFargateService(scope, `${id}-ecs-service`, {
|
|
140
140
|
assignPublicIp: props.assignPublicIp ?? true,
|
|
141
141
|
certificate: props.certificate,
|
|
@@ -58,7 +58,7 @@ class EksManager {
|
|
|
58
58
|
*/
|
|
59
59
|
createEksDeployment(id, scope, props, image, vpc) {
|
|
60
60
|
if (!props)
|
|
61
|
-
throw `EksCluster props undefined`;
|
|
61
|
+
throw `EksCluster props undefined for ${id}`;
|
|
62
62
|
const appLabel = { app: `${id}`.toLowerCase() };
|
|
63
63
|
const deployment = {
|
|
64
64
|
apiVersion: 'apps/v1',
|