From 60398899e31d481fd231b71a00fa02ca2851c303 Mon Sep 17 00:00:00 2001
From: Gadam8 <44494964+Gadam8@users.noreply.github.com>
Date: Mon, 18 Sep 2023 12:10:11 +0100
Subject: [PATCH 1/6] Update FilterPolicy config to match AWS API
Currently, filterPolicy configuration outlined in this file does not match what is outlined in the AWS documentation and API - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html. The `filterPolicy` should only contain the JSON policy, so no need for the `attributes` property; which in itself was confusing as the policy can apply to the message attributes or body.
Further to this, this definition file was missing the `filterPolicyScope` which is needed to determine whether the user wishes to filter on the message attributes or the body.
---
sns/json_schemas/operation.json | 55 +++++++++++++++++----------------
1 file changed, 29 insertions(+), 26 deletions(-)
diff --git a/sns/json_schemas/operation.json b/sns/json_schemas/operation.json
index df59a327..730a4ad9 100644
--- a/sns/json_schemas/operation.json
+++ b/sns/json_schemas/operation.json
@@ -97,6 +97,9 @@
"filterPolicy": {
"$ref": "#/definitions/filterPolicy"
},
+ "filterPolicyScope": {
+ "$ref": "#/definitions/filterPolicyScope"
+ },
"rawMessageDelivery": {
"type": "boolean",
"description": "If true AWS SNS attributes are removed from the body, and for SQS, SNS message attributes are copied to SQS message attributes. If false the SNS attributes are included in the body."
@@ -169,37 +172,37 @@
},
"filterPolicy": {
"type": "object",
- "description": "Only receive a subset of messages from the channel, determined by this policy.",
+ "description": "Only receive a subset of messages from the channel, determined by this policy. Depending on the FilterPolicyScope, a map of either a message attribute or message body to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint.",
"patternProperties": {
"^x-[\\w\\d\\.\\-\\_]+$": {
"$ref": "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/v2.14.0/schemas/2.4.0.json#/definitions/specificationExtension"
}
},
- "properties": {
- "attributes": {
- "type": "object",
- "description": "A map of a message attribute to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint.",
- "additionalProperties": {
- "oneOf": [
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "string"
- },
- {
- "type": "object"
- }
- ]
+ "additionalProperties": {
+ "oneOf": [
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ {
+ "type": "string"
+ },
+ {
+ "type": "object"
}
- }
- },
- "required": [
- "attributes"
- ]
+ ]
+ }
+ },
+ "filterPolicyScope": {
+ "type": "string",
+ "description": "Determines whether the filterPolicy applies to MessageAttributes or MessageBody.",
+ "enum": [
+ "MessageAttributes",
+ "MessageBody"
+ ],
+ "default": "MessageAttributes"
},
"redrivePolicy": {
"type": "object",
@@ -274,4 +277,4 @@
]
}
]
-}
\ No newline at end of file
+}
From 5c0646ae0d2d1079677b7eef3680358ce6753d75 Mon Sep 17 00:00:00 2001
From: Gadam8 <44494964+Gadam8@users.noreply.github.com>
Date: Mon, 18 Sep 2023 15:04:46 +0100
Subject: [PATCH 2/6] Minor: remove redundant ref
---
sns/json_schemas/operation.json | 66 +++++++++++++++------------------
1 file changed, 30 insertions(+), 36 deletions(-)
diff --git a/sns/json_schemas/operation.json b/sns/json_schemas/operation.json
index 730a4ad9..36047a39 100644
--- a/sns/json_schemas/operation.json
+++ b/sns/json_schemas/operation.json
@@ -95,10 +95,38 @@
"$ref": "#/definitions/identifier"
},
"filterPolicy": {
- "$ref": "#/definitions/filterPolicy"
+ "type": "object",
+ "description": "Only receive a subset of messages from the channel, determined by this policy. Depending on the FilterPolicyScope, a map of either a message attribute or message body to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint.",
+ "patternProperties": {
+ "^x-[\\w\\d\\.\\-\\_]+$": {
+ "$ref": "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/v2.14.0/schemas/2.4.0.json#/definitions/specificationExtension"
+ }
+ },
+ "additionalProperties": {
+ "oneOf": [
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ {
+ "type": "string"
+ },
+ {
+ "type": "object"
+ }
+ ]
+ }
},
"filterPolicyScope": {
- "$ref": "#/definitions/filterPolicyScope"
+ "type": "string",
+ "description": "Determines whether the filterPolicy applies to MessageAttributes or MessageBody.",
+ "enum": [
+ "MessageAttributes",
+ "MessageBody"
+ ],
+ "default": "MessageAttributes"
},
"rawMessageDelivery": {
"type": "boolean",
@@ -170,40 +198,6 @@
}
}
},
- "filterPolicy": {
- "type": "object",
- "description": "Only receive a subset of messages from the channel, determined by this policy. Depending on the FilterPolicyScope, a map of either a message attribute or message body to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint.",
- "patternProperties": {
- "^x-[\\w\\d\\.\\-\\_]+$": {
- "$ref": "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/v2.14.0/schemas/2.4.0.json#/definitions/specificationExtension"
- }
- },
- "additionalProperties": {
- "oneOf": [
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "string"
- },
- {
- "type": "object"
- }
- ]
- }
- },
- "filterPolicyScope": {
- "type": "string",
- "description": "Determines whether the filterPolicy applies to MessageAttributes or MessageBody.",
- "enum": [
- "MessageAttributes",
- "MessageBody"
- ],
- "default": "MessageAttributes"
- },
"redrivePolicy": {
"type": "object",
"description": "Prevent poison pill messages by moving un-processable messages to an SQS dead letter queue.",
From 3c71e17d3abeb1b9654bf41a25703b8838c58af3 Mon Sep 17 00:00:00 2001
From: Gadam8 <44494964+Gadam8@users.noreply.github.com>
Date: Tue, 19 Sep 2023 12:02:08 +0100
Subject: [PATCH 3/6] Minor: match Pascal casing
---
sns/json_schemas/operation.json | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sns/json_schemas/operation.json b/sns/json_schemas/operation.json
index 36047a39..6cf18743 100644
--- a/sns/json_schemas/operation.json
+++ b/sns/json_schemas/operation.json
@@ -96,7 +96,7 @@
},
"filterPolicy": {
"type": "object",
- "description": "Only receive a subset of messages from the channel, determined by this policy. Depending on the FilterPolicyScope, a map of either a message attribute or message body to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint.",
+ "description": "Only receive a subset of messages from the channel, determined by this policy. Depending on the filterPolicyScope, a map of either a message attribute or message body to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint.",
"patternProperties": {
"^x-[\\w\\d\\.\\-\\_]+$": {
"$ref": "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/v2.14.0/schemas/2.4.0.json#/definitions/specificationExtension"
@@ -121,10 +121,10 @@
},
"filterPolicyScope": {
"type": "string",
- "description": "Determines whether the filterPolicy applies to MessageAttributes or MessageBody.",
+ "description": "Determines whether the filterPolicy applies to messageAttributes or messageBody.",
"enum": [
- "MessageAttributes",
- "MessageBody"
+ "messageAttributes",
+ "messageBody"
],
"default": "MessageAttributes"
},
From 0657a66753731e9c50a4442e17623bcbe500cc65 Mon Sep 17 00:00:00 2001
From: Gadam8 <44494964+Gadam8@users.noreply.github.com>
Date: Tue, 19 Sep 2023 12:07:04 +0100
Subject: [PATCH 4/6] Minor: amend casing
---
sns/json_schemas/operation.json | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sns/json_schemas/operation.json b/sns/json_schemas/operation.json
index 6cf18743..e928786d 100644
--- a/sns/json_schemas/operation.json
+++ b/sns/json_schemas/operation.json
@@ -96,7 +96,7 @@
},
"filterPolicy": {
"type": "object",
- "description": "Only receive a subset of messages from the channel, determined by this policy. Depending on the filterPolicyScope, a map of either a message attribute or message body to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint.",
+ "description": "Only receive a subset of messages from the channel, determined by this policy. Depending on the FilterPolicyScope, a map of either a message attribute or message body to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint.",
"patternProperties": {
"^x-[\\w\\d\\.\\-\\_]+$": {
"$ref": "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/v2.14.0/schemas/2.4.0.json#/definitions/specificationExtension"
@@ -121,12 +121,12 @@
},
"filterPolicyScope": {
"type": "string",
- "description": "Determines whether the filterPolicy applies to messageAttributes or messageBody.",
+ "description": "Determines whether the FilterPolicy applies to MessageAttributes or MessageBody.",
"enum": [
"messageAttributes",
"messageBody"
],
- "default": "MessageAttributes"
+ "default": "messageAttributes"
},
"rawMessageDelivery": {
"type": "boolean",
From e6632d3c8519ce4ffd10a8fd9ceca46c1a3d897a Mon Sep 17 00:00:00 2001
From: Gadam8 <44494964+Gadam8@users.noreply.github.com>
Date: Wed, 20 Sep 2023 10:03:37 +0100
Subject: [PATCH 5/6] Match AWS API casing and fix example
---
sns/json_schemas/operation.json | 35 ++++++++++++++++-----------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/sns/json_schemas/operation.json b/sns/json_schemas/operation.json
index e928786d..25eb5935 100644
--- a/sns/json_schemas/operation.json
+++ b/sns/json_schemas/operation.json
@@ -123,10 +123,10 @@
"type": "string",
"description": "Determines whether the FilterPolicy applies to MessageAttributes or MessageBody.",
"enum": [
- "messageAttributes",
- "messageBody"
+ "MessageAttributes",
+ "MessageBody"
],
- "default": "messageAttributes"
+ "default": "MessageAttributes"
},
"rawMessageDelivery": {
"type": "boolean",
@@ -234,22 +234,21 @@
"name": "someQueue"
},
"filterPolicy": {
- "attributes": {
- "store": [
- "asyncapi_corp"
- ],
- "event": [
- {
- "anything-but": "order_cancelled"
- }
- ],
- "customer_interests": [
- "rugby",
- "football",
- "baseball"
- ]
- }
+ "store": [
+ "asyncapi_corp"
+ ],
+ "event": [
+ {
+ "anything-but": "order_cancelled"
+ }
+ ],
+ "customer_interests": [
+ "rugby",
+ "football",
+ "baseball"
+ ]
},
+ "filterPolicyScope": "MessageAttributes",
"rawMessageDelivery": false,
"redrivePolicy": {
"deadLetterQueue": {
From def783a4dca1e3f791fe1e9305b4788e6106915d Mon Sep 17 00:00:00 2001
From: Gadam8 <44494964+Gadam8@users.noreply.github.com>
Date: Wed, 20 Sep 2023 15:40:54 +0100
Subject: [PATCH 6/6] Update SNS README
---
sns/README.md | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/sns/README.md b/sns/README.md
index 26a78576..4ef43ec5 100644
--- a/sns/README.md
+++ b/sns/README.md
@@ -113,7 +113,8 @@ We support an array of consumers via the **consumers** field. This allows you to
|---|:---:|---|
| `protocol` | string | **Required.** The protocol that this endpoint receives messages by. Can be `http`, `https`, `email`, `email-json`, `sms`, `sqs`, `application`, `lambda` or `firehose` |
| `endpoint` |[identifier](#identifier)| **Required.** The endpoint messages are delivered to. |
-| `filterPolicy` | [filterPolicy](#filter-policy) | **Optional.** Only receive a subset of messages from the channel, determined by this policy. |
+| `filterPolicy` | object | **Optional.** Only receive a subset of messages from the channel, determined by this policy. |
+| `filterPolicyScope` | string | **Optional.** Determines whether the FilterPolicy applies to MessageAttributes (default) or MessageBody. |
| `rawMessageDelivery` | boolean | **Required.** If *true* AWS SNS attributes are removed from the body, and for SQS, SNS message attributes are copied to SQS message attributes. If *false* the SNS attributes are included in the body. |
| `redrivePolicy` | [redrivePolicy](#redrive-policy) | **Optional.** Prevent poison pill messages by moving un-processable messages to an SQS dead letter queue. |
| `deliveryPolicy` | [deliveryPolicy](#delivery-policy) | **Optional.** Policy for retries to HTTP. The parameter is for that [SNS Subscription](https://docs.aws.amazon.com/sns/latest/api/API_Subscribe.html) and overrides any policy on the [SNS Topic](https://docs.aws.amazon.com/sns/latest/api/API_CreateTopic.html). |
@@ -132,11 +133,6 @@ We support an array of consumers via the **consumers** field. This allows you to
| `backoffFunction` | string, one of: arithmetic, exponential, geometric or linear | **Optional.** The algorithm for backoff between retries |
| `maxReceivesPerSecond` | integer | **Optional.** The maximum number of deliveries per second, per subscription |
-#### Filter Policy
-|Field Name | Type | Description|
-|---|:---:|---|
-| `attributes` |Map(string, array or string or object) | **Required.** A map of a message attribute to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint |
-
#### Identifier
|Field Name | Type | Description|
|---|:---:|---|
@@ -221,9 +217,8 @@ channels:
name: user-signedup-queue # refers to a queue defined in this file, but not shown in this example
rawMessageDelivery: true
filterPolicy:
- attributes:
- reason:
- anything-but: password-reset
+ reason:
+ anything-but: password-reset
redrivePolicy:
deadLetterQueue:
name: user-signedup-queue-dlq # refers toa queue defined in this file, but not show in this example
@@ -281,9 +276,9 @@ channels:
endpoint:
url: http://login.my.com/user/new
filterPolicy:
- attributes:
- reason:
- anything-but: password-reset
+ reason:
+ anything-but: password-reset
+ filterPolicyScope: MessageBody
deliveryPolicy:
minDelayTarget: 1
maxDelayTarget: 120