Kinesis Put Record - Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"kinesis:PutRecord",
"kinesis:DescribeStreamSummary"
],
"Resource": "*"
}
]
}
API Gateway - Kinesis Role
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "apigateway.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
create Kinesis Data Streams
API Gateway -> Intergration Request -> HTTP Headers
Content-Type = 'application/x-amz-json-1.1'
API Gateway -> Intergration Request -> Mapping Templates
Content-Type : application/json
{
"StreamName": "$input.params('stream')",
"Data": "$util.base64Encode($input.body)",
"PartitionKey": "$context.requestId"
}
API Gateway -> Method Request -> Request Validator
API Gateway -> Method Request -> Request Body
Content-Type : application/json
Model name : Empty
API Gateway -> Method Request -> URL Query String
Name : Stream
aws s3 mb s3://<s3 bucket name> --region <region>
Source settings : KDS
S3 Bucket : S3 Bucket
input Data
curl \
-X POST \
-H "Content-Type: application/json" \
-d '{
"name": "test",
"age": "41",
"time": 2023-02-21 14:30:26,
'} \
https://<API Gateway url>/<deploy>?stream=<kds name>
Result
ex) {“SequenceNumber”:”aaabbbccc”,”ShardId”:”shardId-000000000000”}