@@ -78,78 +78,83 @@ export type CloudFormationIntrinsicFunction =
7878 * Helper functions for creating CloudFormation intrinsic functions
7979 */
8080export const Fn = {
81- ref : ( logicalId : string ) => ( { Ref : logicalId } ) ,
81+ ref : ( logicalId : string ) : { Ref : string } => ( { Ref : logicalId } ) ,
8282
83- getAtt : ( logicalId : string , attribute : string ) => ( { 'Fn::GetAtt' : [ logicalId , attribute ] } ) ,
83+ getAtt : ( logicalId : string , attribute : string ) : { 'Fn::GetAtt' : [ string , string ] } =>
84+ ( { 'Fn::GetAtt' : [ logicalId , attribute ] as [ string , string ] } ) ,
8485
85- join : ( delimiter : string , values : any [ ] ) => ( { 'Fn::Join' : [ delimiter , values ] } ) ,
86+ join : ( delimiter : string , values : any [ ] ) : { 'Fn::Join' : [ string , any [ ] ] } =>
87+ ( { 'Fn::Join' : [ delimiter , values ] as [ string , any [ ] ] } ) ,
8688
87- sub : ( template : string , variables ?: Record < string , any > ) =>
88- variables ? { 'Fn::Sub' : [ template , variables ] } : { 'Fn::Sub' : template } ,
89+ sub : ( template : string , variables ?: Record < string , any > ) : { 'Fn::Sub' : string | [ string , Record < string , any > ] } =>
90+ variables ? { 'Fn::Sub' : [ template , variables ] as [ string , Record < string , any > ] } : { 'Fn::Sub' : template } ,
8991
90- select : ( index : number , list : any [ ] | CloudFormationIntrinsicFunction ) => ( { 'Fn::Select' : [ index , list ] } ) ,
92+ select : ( index : number , list : any [ ] | CloudFormationIntrinsicFunction ) : { 'Fn::Select' : [ number , any [ ] | CloudFormationIntrinsicFunction ] } =>
93+ ( { 'Fn::Select' : [ index , list ] as [ number , any [ ] | CloudFormationIntrinsicFunction ] } ) ,
9194
92- split : ( delimiter : string , source : string ) => ( { 'Fn::Split' : [ delimiter , source ] } ) ,
95+ split : ( delimiter : string , source : string ) : { 'Fn::Split' : [ string , string ] } =>
96+ ( { 'Fn::Split' : [ delimiter , source ] as [ string , string ] } ) ,
9397
94- getAZs : ( region : string = '' ) => ( { 'Fn::GetAZs' : region } ) ,
98+ getAZs : ( region : string = '' ) : { 'Fn::GetAZs' : string } => ( { 'Fn::GetAZs' : region } ) ,
9599
96- importValue : ( name : any ) => ( { 'Fn::ImportValue' : name } ) ,
100+ importValue : ( name : any ) : { 'Fn::ImportValue' : any } => ( { 'Fn::ImportValue' : name } ) ,
97101
98- findInMap : ( mapName : string , topLevelKey : any , secondLevelKey : any ) =>
99- ( { 'Fn::FindInMap' : [ mapName , topLevelKey , secondLevelKey ] } ) ,
102+ findInMap : ( mapName : string , topLevelKey : any , secondLevelKey : any ) : { 'Fn::FindInMap' : [ string , any , any ] } =>
103+ ( { 'Fn::FindInMap' : [ mapName , topLevelKey , secondLevelKey ] as [ string , any , any ] } ) ,
100104
101- base64 : ( value : any ) => ( { 'Fn::Base64' : value } ) ,
105+ base64 : ( value : any ) : { 'Fn::Base64' : any } => ( { 'Fn::Base64' : value } ) ,
102106
103107 cidr : ( ipBlock : any , count : number , cidrBits : number ) : { 'Fn::Cidr' : [ any , number , number ] } =>
104- ( { 'Fn::Cidr' : [ ipBlock , count , cidrBits ] } ) ,
108+ ( { 'Fn::Cidr' : [ ipBlock , count , cidrBits ] as [ any , number , number ] } ) ,
105109
106- equals : ( value1 : any , value2 : any ) : { 'Fn::Equals' : [ any , any ] } => ( { 'Fn::Equals' : [ value1 , value2 ] } ) ,
110+ equals : ( value1 : any , value2 : any ) : { 'Fn::Equals' : [ any , any ] } =>
111+ ( { 'Fn::Equals' : [ value1 , value2 ] as [ any , any ] } ) ,
107112
108113 if : ( conditionName : string , trueValue : any , falseValue : any ) : { 'Fn::If' : [ string , any , any ] } =>
109- ( { 'Fn::If' : [ conditionName , trueValue , falseValue ] } ) ,
114+ ( { 'Fn::If' : [ conditionName , trueValue , falseValue ] as [ string , any , any ] } ) ,
110115
111- not : ( condition : any ) : { 'Fn::Not' : [ any ] } => ( { 'Fn::Not' : [ condition ] } ) ,
116+ not : ( condition : any ) : { 'Fn::Not' : [ any ] } => ( { 'Fn::Not' : [ condition ] as [ any ] } ) ,
112117
113- and : ( ...conditions : any [ ] ) => ( { 'Fn::And' : conditions } ) ,
118+ and : ( ...conditions : any [ ] ) : { 'Fn::And' : any [ ] } => ( { 'Fn::And' : conditions } ) ,
114119
115- or : ( ...conditions : any [ ] ) => ( { 'Fn::Or' : conditions } ) ,
120+ or : ( ...conditions : any [ ] ) : { 'Fn::Or' : any [ ] } => ( { 'Fn::Or' : conditions } ) ,
116121}
117122
118123/**
119124 * Common AWS resource ARN patterns
120125 */
121126export const Arn = {
122- s3Bucket : ( bucketName : any ) =>
127+ s3Bucket : ( bucketName : any ) : { 'Fn::Sub' : string | [ string , Record < string , any > ] } =>
123128 Fn . sub ( `arn:aws:s3:::${ bucketName } ` ) ,
124129
125- s3Object : ( bucketName : any , key : string = '*' ) =>
130+ s3Object : ( bucketName : any , key : string = '*' ) : { 'Fn::Sub' : string | [ string , Record < string , any > ] } =>
126131 Fn . sub ( `arn:aws:s3:::${ bucketName } /${ key } ` ) ,
127132
128- lambda : ( functionName : string , region ?: string , account ?: string ) =>
133+ lambda : ( functionName : string , region ?: string , account ?: string ) : { 'Fn::Sub' : string | [ string , Record < string , any > ] } =>
129134 Fn . sub (
130135 `arn:aws:lambda:\${AWS::Region}:\${AWS::AccountId}:function:${ functionName } ` ,
131136 region && account ? { 'AWS::Region' : region , 'AWS::AccountId' : account } : undefined ,
132137 ) ,
133138
134- dynamodb : ( tableName : string ) =>
139+ dynamodb : ( tableName : string ) : { 'Fn::Sub' : string | [ string , Record < string , any > ] } =>
135140 Fn . sub ( `arn:aws:dynamodb:\${AWS::Region}:\${AWS::AccountId}:table/${ tableName } ` ) ,
136141
137- sqs : ( queueName : string ) =>
142+ sqs : ( queueName : string ) : { 'Fn::Sub' : string | [ string , Record < string , any > ] } =>
138143 Fn . sub ( `arn:aws:sqs:\${AWS::Region}:\${AWS::AccountId}:${ queueName } ` ) ,
139144
140- sns : ( topicName : string ) =>
145+ sns : ( topicName : string ) : { 'Fn::Sub' : string | [ string , Record < string , any > ] } =>
141146 Fn . sub ( `arn:aws:sns:\${AWS::Region}:\${AWS::AccountId}:${ topicName } ` ) ,
142147
143- kinesis : ( streamName : string ) =>
148+ kinesis : ( streamName : string ) : { 'Fn::Sub' : string | [ string , Record < string , any > ] } =>
144149 Fn . sub ( `arn:aws:kinesis:\${AWS::Region}:\${AWS::AccountId}:stream/${ streamName } ` ) ,
145150
146- iam : ( resourceType : 'role' | 'policy' | 'user' | 'group' , name : string ) =>
151+ iam : ( resourceType : 'role' | 'policy' | 'user' | 'group' , name : string ) : { 'Fn::Sub' : string | [ string , Record < string , any > ] } =>
147152 Fn . sub ( `arn:aws:iam::\${AWS::AccountId}:${ resourceType } /${ name } ` ) ,
148153
149- secretsManager : ( secretName : string ) =>
154+ secretsManager : ( secretName : string ) : { 'Fn::Sub' : string | [ string , Record < string , any > ] } =>
150155 Fn . sub ( `arn:aws:secretsmanager:\${AWS::Region}:\${AWS::AccountId}:secret:${ secretName } ` ) ,
151156
152- cloudwatch : ( logGroup : string ) =>
157+ cloudwatch : ( logGroup : string ) : { 'Fn::Sub' : string | [ string , Record < string , any > ] } =>
153158 Fn . sub ( `arn:aws:logs:\${AWS::Region}:\${AWS::AccountId}:log-group:${ logGroup } ` ) ,
154159}
155160
0 commit comments