diff --git a/src/main/kotlin/org/opensearch/commons/notifications/model/Sns.kt b/src/main/kotlin/org/opensearch/commons/notifications/model/Sns.kt index 583aec49..fc377b75 100644 --- a/src/main/kotlin/org/opensearch/commons/notifications/model/Sns.kt +++ b/src/main/kotlin/org/opensearch/commons/notifications/model/Sns.kt @@ -58,7 +58,7 @@ data class Sns(val topicArn: String, val roleArn: String?) : BaseConfigData { private val log by logger(Sns::class.java) private val SNS_ARN_REGEX = - Pattern.compile("^arn:aws(-[^:]+)?:sns:([a-zA-Z0-9-]+):([0-9]{12}):([a-zA-Z0-9-_]+)$") + Pattern.compile("^arn:aws(-[^:]+)?:sns:([a-zA-Z0-9-]+):([0-9]{12}):([a-zA-Z_0-9+=,.@\\-_/]+)$") /** * reader to create instance of class from writable. diff --git a/src/test/kotlin/org/opensearch/commons/notifications/model/SnsTests.kt b/src/test/kotlin/org/opensearch/commons/notifications/model/SnsTests.kt index 494f09e9..f81e8d3f 100644 --- a/src/test/kotlin/org/opensearch/commons/notifications/model/SnsTests.kt +++ b/src/test/kotlin/org/opensearch/commons/notifications/model/SnsTests.kt @@ -8,6 +8,7 @@ package org.opensearch.commons.notifications.model import com.fasterxml.jackson.core.JsonParseException import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions.assertThrows +import org.junit.jupiter.api.Assertions.fail import org.junit.jupiter.api.Test import org.opensearch.commons.utils.createObjectFromJsonString import org.opensearch.commons.utils.getJsonString @@ -49,6 +50,18 @@ internal class SnsTests { } } + @Test + fun `test SNS correctly validates SNS FIFO topic ARN`() { + try { + Sns( + "arn:aws:sns:ap-southeast-2:333654771707:sns-fifo-alerting.fifo", + "arn:aws:iam::012345678912:role/iam-test" + ) + } catch (e: Exception) { + fail("Expected fifo sns topic ARN to be validated successfully", e) + } + } + @Test fun `SNS serialize and deserialize transport object should be equal`() { val sampleSns = Sns("arn:aws:sns:us-east-1:012345678912:topic-test", "arn:aws:iam::012345678912:role/iam-test")