@ndlib/ndlib-cdk2 1.0.15 → 1.0.17

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/README.md CHANGED
@@ -89,6 +89,36 @@ const notifications = new PipelineNotifications(stack, 'TestPipelineNotification
89
89
  })
90
90
  ```
91
91
 
92
+
93
+ ## CodePipeline Slack Status Notifications
94
+
95
+ Adds a slack notification construct to watch a CodePipeline for state changes. Note: Currently does not watch any of the actions for specific state changes.
96
+
97
+ Example message:
98
+
99
+ > Pipeline [example-pipeline-deployment-DeploymentPipelineEDAF206A-19MVGYZ0MIPPR](https://us-east-1.console.aws.amazon.com/codepipeline/home?region=us-east-1#/view/example-pipeline-deployment-DeploymentPipelineEDAF206A-19MVGYZ0MIPPR)just SUCCEEDED.
100
+
101
+ Example usage:
102
+
103
+ ```typescript
104
+ import cdk = require('aws-cdk-lib/core')
105
+ import { Pipeline } from 'aws-cdk-lib/aws-codepipeline'
106
+ import { SlackPipelineStatusNotifications } from '@ndlib/ndlib-cdk2'
107
+ const stack = new cdk.Stack()
108
+ const pipeline = Pipeline(stack, { ... })
109
+
110
+ if(props.slackChannelId){
111
+ new SlackPipelineStatusNotifications(this, 'SlackPipelineStatusNotifications', {
112
+ pipeline,
113
+ // messageText: 'example of additional message text', // optional
114
+ slackChannelId: props.slackChannelId,
115
+ slackChannelName: props.slackChannelName,
116
+ // slackNotifyTopicArn: 'some valid topic arn', // optional, defaults to: Fn.importValue('slack-pipeline-status-notify:TopicArn')
117
+ })
118
+ }
119
+ ```
120
+
121
+
92
122
  ## Service Level Objectives
93
123
 
94
124
  Creates Cloudwatch Dashboards and Alarms from a list of SLOs based on the Google SRE workbook for [Alerting on SLOs](https://landing.google.com/sre/workbook/chapters/alerting-on-slos/)
package/lib/index.d.ts CHANGED
@@ -1,18 +1,19 @@
1
- export * from './stack-tags';
2
- export * from './https-alb';
3
1
  export * from './archive-bucket';
4
- export * from './pipeline-notifications';
5
- export * from './slos/alarms';
6
- export * from './slos/alarms-dashboard';
7
- export * from './slos/performance-dashboard';
8
- export * from './ec2s/ec2-with-database';
9
2
  export * from './artifact-bucket';
3
+ export * from './dashboards';
10
4
  export * from './docker-codebuild-action';
5
+ export * from './ec2s/ec2-with-database';
11
6
  export * from './edge-lambdas';
7
+ export * from './https-alb';
8
+ export * from './metrics';
12
9
  export * from './newman-runner';
13
- export * from './static-host';
10
+ export * from './pipeline-notifications';
14
11
  export * from './pipeline-s3-sync';
15
- export * from './source-watcher';
16
- export * from './dashboards';
17
- export * from './metrics';
18
12
  export * from './slack-integration';
13
+ export * from './slack-pipeline-status-notifications';
14
+ export * from './slos/alarms';
15
+ export * from './slos/alarms-dashboard';
16
+ export * from './slos/performance-dashboard';
17
+ export * from './source-watcher';
18
+ export * from './stack-tags';
19
+ export * from './static-host';
package/lib/index.js CHANGED
@@ -14,21 +14,22 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./stack-tags"), exports);
18
- __exportStar(require("./https-alb"), exports);
19
17
  __exportStar(require("./archive-bucket"), exports);
20
- __exportStar(require("./pipeline-notifications"), exports);
21
- __exportStar(require("./slos/alarms"), exports);
22
- __exportStar(require("./slos/alarms-dashboard"), exports);
23
- __exportStar(require("./slos/performance-dashboard"), exports);
24
- __exportStar(require("./ec2s/ec2-with-database"), exports);
25
18
  __exportStar(require("./artifact-bucket"), exports);
19
+ __exportStar(require("./dashboards"), exports);
26
20
  __exportStar(require("./docker-codebuild-action"), exports);
21
+ __exportStar(require("./ec2s/ec2-with-database"), exports);
27
22
  __exportStar(require("./edge-lambdas"), exports);
23
+ __exportStar(require("./https-alb"), exports);
24
+ __exportStar(require("./metrics"), exports);
28
25
  __exportStar(require("./newman-runner"), exports);
29
- __exportStar(require("./static-host"), exports);
26
+ __exportStar(require("./pipeline-notifications"), exports);
30
27
  __exportStar(require("./pipeline-s3-sync"), exports);
31
- __exportStar(require("./source-watcher"), exports);
32
- __exportStar(require("./dashboards"), exports);
33
- __exportStar(require("./metrics"), exports);
34
28
  __exportStar(require("./slack-integration"), exports);
29
+ __exportStar(require("./slack-pipeline-status-notifications"), exports);
30
+ __exportStar(require("./slos/alarms"), exports);
31
+ __exportStar(require("./slos/alarms-dashboard"), exports);
32
+ __exportStar(require("./slos/performance-dashboard"), exports);
33
+ __exportStar(require("./source-watcher"), exports);
34
+ __exportStar(require("./stack-tags"), exports);
35
+ __exportStar(require("./static-host"), exports);
@@ -0,0 +1,21 @@
1
+ import { aws_codepipeline, StackProps } from 'aws-cdk-lib';
2
+ import { Construct } from 'constructs';
3
+ export interface ISlackPipelineStatusNotificationsProps extends StackProps {
4
+ readonly pipeline: aws_codepipeline.Pipeline;
5
+ readonly messageText?: string;
6
+ readonly slackChannelId: string;
7
+ readonly slackChannelName?: string;
8
+ readonly slackNotifyTopicArn?: string;
9
+ }
10
+ export interface ISlackPipelineStatusNotificationsData {
11
+ eventInfo: string;
12
+ messageText?: string;
13
+ pipelineName: string;
14
+ pipelineState: string;
15
+ pipelineUrl: string;
16
+ slackChannelId: string;
17
+ slackChannelName?: string;
18
+ }
19
+ export declare class SlackPipelineStatusNotifications extends Construct {
20
+ constructor(scope: Construct, id: string, props: ISlackPipelineStatusNotificationsProps);
21
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SlackPipelineStatusNotifications = void 0;
4
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
5
+ const aws_sns_1 = require("aws-cdk-lib/aws-sns");
6
+ const constructs_1 = require("constructs");
7
+ class SlackPipelineStatusNotifications extends constructs_1.Construct {
8
+ constructor(scope, id, props) {
9
+ super(scope, id);
10
+ const eventInfo = aws_cdk_lib_1.aws_events.EventField.fromPath('$');
11
+ const pipelineName = aws_cdk_lib_1.aws_events.EventField.fromPath('$.detail.pipeline');
12
+ const pipelineState = aws_cdk_lib_1.aws_events.EventField.fromPath('$.detail.state');
13
+ const pipelineBaseUrl = aws_cdk_lib_1.Fn.sub('https://${AWS::Region}.console.aws.amazon.com/codepipeline/home?region=${AWS::Region}#/view/');
14
+ // eslint-disable-next-line max-len
15
+ const testStackApprovalTopic = aws_sns_1.Topic.fromTopicArn(this, 'SlackTopicFromArn', props.slackNotifyTopicArn || aws_cdk_lib_1.Fn.importValue('slack-pipeline-status-notify:TopicArn'));
16
+ const SlackPipelineStatusNotificationsData = {
17
+ eventInfo: eventInfo,
18
+ messageText: props.messageText,
19
+ pipelineName: pipelineName,
20
+ pipelineState: pipelineState,
21
+ pipelineUrl: pipelineBaseUrl + pipelineName,
22
+ slackChannelId: props.slackChannelId,
23
+ slackChannelName: props.slackChannelName,
24
+ };
25
+ const message = aws_cdk_lib_1.aws_events.RuleTargetInput.fromObject(SlackPipelineStatusNotificationsData);
26
+ const target = new aws_cdk_lib_1.aws_events_targets.SnsTopic(testStackApprovalTopic, { message });
27
+ props.pipeline.onStateChange('OnPipelineStateChange', { target });
28
+ }
29
+ }
30
+ exports.SlackPipelineStatusNotifications = SlackPipelineStatusNotifications;
@@ -104,7 +104,7 @@ class StaticHost extends constructs_1.Construct {
104
104
  ],
105
105
  viewerCertificate: aws_cdk_lib_1.aws_cloudfront.ViewerCertificate.fromAcmCertificate(props.websiteCertificate, {
106
106
  aliases: [this.hostname],
107
- securityPolicy: aws_cdk_lib_1.aws_cloudfront.SecurityPolicyProtocol.TLS_V1_1_2016,
107
+ securityPolicy: aws_cdk_lib_1.aws_cloudfront.SecurityPolicyProtocol.TLS_V1_2_2021,
108
108
  sslMethod: aws_cdk_lib_1.aws_cloudfront.SSLMethod.SNI,
109
109
  }),
110
110
  viewerProtocolPolicy: aws_cdk_lib_1.aws_cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/ndlib-cdk2",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "Reusable CDK2 modules used within Hesburgh Libraries of Notre Dame",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -40,35 +40,35 @@
40
40
  "aws-cdk-lib": "^2.88.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/jest": "^29.5.3",
44
- "@types/node": "^18.16.19",
45
- "@typescript-eslint/eslint-plugin": "^6.1.0",
46
- "@typescript-eslint/parser": "^6.1.0",
43
+ "@types/jest": "^29.5.4",
44
+ "@types/node": "^18.17.0",
45
+ "@typescript-eslint/eslint-plugin": "^6.6.0",
46
+ "@typescript-eslint/parser": "^6.6.0",
47
47
  "aws-sdk-client-mock": "^3.0.0",
48
- "eslint": "^8.45.0",
48
+ "eslint": "^8.48.0",
49
49
  "eslint-config-standard": "^17.1.0",
50
- "eslint-plugin-import": "^2.27.5",
50
+ "eslint-plugin-import": "^2.28.1",
51
51
  "eslint-plugin-jest": "^27.2.3",
52
- "eslint-plugin-n": "^16.0.1",
52
+ "eslint-plugin-n": "^16.0.2",
53
53
  "eslint-plugin-node": "^11.1.0",
54
54
  "eslint-plugin-promise": "^6.1.1",
55
55
  "eslint-plugin-standard": "^5.0.0",
56
56
  "github-changes": "^2.0.3",
57
- "jest": "^29.6.1",
58
- "jest-mock": "^29.6.1",
59
- "prettier": "^3.0.0",
57
+ "jest": "^29.6.4",
58
+ "jest-mock": "^29.6.3",
59
+ "prettier": "^3.0.3",
60
60
  "subpackage": "^1.1.0",
61
61
  "ts-jest": "^29.1.1",
62
62
  "tsc-watch": "^6.0.4",
63
- "typescript": "^5.1.6"
63
+ "typescript": "^5.2.2"
64
64
  },
65
65
  "files": [
66
66
  "lib/**/*"
67
67
  ],
68
68
  "dependencies": {
69
- "aws-cdk-lib": "^2.88.0",
70
- "constructs": "^10.2.69",
71
- "node-fetch": "^3.3.1"
69
+ "aws-cdk-lib": "^2.94.0",
70
+ "constructs": "^10.2.70",
71
+ "node-fetch": "^3.3.2"
72
72
  },
73
73
  "subPackages": [
74
74
  "src/internal-lambdas/sourceWatcherLambda/src"