File tree 2 files changed +17
-0
lines changed
packages/aws-cdk-lib/aws-sns
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ export interface TopicProps {
12
12
/**
13
13
* A developer-defined string that can be used to identify this SNS topic.
14
14
*
15
+ * The display name must be maximum 100 characters long, including hyphens (-),
16
+ * underscores (_), spaces, and tabs.
17
+ *
15
18
* @default None
16
19
*/
17
20
readonly displayName ?: string ;
@@ -296,6 +299,10 @@ export class Topic extends TopicBase {
296
299
throw new Error ( `signatureVersion must be "1" or "2", received: "${ props . signatureVersion } "` ) ;
297
300
}
298
301
302
+ if ( props . displayName && ! Token . isUnresolved ( props . displayName ) && props . displayName . length > 100 ) {
303
+ throw new Error ( `displayName must be less than or equal to 100 characters, got ${ props . displayName . length } ` ) ;
304
+ }
305
+
299
306
const resource = new CfnTopic ( this , 'Resource' , {
300
307
archivePolicy : props . messageRetentionPeriodInDays ? {
301
308
MessageRetentionPeriod : props . messageRetentionPeriodInDays ,
Original file line number Diff line number Diff line change @@ -176,6 +176,16 @@ describe('Topic', () => {
176
176
signatureVersion : '3' ,
177
177
} ) ) . toThrow ( / s i g n a t u r e V e r s i o n m u s t b e " 1 " o r " 2 " , r e c e i v e d : " 3 " / ) ;
178
178
} ) ;
179
+
180
+ test ( 'throw error when displayName is too long' , ( ) => {
181
+ const stack = new cdk . Stack ( ) ;
182
+
183
+ expect ( ( ) => {
184
+ new sns . Topic ( stack , 'MyTopic' , {
185
+ displayName : 'a' . repeat ( 101 ) ,
186
+ } ) ;
187
+ } ) . toThrow ( 'displayName must be less than or equal to 100 characters, got 101' ) ;
188
+ } ) ;
179
189
} ) ;
180
190
181
191
test ( 'can add a policy to the topic' , ( ) => {
You can’t perform that action at this time.
0 commit comments