diff --git a/README.md b/README.md index a0a6ef8..c0402cb 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 @@ -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 @@ -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: @@ -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) diff --git a/src/index.ts b/src/index.ts index f254d55..7f832ed 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 ( diff --git a/tests/pipes.test.ts b/tests/pipes.test.ts index 91ae78c..6d80b34 100644 --- a/tests/pipes.test.ts +++ b/tests/pipes.test.ts @@ -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, @@ -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