[AWS] API Gateway - KDS - KDF - S3

on_cloud·2023년 3월 30일
0

AWS

목록 보기
6/13
post-thumbnail

IAM


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"
    }
  ]
}

Kinesis Data Streams


create Kinesis Data Streams


API Gateway


  1. API Gateway -> Crewate API -> Rest API -> Create API
  2. API Gateway -> Actions -> Create Method -> POST

  1. API Gateway -> Intergration Request -> HTTP Headers
    Content-Type = 'application/x-amz-json-1.1'

  2. API Gateway -> Intergration Request -> Mapping Templates
    Content-Type : application/json

  1. API Gateway -> Intergration Request -> Mapping Templates -> application/json
{
  "StreamName": "$input.params('stream')",
  "Data": "$util.base64Encode($input.body)",
  "PartitionKey": "$context.requestId"
}
  1. API Gateway -> Method Request -> Request Validator

  2. API Gateway -> Method Request -> Request Body
    Content-Type : application/json
    Model name : Empty

  3. API Gateway -> Method Request -> URL Query String
    Name : Stream


S3


aws s3 mb s3://<s3 bucket name> --region <region>

Kinesis Data Firehose

Source settings : KDS
S3 Bucket : S3 Bucket


TEST


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”}

0개의 댓글