codepipeline-event-notifier 0.1.7 → 0.2.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/.jsii +167 -20
- package/API.md +229 -9
- package/README.md +55 -11
- package/assets/funcs/notifier.lambda/index.js +34 -21
- package/assets/funcs/notifier.lambda/index.js.map +3 -3
- package/lib/constructs/codepipeline-event-notifier.d.ts +45 -1
- package/lib/constructs/codepipeline-event-notifier.js +27 -20
- package/lib/funcs/notifier-predicates.d.ts +29 -0
- package/lib/funcs/notifier-predicates.js +37 -0
- package/lib/funcs/notifier.lambda.d.ts +1 -1
- package/lib/funcs/notifier.lambda.js +23 -24
- package/lib/index.d.ts +1 -3
- package/lib/index.js +4 -10
- package/package.json +1 -1
package/.jsii
CHANGED
|
@@ -8455,7 +8455,7 @@
|
|
|
8455
8455
|
},
|
|
8456
8456
|
"name": "codepipeline-event-notifier",
|
|
8457
8457
|
"readme": {
|
|
8458
|
-
"markdown": "# CodePipeline Event Notifier\n\n[](https://www.npmjs.com/package/codepipeline-event-notifier)\n[](LICENSE)\n\nCDK construct that listens to **AWS CodePipeline execution STARTED** events via EventBridge, invokes a Lambda notifier, and publishes execution state changes to an SNS topic.\n\n## Features\n\n- **EventBridge integration**: triggers on `CodePipeline Pipeline Execution State Change` with `state=STARTED
|
|
8458
|
+
"markdown": "# CodePipeline Event Notifier\n\n[](https://www.npmjs.com/package/codepipeline-event-notifier)\n[](LICENSE)\n\nCDK construct that listens to **AWS CodePipeline execution STARTED** events via EventBridge, invokes a Lambda notifier, and publishes execution state changes to an SNS topic.\n\n## Features\n\n- **EventBridge integration**: triggers on `CodePipeline Pipeline Execution State Change` with `state=STARTED` (customizable via `eventPattern`)\n- **SNS notifications**: publishes execution status transitions as JSON messages (`phase`: `eventbridge` / `wait`)\n- **Execution waiting**: calls `GetPipelineExecution` until a terminal state (`SUCCEEDED` / `FAILED` / `STOPPED` / `SUPERSEDED`) or timeout\n- **Configurable props**: reuse an existing SNS topic, adjust wait interval / max wait duration / Lambda timeout, and filter events\n- **No subscriptions by default**: the SNS topic is created (or reused), but subscriptions (email/HTTP/etc.) are intentionally not configured\n\n## Installation\n\n### npm\n\n```bash\nnpm install codepipeline-event-notifier\n```\n\n### yarn\n\n```bash\nyarn add codepipeline-event-notifier\n```\n\n## Usage\n\nInstantiate `CodePipelineEventNotifier` in your CDK stack:\n\n```ts\nimport { Stack } from 'aws-cdk-lib';\nimport { Construct } from 'constructs';\nimport { CodePipelineEventNotifier } from 'codepipeline-event-notifier';\n\nexport class MyStack extends Stack {\n constructor(scope: Construct, id: string) {\n super(scope, id);\n\n const notifier = new CodePipelineEventNotifier(this, 'CodePipelineEventNotifier');\n\n // Optionally subscribe to the topic created by the construct\n // notifier.topic.addSubscription(...);\n }\n}\n```\n\n### Customize with props\n\n```ts\nimport { Duration, Stack, aws_sns as sns } from 'aws-cdk-lib';\nimport { Construct } from 'constructs';\nimport { CodePipelineEventNotifier } from 'codepipeline-event-notifier';\n\nexport class MyStack extends Stack {\n constructor(scope: Construct, id: string) {\n super(scope, id);\n\n const topic = sns.Topic.fromTopicArn(this, 'ExistingTopic', 'arn:aws:sns:...');\n\n new CodePipelineEventNotifier(this, 'CodePipelineEventNotifier', {\n topic,\n waitInterval: Duration.seconds(30),\n maxWaitDuration: Duration.minutes(10),\n timeout: Duration.minutes(12),\n eventPattern: {\n source: ['aws.codepipeline'],\n detailType: ['CodePipeline Pipeline Execution State Change'],\n detail: {\n state: ['STARTED'],\n pipeline: ['my-pipeline'],\n },\n },\n });\n }\n}\n```\n\n## Options\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `topic` | `sns.ITopic` | new topic | SNS topic to publish notifications to (also exposed as `notifier.topic`) |\n| `waitInterval` | `Duration` | `10 seconds` | Interval between `GetPipelineExecution` calls |\n| `maxWaitDuration` | `Duration` | `14 minutes` | Maximum wait duration before giving up |\n| `timeout` | `Duration` | `15 minutes` | Notifier Lambda timeout (should exceed `maxWaitDuration`) |\n| `eventPattern` | `events.EventPattern` | CodePipeline `STARTED` | EventBridge rule filter |\n\nThe notifier Lambda uses these environment variables (set by the construct from props):\n\n- `SNS_TOPIC_ARN` (**required**): SNS topic ARN to publish notifications to\n- `WAIT_INTERVAL_SECONDS` (default: `10`): wait interval in seconds\n- `MAX_WAIT_MINUTES` (default: `14`): maximum wait duration in minutes\n\n## Requirements\n\n- Node.js `>= 20`\n- AWS CDK `v2` (`aws-cdk-lib` `^2.232.0`)\n- `constructs` `^10.5.1`\n\n## License\n\nThis project is licensed under the Apache-2.0 License.\n"
|
|
8459
8459
|
},
|
|
8460
8460
|
"repository": {
|
|
8461
8461
|
"type": "git",
|
|
@@ -8468,43 +8468,190 @@
|
|
|
8468
8468
|
}
|
|
8469
8469
|
},
|
|
8470
8470
|
"types": {
|
|
8471
|
-
"codepipeline-event-notifier.
|
|
8471
|
+
"codepipeline-event-notifier.CodePipelineEventNotifier": {
|
|
8472
8472
|
"assembly": "codepipeline-event-notifier",
|
|
8473
|
+
"base": "constructs.Construct",
|
|
8473
8474
|
"docs": {
|
|
8474
|
-
"stability": "stable"
|
|
8475
|
+
"stability": "stable",
|
|
8476
|
+
"summary": "Provisions an EventBridge rule that listens for CodePipeline execution STARTED events, then invokes a notifier Lambda which publishes execution state changes to an SNS topic."
|
|
8475
8477
|
},
|
|
8476
|
-
"fqn": "codepipeline-event-notifier.
|
|
8478
|
+
"fqn": "codepipeline-event-notifier.CodePipelineEventNotifier",
|
|
8477
8479
|
"initializer": {
|
|
8478
8480
|
"docs": {
|
|
8479
8481
|
"stability": "stable"
|
|
8480
|
-
}
|
|
8482
|
+
},
|
|
8483
|
+
"locationInModule": {
|
|
8484
|
+
"filename": "src/constructs/codepipeline-event-notifier.ts",
|
|
8485
|
+
"line": 63
|
|
8486
|
+
},
|
|
8487
|
+
"parameters": [
|
|
8488
|
+
{
|
|
8489
|
+
"docs": {
|
|
8490
|
+
"summary": "the construct scope."
|
|
8491
|
+
},
|
|
8492
|
+
"name": "scope",
|
|
8493
|
+
"type": {
|
|
8494
|
+
"fqn": "constructs.Construct"
|
|
8495
|
+
}
|
|
8496
|
+
},
|
|
8497
|
+
{
|
|
8498
|
+
"docs": {
|
|
8499
|
+
"summary": "the construct id."
|
|
8500
|
+
},
|
|
8501
|
+
"name": "id",
|
|
8502
|
+
"type": {
|
|
8503
|
+
"primitive": "string"
|
|
8504
|
+
}
|
|
8505
|
+
},
|
|
8506
|
+
{
|
|
8507
|
+
"docs": {
|
|
8508
|
+
"summary": "construct properties."
|
|
8509
|
+
},
|
|
8510
|
+
"name": "props",
|
|
8511
|
+
"optional": true,
|
|
8512
|
+
"type": {
|
|
8513
|
+
"fqn": "codepipeline-event-notifier.CodePipelineEventNotifierProps"
|
|
8514
|
+
}
|
|
8515
|
+
}
|
|
8516
|
+
]
|
|
8481
8517
|
},
|
|
8482
8518
|
"kind": "class",
|
|
8483
8519
|
"locationInModule": {
|
|
8484
|
-
"filename": "src/
|
|
8485
|
-
"line":
|
|
8520
|
+
"filename": "src/constructs/codepipeline-event-notifier.ts",
|
|
8521
|
+
"line": 52
|
|
8486
8522
|
},
|
|
8487
|
-
"
|
|
8523
|
+
"name": "CodePipelineEventNotifier",
|
|
8524
|
+
"properties": [
|
|
8488
8525
|
{
|
|
8489
8526
|
"docs": {
|
|
8490
|
-
"stability": "stable"
|
|
8527
|
+
"stability": "stable",
|
|
8528
|
+
"summary": "SNS topic that receives CodePipeline execution notifications."
|
|
8491
8529
|
},
|
|
8530
|
+
"immutable": true,
|
|
8492
8531
|
"locationInModule": {
|
|
8493
|
-
"filename": "src/
|
|
8494
|
-
"line":
|
|
8532
|
+
"filename": "src/constructs/codepipeline-event-notifier.ts",
|
|
8533
|
+
"line": 56
|
|
8495
8534
|
},
|
|
8496
|
-
"name": "
|
|
8497
|
-
"
|
|
8498
|
-
"
|
|
8499
|
-
|
|
8500
|
-
|
|
8535
|
+
"name": "topic",
|
|
8536
|
+
"type": {
|
|
8537
|
+
"fqn": "aws-cdk-lib.aws_sns.ITopic"
|
|
8538
|
+
}
|
|
8539
|
+
}
|
|
8540
|
+
],
|
|
8541
|
+
"symbolId": "src/constructs/codepipeline-event-notifier:CodePipelineEventNotifier"
|
|
8542
|
+
},
|
|
8543
|
+
"codepipeline-event-notifier.CodePipelineEventNotifierProps": {
|
|
8544
|
+
"assembly": "codepipeline-event-notifier",
|
|
8545
|
+
"datatype": true,
|
|
8546
|
+
"docs": {
|
|
8547
|
+
"stability": "stable",
|
|
8548
|
+
"summary": "Properties for {@link CodePipelineEventNotifier}."
|
|
8549
|
+
},
|
|
8550
|
+
"fqn": "codepipeline-event-notifier.CodePipelineEventNotifierProps",
|
|
8551
|
+
"kind": "interface",
|
|
8552
|
+
"locationInModule": {
|
|
8553
|
+
"filename": "src/constructs/codepipeline-event-notifier.ts",
|
|
8554
|
+
"line": 8
|
|
8555
|
+
},
|
|
8556
|
+
"name": "CodePipelineEventNotifierProps",
|
|
8557
|
+
"properties": [
|
|
8558
|
+
{
|
|
8559
|
+
"abstract": true,
|
|
8560
|
+
"docs": {
|
|
8561
|
+
"default": "CodePipeline Pipeline Execution State Change with `state=STARTED`",
|
|
8562
|
+
"stability": "stable",
|
|
8563
|
+
"summary": "EventBridge event pattern that triggers the notifier."
|
|
8564
|
+
},
|
|
8565
|
+
"immutable": true,
|
|
8566
|
+
"locationInModule": {
|
|
8567
|
+
"filename": "src/constructs/codepipeline-event-notifier.ts",
|
|
8568
|
+
"line": 45
|
|
8569
|
+
},
|
|
8570
|
+
"name": "eventPattern",
|
|
8571
|
+
"optional": true,
|
|
8572
|
+
"type": {
|
|
8573
|
+
"fqn": "aws-cdk-lib.aws_events.EventPattern"
|
|
8574
|
+
}
|
|
8575
|
+
},
|
|
8576
|
+
{
|
|
8577
|
+
"abstract": true,
|
|
8578
|
+
"docs": {
|
|
8579
|
+
"default": "Duration.minutes(14)",
|
|
8580
|
+
"remarks": "Mapped to the notifier Lambda environment variable `MAX_WAIT_MINUTES`.",
|
|
8581
|
+
"stability": "stable",
|
|
8582
|
+
"summary": "Maximum duration to wait for execution state changes."
|
|
8583
|
+
},
|
|
8584
|
+
"immutable": true,
|
|
8585
|
+
"locationInModule": {
|
|
8586
|
+
"filename": "src/constructs/codepipeline-event-notifier.ts",
|
|
8587
|
+
"line": 30
|
|
8588
|
+
},
|
|
8589
|
+
"name": "maxWaitDuration",
|
|
8590
|
+
"optional": true,
|
|
8591
|
+
"type": {
|
|
8592
|
+
"fqn": "aws-cdk-lib.Duration"
|
|
8593
|
+
}
|
|
8594
|
+
},
|
|
8595
|
+
{
|
|
8596
|
+
"abstract": true,
|
|
8597
|
+
"docs": {
|
|
8598
|
+
"default": "Duration.minutes(15)",
|
|
8599
|
+
"remarks": "Should be greater than {@link maxWaitDuration}.",
|
|
8600
|
+
"stability": "stable",
|
|
8601
|
+
"summary": "Timeout for the notifier Lambda function."
|
|
8602
|
+
},
|
|
8603
|
+
"immutable": true,
|
|
8604
|
+
"locationInModule": {
|
|
8605
|
+
"filename": "src/constructs/codepipeline-event-notifier.ts",
|
|
8606
|
+
"line": 38
|
|
8607
|
+
},
|
|
8608
|
+
"name": "timeout",
|
|
8609
|
+
"optional": true,
|
|
8610
|
+
"type": {
|
|
8611
|
+
"fqn": "aws-cdk-lib.Duration"
|
|
8612
|
+
}
|
|
8613
|
+
},
|
|
8614
|
+
{
|
|
8615
|
+
"abstract": true,
|
|
8616
|
+
"docs": {
|
|
8617
|
+
"default": "- a new topic is created",
|
|
8618
|
+
"remarks": "Subscriptions (email/HTTP/etc.) are intentionally not managed by this construct.",
|
|
8619
|
+
"stability": "stable",
|
|
8620
|
+
"summary": "SNS topic that receives CodePipeline execution notifications."
|
|
8621
|
+
},
|
|
8622
|
+
"immutable": true,
|
|
8623
|
+
"locationInModule": {
|
|
8624
|
+
"filename": "src/constructs/codepipeline-event-notifier.ts",
|
|
8625
|
+
"line": 15
|
|
8626
|
+
},
|
|
8627
|
+
"name": "topic",
|
|
8628
|
+
"optional": true,
|
|
8629
|
+
"type": {
|
|
8630
|
+
"fqn": "aws-cdk-lib.aws_sns.ITopic"
|
|
8631
|
+
}
|
|
8632
|
+
},
|
|
8633
|
+
{
|
|
8634
|
+
"abstract": true,
|
|
8635
|
+
"docs": {
|
|
8636
|
+
"default": "Duration.seconds(10)",
|
|
8637
|
+
"stability": "stable",
|
|
8638
|
+
"summary": "Interval between `GetPipelineExecution` waits."
|
|
8639
|
+
},
|
|
8640
|
+
"immutable": true,
|
|
8641
|
+
"locationInModule": {
|
|
8642
|
+
"filename": "src/constructs/codepipeline-event-notifier.ts",
|
|
8643
|
+
"line": 22
|
|
8644
|
+
},
|
|
8645
|
+
"name": "waitInterval",
|
|
8646
|
+
"optional": true,
|
|
8647
|
+
"type": {
|
|
8648
|
+
"fqn": "aws-cdk-lib.Duration"
|
|
8501
8649
|
}
|
|
8502
8650
|
}
|
|
8503
8651
|
],
|
|
8504
|
-
"
|
|
8505
|
-
"symbolId": "src/index:Hello"
|
|
8652
|
+
"symbolId": "src/constructs/codepipeline-event-notifier:CodePipelineEventNotifierProps"
|
|
8506
8653
|
}
|
|
8507
8654
|
},
|
|
8508
|
-
"version": "0.
|
|
8509
|
-
"fingerprint": "
|
|
8655
|
+
"version": "0.2.0",
|
|
8656
|
+
"fingerprint": "haiP7ZcLzAoufXc8v9n0DlrCNnVW5pL8h+9noaJvwW4="
|
|
8510
8657
|
}
|
package/API.md
CHANGED
|
@@ -1,21 +1,48 @@
|
|
|
1
1
|
# API Reference <a name="API Reference" id="api-reference"></a>
|
|
2
2
|
|
|
3
|
+
## Constructs <a name="Constructs" id="Constructs"></a>
|
|
3
4
|
|
|
5
|
+
### CodePipelineEventNotifier <a name="CodePipelineEventNotifier" id="codepipeline-event-notifier.CodePipelineEventNotifier"></a>
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
Provisions an EventBridge rule that listens for CodePipeline execution STARTED events, then invokes a notifier Lambda which publishes execution state changes to an SNS topic.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
#### Initializers <a name="Initializers" id="codepipeline-event-notifier.Hello.Initializer"></a>
|
|
9
|
+
#### Initializers <a name="Initializers" id="codepipeline-event-notifier.CodePipelineEventNotifier.Initializer"></a>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
import {
|
|
12
|
+
import { CodePipelineEventNotifier } from 'codepipeline-event-notifier'
|
|
13
13
|
|
|
14
|
-
new
|
|
14
|
+
new CodePipelineEventNotifier(scope: Construct, id: string, props?: CodePipelineEventNotifierProps)
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
| **Name** | **Type** | **Description** |
|
|
18
18
|
| --- | --- | --- |
|
|
19
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifier.Initializer.parameter.scope">scope</a></code> | <code>constructs.Construct</code> | the construct scope. |
|
|
20
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifier.Initializer.parameter.id">id</a></code> | <code>string</code> | the construct id. |
|
|
21
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifier.Initializer.parameter.props">props</a></code> | <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifierProps">CodePipelineEventNotifierProps</a></code> | construct properties. |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
##### `scope`<sup>Required</sup> <a name="scope" id="codepipeline-event-notifier.CodePipelineEventNotifier.Initializer.parameter.scope"></a>
|
|
26
|
+
|
|
27
|
+
- *Type:* constructs.Construct
|
|
28
|
+
|
|
29
|
+
the construct scope.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
##### `id`<sup>Required</sup> <a name="id" id="codepipeline-event-notifier.CodePipelineEventNotifier.Initializer.parameter.id"></a>
|
|
34
|
+
|
|
35
|
+
- *Type:* string
|
|
36
|
+
|
|
37
|
+
the construct id.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
##### `props`<sup>Optional</sup> <a name="props" id="codepipeline-event-notifier.CodePipelineEventNotifier.Initializer.parameter.props"></a>
|
|
42
|
+
|
|
43
|
+
- *Type:* <a href="#codepipeline-event-notifier.CodePipelineEventNotifierProps">CodePipelineEventNotifierProps</a>
|
|
44
|
+
|
|
45
|
+
construct properties.
|
|
19
46
|
|
|
20
47
|
---
|
|
21
48
|
|
|
@@ -23,17 +50,210 @@ new Hello()
|
|
|
23
50
|
|
|
24
51
|
| **Name** | **Description** |
|
|
25
52
|
| --- | --- |
|
|
26
|
-
| <code><a href="#codepipeline-event-notifier.
|
|
53
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifier.toString">toString</a></code> | Returns a string representation of this construct. |
|
|
54
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifier.with">with</a></code> | Applies one or more mixins to this construct. |
|
|
27
55
|
|
|
28
56
|
---
|
|
29
57
|
|
|
30
|
-
##### `
|
|
58
|
+
##### `toString` <a name="toString" id="codepipeline-event-notifier.CodePipelineEventNotifier.toString"></a>
|
|
31
59
|
|
|
32
60
|
```typescript
|
|
33
|
-
public
|
|
61
|
+
public toString(): string
|
|
34
62
|
```
|
|
35
63
|
|
|
64
|
+
Returns a string representation of this construct.
|
|
36
65
|
|
|
66
|
+
##### `with` <a name="with" id="codepipeline-event-notifier.CodePipelineEventNotifier.with"></a>
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
public with(mixins: ...IMixin[]): IConstruct
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Applies one or more mixins to this construct.
|
|
73
|
+
|
|
74
|
+
Mixins are applied in order. The list of constructs is captured at the
|
|
75
|
+
start of the call, so constructs added by a mixin will not be visited.
|
|
76
|
+
Use multiple `with()` calls if subsequent mixins should apply to added
|
|
77
|
+
constructs.
|
|
78
|
+
|
|
79
|
+
###### `mixins`<sup>Required</sup> <a name="mixins" id="codepipeline-event-notifier.CodePipelineEventNotifier.with.parameter.mixins"></a>
|
|
80
|
+
|
|
81
|
+
- *Type:* ...constructs.IMixin[]
|
|
82
|
+
|
|
83
|
+
The mixins to apply.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
#### Static Functions <a name="Static Functions" id="Static Functions"></a>
|
|
88
|
+
|
|
89
|
+
| **Name** | **Description** |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifier.isConstruct">isConstruct</a></code> | Checks if `x` is a construct. |
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
##### `isConstruct` <a name="isConstruct" id="codepipeline-event-notifier.CodePipelineEventNotifier.isConstruct"></a>
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { CodePipelineEventNotifier } from 'codepipeline-event-notifier'
|
|
99
|
+
|
|
100
|
+
CodePipelineEventNotifier.isConstruct(x: any)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Checks if `x` is a construct.
|
|
104
|
+
|
|
105
|
+
Use this method instead of `instanceof` to properly detect `Construct`
|
|
106
|
+
instances, even when the construct library is symlinked.
|
|
107
|
+
|
|
108
|
+
Explanation: in JavaScript, multiple copies of the `constructs` library on
|
|
109
|
+
disk are seen as independent, completely different libraries. As a
|
|
110
|
+
consequence, the class `Construct` in each copy of the `constructs` library
|
|
111
|
+
is seen as a different class, and an instance of one class will not test as
|
|
112
|
+
`instanceof` the other class. `npm install` will not create installations
|
|
113
|
+
like this, but users may manually symlink construct libraries together or
|
|
114
|
+
use a monorepo tool: in those cases, multiple copies of the `constructs`
|
|
115
|
+
library can be accidentally installed, and `instanceof` will behave
|
|
116
|
+
unpredictably. It is safest to avoid using `instanceof`, and using
|
|
117
|
+
this type-testing method instead.
|
|
118
|
+
|
|
119
|
+
###### `x`<sup>Required</sup> <a name="x" id="codepipeline-event-notifier.CodePipelineEventNotifier.isConstruct.parameter.x"></a>
|
|
120
|
+
|
|
121
|
+
- *Type:* any
|
|
122
|
+
|
|
123
|
+
Any object.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
#### Properties <a name="Properties" id="Properties"></a>
|
|
128
|
+
|
|
129
|
+
| **Name** | **Type** | **Description** |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifier.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
|
|
132
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifier.property.topic">topic</a></code> | <code>aws-cdk-lib.aws_sns.ITopic</code> | SNS topic that receives CodePipeline execution notifications. |
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
##### `node`<sup>Required</sup> <a name="node" id="codepipeline-event-notifier.CodePipelineEventNotifier.property.node"></a>
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
public readonly node: Node;
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
- *Type:* constructs.Node
|
|
143
|
+
|
|
144
|
+
The tree node.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
##### `topic`<sup>Required</sup> <a name="topic" id="codepipeline-event-notifier.CodePipelineEventNotifier.property.topic"></a>
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
public readonly topic: ITopic;
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
- *Type:* aws-cdk-lib.aws_sns.ITopic
|
|
155
|
+
|
|
156
|
+
SNS topic that receives CodePipeline execution notifications.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
## Structs <a name="Structs" id="Structs"></a>
|
|
162
|
+
|
|
163
|
+
### CodePipelineEventNotifierProps <a name="CodePipelineEventNotifierProps" id="codepipeline-event-notifier.CodePipelineEventNotifierProps"></a>
|
|
164
|
+
|
|
165
|
+
Properties for {@link CodePipelineEventNotifier}.
|
|
166
|
+
|
|
167
|
+
#### Initializer <a name="Initializer" id="codepipeline-event-notifier.CodePipelineEventNotifierProps.Initializer"></a>
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import { CodePipelineEventNotifierProps } from 'codepipeline-event-notifier'
|
|
171
|
+
|
|
172
|
+
const codePipelineEventNotifierProps: CodePipelineEventNotifierProps = { ... }
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### Properties <a name="Properties" id="Properties"></a>
|
|
176
|
+
|
|
177
|
+
| **Name** | **Type** | **Description** |
|
|
178
|
+
| --- | --- | --- |
|
|
179
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifierProps.property.eventPattern">eventPattern</a></code> | <code>aws-cdk-lib.aws_events.EventPattern</code> | EventBridge event pattern that triggers the notifier. |
|
|
180
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifierProps.property.maxWaitDuration">maxWaitDuration</a></code> | <code>aws-cdk-lib.Duration</code> | Maximum duration to wait for execution state changes. |
|
|
181
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifierProps.property.timeout">timeout</a></code> | <code>aws-cdk-lib.Duration</code> | Timeout for the notifier Lambda function. |
|
|
182
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifierProps.property.topic">topic</a></code> | <code>aws-cdk-lib.aws_sns.ITopic</code> | SNS topic that receives CodePipeline execution notifications. |
|
|
183
|
+
| <code><a href="#codepipeline-event-notifier.CodePipelineEventNotifierProps.property.waitInterval">waitInterval</a></code> | <code>aws-cdk-lib.Duration</code> | Interval between `GetPipelineExecution` waits. |
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
##### `eventPattern`<sup>Optional</sup> <a name="eventPattern" id="codepipeline-event-notifier.CodePipelineEventNotifierProps.property.eventPattern"></a>
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
public readonly eventPattern: EventPattern;
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
- *Type:* aws-cdk-lib.aws_events.EventPattern
|
|
194
|
+
- *Default:* CodePipeline Pipeline Execution State Change with `state=STARTED`
|
|
195
|
+
|
|
196
|
+
EventBridge event pattern that triggers the notifier.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
##### `maxWaitDuration`<sup>Optional</sup> <a name="maxWaitDuration" id="codepipeline-event-notifier.CodePipelineEventNotifierProps.property.maxWaitDuration"></a>
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
public readonly maxWaitDuration: Duration;
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
- *Type:* aws-cdk-lib.Duration
|
|
207
|
+
- *Default:* Duration.minutes(14)
|
|
208
|
+
|
|
209
|
+
Maximum duration to wait for execution state changes.
|
|
210
|
+
|
|
211
|
+
Mapped to the notifier Lambda environment variable `MAX_WAIT_MINUTES`.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
##### `timeout`<sup>Optional</sup> <a name="timeout" id="codepipeline-event-notifier.CodePipelineEventNotifierProps.property.timeout"></a>
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
public readonly timeout: Duration;
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
- *Type:* aws-cdk-lib.Duration
|
|
222
|
+
- *Default:* Duration.minutes(15)
|
|
223
|
+
|
|
224
|
+
Timeout for the notifier Lambda function.
|
|
225
|
+
|
|
226
|
+
Should be greater than {@link maxWaitDuration}.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
##### `topic`<sup>Optional</sup> <a name="topic" id="codepipeline-event-notifier.CodePipelineEventNotifierProps.property.topic"></a>
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
public readonly topic: ITopic;
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
- *Type:* aws-cdk-lib.aws_sns.ITopic
|
|
237
|
+
- *Default:* a new topic is created
|
|
238
|
+
|
|
239
|
+
SNS topic that receives CodePipeline execution notifications.
|
|
240
|
+
|
|
241
|
+
Subscriptions (email/HTTP/etc.) are intentionally not managed by this construct.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
##### `waitInterval`<sup>Optional</sup> <a name="waitInterval" id="codepipeline-event-notifier.CodePipelineEventNotifierProps.property.waitInterval"></a>
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
public readonly waitInterval: Duration;
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
- *Type:* aws-cdk-lib.Duration
|
|
252
|
+
- *Default:* Duration.seconds(10)
|
|
253
|
+
|
|
254
|
+
Interval between `GetPipelineExecution` waits.
|
|
255
|
+
|
|
256
|
+
---
|
|
37
257
|
|
|
38
258
|
|
|
39
259
|
|
package/README.md
CHANGED
|
@@ -7,10 +7,11 @@ CDK construct that listens to **AWS CodePipeline execution STARTED** events via
|
|
|
7
7
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
10
|
-
- **EventBridge integration**: triggers on `CodePipeline Pipeline Execution State Change` with `state=STARTED`
|
|
11
|
-
- **SNS notifications**: publishes execution status transitions
|
|
12
|
-
- **Execution
|
|
13
|
-
- **
|
|
10
|
+
- **EventBridge integration**: triggers on `CodePipeline Pipeline Execution State Change` with `state=STARTED` (customizable via `eventPattern`)
|
|
11
|
+
- **SNS notifications**: publishes execution status transitions as JSON messages (`phase`: `eventbridge` / `wait`)
|
|
12
|
+
- **Execution waiting**: calls `GetPipelineExecution` until a terminal state (`SUCCEEDED` / `FAILED` / `STOPPED` / `SUPERSEDED`) or timeout
|
|
13
|
+
- **Configurable props**: reuse an existing SNS topic, adjust wait interval / max wait duration / Lambda timeout, and filter events
|
|
14
|
+
- **No subscriptions by default**: the SNS topic is created (or reused), but subscriptions (email/HTTP/etc.) are intentionally not configured
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
16
17
|
|
|
@@ -39,24 +40,67 @@ export class MyStack extends Stack {
|
|
|
39
40
|
constructor(scope: Construct, id: string) {
|
|
40
41
|
super(scope, id);
|
|
41
42
|
|
|
42
|
-
new CodePipelineEventNotifier(this, 'CodePipelineEventNotifier');
|
|
43
|
+
const notifier = new CodePipelineEventNotifier(this, 'CodePipelineEventNotifier');
|
|
44
|
+
|
|
45
|
+
// Optionally subscribe to the topic created by the construct
|
|
46
|
+
// notifier.topic.addSubscription(...);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Customize with props
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { Duration, Stack, aws_sns as sns } from 'aws-cdk-lib';
|
|
55
|
+
import { Construct } from 'constructs';
|
|
56
|
+
import { CodePipelineEventNotifier } from 'codepipeline-event-notifier';
|
|
57
|
+
|
|
58
|
+
export class MyStack extends Stack {
|
|
59
|
+
constructor(scope: Construct, id: string) {
|
|
60
|
+
super(scope, id);
|
|
61
|
+
|
|
62
|
+
const topic = sns.Topic.fromTopicArn(this, 'ExistingTopic', 'arn:aws:sns:...');
|
|
63
|
+
|
|
64
|
+
new CodePipelineEventNotifier(this, 'CodePipelineEventNotifier', {
|
|
65
|
+
topic,
|
|
66
|
+
waitInterval: Duration.seconds(30),
|
|
67
|
+
maxWaitDuration: Duration.minutes(10),
|
|
68
|
+
timeout: Duration.minutes(12),
|
|
69
|
+
eventPattern: {
|
|
70
|
+
source: ['aws.codepipeline'],
|
|
71
|
+
detailType: ['CodePipeline Pipeline Execution State Change'],
|
|
72
|
+
detail: {
|
|
73
|
+
state: ['STARTED'],
|
|
74
|
+
pipeline: ['my-pipeline'],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
});
|
|
43
78
|
}
|
|
44
79
|
}
|
|
45
80
|
```
|
|
46
81
|
|
|
47
82
|
## Options
|
|
48
83
|
|
|
49
|
-
|
|
84
|
+
| Prop | Type | Default | Description |
|
|
85
|
+
| --- | --- | --- | --- |
|
|
86
|
+
| `topic` | `sns.ITopic` | new topic | SNS topic to publish notifications to (also exposed as `notifier.topic`) |
|
|
87
|
+
| `waitInterval` | `Duration` | `10 seconds` | Interval between `GetPipelineExecution` calls |
|
|
88
|
+
| `maxWaitDuration` | `Duration` | `14 minutes` | Maximum wait duration before giving up |
|
|
89
|
+
| `timeout` | `Duration` | `15 minutes` | Notifier Lambda timeout (should exceed `maxWaitDuration`) |
|
|
90
|
+
| `eventPattern` | `events.EventPattern` | CodePipeline `STARTED` | EventBridge rule filter |
|
|
91
|
+
|
|
92
|
+
The notifier Lambda uses these environment variables (set by the construct from props):
|
|
50
93
|
|
|
51
|
-
- `SNS_TOPIC_ARN` (**required**): SNS topic ARN to publish notifications to
|
|
52
|
-
- `
|
|
53
|
-
- `
|
|
94
|
+
- `SNS_TOPIC_ARN` (**required**): SNS topic ARN to publish notifications to
|
|
95
|
+
- `WAIT_INTERVAL_SECONDS` (default: `10`): wait interval in seconds
|
|
96
|
+
- `MAX_WAIT_MINUTES` (default: `14`): maximum wait duration in minutes
|
|
54
97
|
|
|
55
98
|
## Requirements
|
|
56
99
|
|
|
57
100
|
- Node.js `>= 20`
|
|
58
|
-
- AWS CDK `v2` (`aws-cdk-lib`)
|
|
101
|
+
- AWS CDK `v2` (`aws-cdk-lib` `^2.232.0`)
|
|
102
|
+
- `constructs` `^10.5.1`
|
|
59
103
|
|
|
60
104
|
## License
|
|
61
105
|
|
|
62
|
-
This project is licensed under the Apache-2.0 License.
|
|
106
|
+
This project is licensed under the Apache-2.0 License.
|