Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Serverless Pipes Plugin

Serverless Framework plugin called as "pipes", used to create EventBridge Pipes by providing the required event sources, targets and other parameters as needed.
Expand All @@ -16,8 +15,8 @@ yarn add serverless-pipes
```

## Allowed Services
At the initial version of the plugin, the below mentioned AWS services are supported for the source, target and enrichment in the EventBridge Pipes. We will expand to other services in the future.

At the initial version of the plugin, the below mentioned AWS services are supported for the source, target and enrichment in the EventBridge Pipes. We will expand to other services in the future.

### Source

Expand All @@ -36,8 +35,6 @@ At the initial version of the plugin, the below mentioned AWS services are suppo

- [Lambda Function](docs/parameters/EnrichmentParameters.md)



## Usage

```yaml
Expand All @@ -47,11 +44,11 @@ plugins:
- serverless-pipes

functions:
pipeEnricher:
handler: functions/pipeEnricher.handler
pipeEnricher:
handler: functions/pipeEnricher.handler

pipes:
testPipe: #pipeName
testPipe: #pipeName
enabled: true
source:
sqs:
Expand All @@ -61,13 +58,27 @@ pipes:
sns:
arn:
Fn::GetAtt: [TargetSNSTopic, TopicArn]
enrichment:
enrichment:
name: pipeEnricher
filter:
- Pattern: "{ \"body\": { \"message\": [ \"hello\" ], \"city\": [ \"hey\" ] }}"
- Pattern: '{ "body": { "message": [ "hello" ], "city": [ "hey" ] }}'
iamRolePipes:
type: "individual"

anotherTestPipe: #pipeName
enabled: true
source:
sqs:
arn: arn:aws:sqs:eu-central-1:123456789012:source-queue-name
target:
sns:
arn: arn:aws:sqs:eu-central-1:123456789012:target-queue-name
enrichment:
name: pipeEnricher
filter:
- Pattern: '{ "body": { "message": [ "hello" ], "city": [ "hey" ] }}'
iamRolePipes:
type: "individual"
```

For documentation refer [Docs](docs/index.md)
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class ServerlessPipes {
pipe: string
): void {
const arnRegex = new RegExp(
"^arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9-]+):([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-d{1})?:(d{12})?:(.+)$"
"^arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9-]+):([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\\d{1})?:(\\d{12})?:(.+)$"
);
if (typeof arn === "object") arn = Object.keys(arn)[0];
if (
Expand Down
17 changes: 15 additions & 2 deletions tests/pipes.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, assert } from "chai";
import ServerlessPipes from "../src/index";
import { assert, expect } from "chai";
import Serverless from "serverless";

import ServerlessPipes from "../src";
import {
compileBasedOnSourceType,
compileBasedOnTargetType,
Expand Down Expand Up @@ -255,6 +256,18 @@ describe("ServerlessPipes", () => {
expect(serverlessPipes.validateArn(arn, type, pipe)).to.be.undefined;
});

it("should vaidateArn without error if proper arn is given", () => {
const type = "source";
const pipe = "testPipe";
expect(
serverlessPipes.validateArn(
"arn:aws:sqs:eu-central-1:123456789012:queue-name",
type,
pipe
)
).to.be.undefined;
});

it("should throw error if validateArn doesnt get invalid input parameters", () => {
try {
const arn = { "Fn::GetAtt:": ["SourceSQSQueue", "Arn"] }; //invalid arn; starts with Fn::GetAtt:: instead of Fn::GetAtt
Expand Down