@gradientedge/cdk-utils 5.0.0 → 5.1.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/common/construct.d.ts +1 -0
- package/dist/src/lib/common/construct.js +2 -0
- package/dist/src/lib/manager/aws/event-target-manager.d.ts +60 -0
- package/dist/src/lib/manager/aws/event-target-manager.js +91 -0
- package/dist/src/lib/manager/aws/index.d.ts +1 -0
- package/dist/src/lib/manager/aws/index.js +1 -0
- package/package.json +1 -1
- package/src/lib/common/construct.ts +2 -0
- package/src/lib/manager/aws/event-target-manager.ts +84 -0
- package/src/lib/manager/aws/index.ts +1 -0
|
@@ -33,6 +33,7 @@ export declare class CommonConstruct extends Construct {
|
|
|
33
33
|
eksManager: aws.EksManager;
|
|
34
34
|
elasticacheManager: aws.ElastiCacheManager;
|
|
35
35
|
eventManager: aws.EventManager;
|
|
36
|
+
eventTargetManager: aws.EventTargetManager;
|
|
36
37
|
iamManager: aws.IamManager;
|
|
37
38
|
kmsManager: aws.KmsManager;
|
|
38
39
|
lambdaManager: aws.LambdaManager;
|
|
@@ -58,6 +58,7 @@ class CommonConstruct extends constructs_1.Construct {
|
|
|
58
58
|
eksManager;
|
|
59
59
|
elasticacheManager;
|
|
60
60
|
eventManager;
|
|
61
|
+
eventTargetManager;
|
|
61
62
|
iamManager;
|
|
62
63
|
kmsManager;
|
|
63
64
|
lambdaManager;
|
|
@@ -88,6 +89,7 @@ class CommonConstruct extends constructs_1.Construct {
|
|
|
88
89
|
this.eksManager = new aws.EksManager();
|
|
89
90
|
this.elasticacheManager = new aws.ElastiCacheManager();
|
|
90
91
|
this.eventManager = new aws.EventManager();
|
|
92
|
+
this.eventTargetManager = new aws.EventTargetManager();
|
|
91
93
|
this.iamManager = new aws.IamManager();
|
|
92
94
|
this.kmsManager = new aws.KmsManager();
|
|
93
95
|
this.lambdaManager = new aws.LambdaManager();
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as events from 'aws-cdk-lib/aws-events';
|
|
2
|
+
import * as targets from 'aws-cdk-lib/aws-events-targets';
|
|
3
|
+
import * as logs from 'aws-cdk-lib/aws-logs';
|
|
4
|
+
import * as common from '../../common';
|
|
5
|
+
/**
|
|
6
|
+
* @stability stable
|
|
7
|
+
* @category cdk-utils.event-taeget-manager
|
|
8
|
+
* @subcategory Construct
|
|
9
|
+
* @classdesc Provides operations on AWS EventBridge Targets.
|
|
10
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
11
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
12
|
+
* @example
|
|
13
|
+
* import * as common from '@gradientedge/cdk-utils'
|
|
14
|
+
*
|
|
15
|
+
* class CustomConstruct extends common.common.CommonConstruct {
|
|
16
|
+
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
17
|
+
* super(parent, id, props)
|
|
18
|
+
* this.props = props
|
|
19
|
+
* this.eventTargetManager.createCloudWatchLogGroupNoPolicy('MyLogGrouptarget', this, myLogGroup)
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* @see [CDK EventBridge Target Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_events_targets-readme.html}
|
|
24
|
+
*/
|
|
25
|
+
export declare class EventTargetManager {
|
|
26
|
+
/**
|
|
27
|
+
* @summary Method to create a cloud watch log group target without a policy.
|
|
28
|
+
* - This method is created as a workaround for cdk issue - https://github.com/aws/aws-cdk/issues/17002
|
|
29
|
+
* @param {string} id scoped id of the resource
|
|
30
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
31
|
+
* @param {logs.ILogGroup} logGroup the log group
|
|
32
|
+
* @param {LogGroupNoPolicyProps} props the log group target properties
|
|
33
|
+
*/
|
|
34
|
+
createCloudWatchLogGroupNoPolicy(id: string, scope: common.CommonConstruct, logGroup: logs.ILogGroup, props?: LogGroupNoPolicyProps): CloudWatchLogGroupNoPolicy;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Customize the CloudWatch LogGroup Event Target
|
|
38
|
+
*/
|
|
39
|
+
export interface LogGroupNoPolicyProps extends targets.TargetBaseProps {
|
|
40
|
+
/**
|
|
41
|
+
* The event to send to the CloudWatch LogGroup
|
|
42
|
+
*
|
|
43
|
+
* This will be the event logged into the CloudWatch LogGroup
|
|
44
|
+
*
|
|
45
|
+
* @default - the entire EventBridge event
|
|
46
|
+
*/
|
|
47
|
+
readonly event?: events.RuleTargetInput;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Use an AWS CloudWatch LogGroup as an event rule target, but don't apply a policy.
|
|
51
|
+
*/
|
|
52
|
+
export declare class CloudWatchLogGroupNoPolicy implements events.IRuleTarget {
|
|
53
|
+
private readonly logGroup;
|
|
54
|
+
private readonly props;
|
|
55
|
+
constructor(logGroup: logs.ILogGroup, props?: LogGroupNoPolicyProps);
|
|
56
|
+
/**
|
|
57
|
+
* Returns a RuleTarget that can be used to log an event into a CloudWatch LogGroup
|
|
58
|
+
*/
|
|
59
|
+
bind(_rule: events.IRule, _id?: string): events.RuleTargetConfig;
|
|
60
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.CloudWatchLogGroupNoPolicy = exports.EventTargetManager = void 0;
|
|
27
|
+
const cdk = __importStar(require("aws-cdk-lib"));
|
|
28
|
+
const targets = __importStar(require("aws-cdk-lib/aws-events-targets"));
|
|
29
|
+
/**
|
|
30
|
+
* @stability stable
|
|
31
|
+
* @category cdk-utils.event-taeget-manager
|
|
32
|
+
* @subcategory Construct
|
|
33
|
+
* @classdesc Provides operations on AWS EventBridge Targets.
|
|
34
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
35
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
36
|
+
* @example
|
|
37
|
+
* import * as common from '@gradientedge/cdk-utils'
|
|
38
|
+
*
|
|
39
|
+
* class CustomConstruct extends common.common.CommonConstruct {
|
|
40
|
+
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
41
|
+
* super(parent, id, props)
|
|
42
|
+
* this.props = props
|
|
43
|
+
* this.eventTargetManager.createCloudWatchLogGroupNoPolicy('MyLogGrouptarget', this, myLogGroup)
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* @see [CDK EventBridge Target Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_events_targets-readme.html}
|
|
48
|
+
*/
|
|
49
|
+
class EventTargetManager {
|
|
50
|
+
/**
|
|
51
|
+
* @summary Method to create a cloud watch log group target without a policy.
|
|
52
|
+
* - This method is created as a workaround for cdk issue - https://github.com/aws/aws-cdk/issues/17002
|
|
53
|
+
* @param {string} id scoped id of the resource
|
|
54
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
55
|
+
* @param {logs.ILogGroup} logGroup the log group
|
|
56
|
+
* @param {LogGroupNoPolicyProps} props the log group target properties
|
|
57
|
+
*/
|
|
58
|
+
createCloudWatchLogGroupNoPolicy(id, scope, logGroup, props) {
|
|
59
|
+
return new CloudWatchLogGroupNoPolicy(logGroup, props);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.EventTargetManager = EventTargetManager;
|
|
63
|
+
/**
|
|
64
|
+
* Use an AWS CloudWatch LogGroup as an event rule target, but don't apply a policy.
|
|
65
|
+
*/
|
|
66
|
+
class CloudWatchLogGroupNoPolicy {
|
|
67
|
+
logGroup;
|
|
68
|
+
props;
|
|
69
|
+
constructor(logGroup, props = {}) {
|
|
70
|
+
this.logGroup = logGroup;
|
|
71
|
+
this.props = props;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Returns a RuleTarget that can be used to log an event into a CloudWatch LogGroup
|
|
75
|
+
*/
|
|
76
|
+
bind(_rule, _id) {
|
|
77
|
+
const logGroupStack = cdk.Stack.of(this.logGroup);
|
|
78
|
+
return {
|
|
79
|
+
...targets.bindBaseTargetConfig(this.props),
|
|
80
|
+
arn: logGroupStack.formatArn({
|
|
81
|
+
service: 'logs',
|
|
82
|
+
resource: 'log-group',
|
|
83
|
+
arnFormat: cdk.ArnFormat.COLON_RESOURCE_NAME,
|
|
84
|
+
resourceName: this.logGroup.logGroupName,
|
|
85
|
+
}),
|
|
86
|
+
input: this.props.event,
|
|
87
|
+
targetResource: this.logGroup,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.CloudWatchLogGroupNoPolicy = CloudWatchLogGroupNoPolicy;
|
|
@@ -11,6 +11,7 @@ export * from './ecs-manager';
|
|
|
11
11
|
export * from './eks-manager';
|
|
12
12
|
export * from './elasticache-manager';
|
|
13
13
|
export * from './event-manager';
|
|
14
|
+
export * from './event-target-manager';
|
|
14
15
|
export * from './iam-manager';
|
|
15
16
|
export * from './kms-manager';
|
|
16
17
|
export * from './lambda-manager';
|
|
@@ -27,6 +27,7 @@ __exportStar(require("./ecs-manager"), exports);
|
|
|
27
27
|
__exportStar(require("./eks-manager"), exports);
|
|
28
28
|
__exportStar(require("./elasticache-manager"), exports);
|
|
29
29
|
__exportStar(require("./event-manager"), exports);
|
|
30
|
+
__exportStar(require("./event-target-manager"), exports);
|
|
30
31
|
__exportStar(require("./iam-manager"), exports);
|
|
31
32
|
__exportStar(require("./kms-manager"), exports);
|
|
32
33
|
__exportStar(require("./lambda-manager"), exports);
|
package/package.json
CHANGED
|
@@ -35,6 +35,7 @@ export class CommonConstruct extends Construct {
|
|
|
35
35
|
eksManager: aws.EksManager
|
|
36
36
|
elasticacheManager: aws.ElastiCacheManager
|
|
37
37
|
eventManager: aws.EventManager
|
|
38
|
+
eventTargetManager: aws.EventTargetManager
|
|
38
39
|
iamManager: aws.IamManager
|
|
39
40
|
kmsManager: aws.KmsManager
|
|
40
41
|
lambdaManager: aws.LambdaManager
|
|
@@ -67,6 +68,7 @@ export class CommonConstruct extends Construct {
|
|
|
67
68
|
this.eksManager = new aws.EksManager()
|
|
68
69
|
this.elasticacheManager = new aws.ElastiCacheManager()
|
|
69
70
|
this.eventManager = new aws.EventManager()
|
|
71
|
+
this.eventTargetManager = new aws.EventTargetManager()
|
|
70
72
|
this.iamManager = new aws.IamManager()
|
|
71
73
|
this.kmsManager = new aws.KmsManager()
|
|
72
74
|
this.lambdaManager = new aws.LambdaManager()
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as cdk from 'aws-cdk-lib'
|
|
2
|
+
import * as events from 'aws-cdk-lib/aws-events'
|
|
3
|
+
import * as targets from 'aws-cdk-lib/aws-events-targets'
|
|
4
|
+
import * as logs from 'aws-cdk-lib/aws-logs'
|
|
5
|
+
import * as common from '../../common'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @stability stable
|
|
9
|
+
* @category cdk-utils.event-taeget-manager
|
|
10
|
+
* @subcategory Construct
|
|
11
|
+
* @classdesc Provides operations on AWS EventBridge Targets.
|
|
12
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
13
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
14
|
+
* @example
|
|
15
|
+
* import * as common from '@gradientedge/cdk-utils'
|
|
16
|
+
*
|
|
17
|
+
* class CustomConstruct extends common.common.CommonConstruct {
|
|
18
|
+
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
19
|
+
* super(parent, id, props)
|
|
20
|
+
* this.props = props
|
|
21
|
+
* this.eventTargetManager.createCloudWatchLogGroupNoPolicy('MyLogGrouptarget', this, myLogGroup)
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* @see [CDK EventBridge Target Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_events_targets-readme.html}
|
|
26
|
+
*/
|
|
27
|
+
export class EventTargetManager {
|
|
28
|
+
/**
|
|
29
|
+
* @summary Method to create a cloud watch log group target without a policy.
|
|
30
|
+
* - This method is created as a workaround for cdk issue - https://github.com/aws/aws-cdk/issues/17002
|
|
31
|
+
* @param {string} id scoped id of the resource
|
|
32
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
33
|
+
* @param {logs.ILogGroup} logGroup the log group
|
|
34
|
+
* @param {LogGroupNoPolicyProps} props the log group target properties
|
|
35
|
+
*/
|
|
36
|
+
public createCloudWatchLogGroupNoPolicy(
|
|
37
|
+
id: string,
|
|
38
|
+
scope: common.CommonConstruct,
|
|
39
|
+
logGroup: logs.ILogGroup,
|
|
40
|
+
props?: LogGroupNoPolicyProps
|
|
41
|
+
) {
|
|
42
|
+
return new CloudWatchLogGroupNoPolicy(logGroup, props)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Customize the CloudWatch LogGroup Event Target
|
|
48
|
+
*/
|
|
49
|
+
export interface LogGroupNoPolicyProps extends targets.TargetBaseProps {
|
|
50
|
+
/**
|
|
51
|
+
* The event to send to the CloudWatch LogGroup
|
|
52
|
+
*
|
|
53
|
+
* This will be the event logged into the CloudWatch LogGroup
|
|
54
|
+
*
|
|
55
|
+
* @default - the entire EventBridge event
|
|
56
|
+
*/
|
|
57
|
+
readonly event?: events.RuleTargetInput
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Use an AWS CloudWatch LogGroup as an event rule target, but don't apply a policy.
|
|
62
|
+
*/
|
|
63
|
+
export class CloudWatchLogGroupNoPolicy implements events.IRuleTarget {
|
|
64
|
+
constructor(private readonly logGroup: logs.ILogGroup, private readonly props: LogGroupNoPolicyProps = {}) {}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Returns a RuleTarget that can be used to log an event into a CloudWatch LogGroup
|
|
68
|
+
*/
|
|
69
|
+
public bind(_rule: events.IRule, _id?: string): events.RuleTargetConfig {
|
|
70
|
+
const logGroupStack = cdk.Stack.of(this.logGroup)
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
...targets.bindBaseTargetConfig(this.props),
|
|
74
|
+
arn: logGroupStack.formatArn({
|
|
75
|
+
service: 'logs',
|
|
76
|
+
resource: 'log-group',
|
|
77
|
+
arnFormat: cdk.ArnFormat.COLON_RESOURCE_NAME,
|
|
78
|
+
resourceName: this.logGroup.logGroupName,
|
|
79
|
+
}),
|
|
80
|
+
input: this.props.event,
|
|
81
|
+
targetResource: this.logGroup,
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -11,6 +11,7 @@ export * from './ecs-manager'
|
|
|
11
11
|
export * from './eks-manager'
|
|
12
12
|
export * from './elasticache-manager'
|
|
13
13
|
export * from './event-manager'
|
|
14
|
+
export * from './event-target-manager'
|
|
14
15
|
export * from './iam-manager'
|
|
15
16
|
export * from './kms-manager'
|
|
16
17
|
export * from './lambda-manager'
|