Skip to content

Commit 919af72

Browse files
authored
Merge pull request #30 from horike37/fix-fn-sub
Refactor: Use Fn::Sub function instead of Fn::Join
2 parents cef0219 + 9f4f654 commit 919af72

File tree

4 files changed

+147
-277
lines changed

4 files changed

+147
-277
lines changed

lib/package/kinesis/compileMethodsToKinesis.js

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,7 @@ module.exports = {
5454
'Fn::GetAtt': ['ApigatewayToKinesisRole', 'Arn']
5555
},
5656
Uri: {
57-
'Fn::Join': [
58-
'',
59-
[
60-
'arn:aws:apigateway:',
61-
{
62-
Ref: 'AWS::Region'
63-
},
64-
':kinesis:action/PutRecord'
65-
]
66-
]
57+
'Fn::Sub': 'arn:aws:apigateway:${AWS::Region}:kinesis:action/PutRecord'
6758
},
6859
PassthroughBehavior: 'NEVER',
6960
RequestTemplates: this.getKinesisIntegrationRequestTemplates(http)
@@ -147,27 +138,16 @@ module.exports = {
147138
},
148139

149140
buildDefaultKinesisRequestTemplate(http) {
150-
let streamName
151-
if (typeof http.streamName == 'object') {
152-
streamName = http.streamName
153-
} else {
154-
streamName = `"${http.streamName}"`
155-
}
156-
157141
const objectRequestParam = this.getKinesisObjectRequestParameter(http)
158142

159143
return {
160-
'Fn::Join': [
161-
'',
162-
[
163-
'{',
164-
'"StreamName": "',
165-
streamName,
166-
'",',
167-
'"Data": "$util.base64Encode($input.body)",',
168-
`"PartitionKey": "${objectRequestParam}"`,
169-
'}'
170-
]
144+
'Fn::Sub': [
145+
'{"StreamName":"${StreamName}","Data":"${Data}","PartitionKey":"${PartitionKey}"}',
146+
{
147+
StreamName: http.streamName,
148+
Data: '$util.base64Encode($input.body)',
149+
PartitionKey: `${objectRequestParam}`
150+
}
171151
]
172152
}
173153
}

0 commit comments

Comments
 (0)