Help us understand the problem. What is going on with this article?

[JAWS-UG CLI] Amazon Kinesis Firehose re:入門 (2) Delivery Streamの作成

More than 3 years have passed since last update.

この記事について

JAWS-UG CLI専門支部 #90 Kinesis Firehose 復習編で実施するハンズオン用の手順書です。

前提条件

必要な権限

作業にあたっては、以下の権限を有したIAMユーザもしくはIAMロールを利用してください。

  • 以下のサービスに対するフルコントロール権限
    • Kinesis Firehose
    • IAM
    • EC2
    • S3
    • CloudWatch Logs
    • STS
    • (Lambda)
      • データの変換を行う場合
    • (KMS)
      • データの暗号化を行う場合

0. 準備

0.1. リージョンを指定

オレゴンリージョンで実施します。(東京マダー?)

コマンド
export AWS_DEFAULT_REGION="us-west-2"

0.2. 資格情報を確認

コマンド
aws configure list

インスタンスプロファイルを設定したEC2インスタンスでアクセスキーを設定せずに実行した場合、以下のようになります。

結果
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************QSAA         iam-role
secret_key     ****************c1xY         iam-role
    region                us-west-2              env    AWS_DEFAULT_REGION

0.3. バージョン確認

コマンド
aws --version
結果
aws-cli/1.11.129 Python/2.7.12 Linux/4.9.38-16.33.amzn1.x86_64 botocore/1.5.92

0.4. バージョンアップ(必要に応じて)

コマンド
sudo pip install -U awscli

0.5. 変数の確認

コマンド
cat << ETX

    ROLE_ARN: ${ROLE_ARN}
    BUCKET_NAME: ${BUCKET_NAME}

ETX

1. Delivery Streamの作成

1.1. 設定ファイルの作成

Delivery Stream名の指定

コマンド
DELIVERY_STREAM_NAME="jawsug-cli-stream"

定義ファイル名の指定

コマンド
S3_DESTINATION_FILE_NAME="s3_destination_configuration.json"

バッファサイズの指定

コマンド
BUFFER_SIZE=1

バッファインターバルの指定

コマンド
BUFFER_INTERVAL=60

ロググループ名およびログストリーム名の指定

コマンド
LOG_GROUP_NAME="/aws/kinesisfirehose/${DELIVERY_STREAM_NAME}"
LOG_STREAM_NAME="S3Delivery"

変数を確認

コマンド
cat << ETX

    S3_DESTINATION_FILE_NAME: ${S3_DESTINATION_FILE_NAME}
    ROLE_ARN: ${ROLE_ARN}
    BUCKET_NAME: ${BUCKET_NAME}
    BUFFER_SIZE: ${BUFFER_SIZE}
    BUFFER_INTERVAL: ${BUFFER_INTERVAL}
    LOG_GROUP_NAME: ${LOG_GROUP_NAME}
    LOG_STREAM_NAME: ${LOG_STREAM_NAME}

ETX
結果
    S3_DESTINATION_FILE_NAME: s3_destination_configuration.json
    ROLE_ARN: arn:aws:iam::XXXXXXXXXXXX:role/service-role-firehose
    BUCKET_NAME: firehose-jawsug-cli-s3bucket-134czh3hcofqz
    BUFFER_SIZE: 1
    BUFFER_INTERVAL: 60
    LOG_GROUP_NAME: /aws/kinesisfirehose/jawsug-cli-stream
    LOG_STREAM_NAME: S3Delivery

定義を生成

コマンド
cat << EOF > ${S3_DESTINATION_FILE_NAME}
{
  "RoleARN": "${ROLE_ARN}",
  "BucketARN": "arn:aws:s3:::${BUCKET_NAME}",
  "Prefix": "",
  "BufferingHints": {
    "SizeInMBs": ${BUFFER_SIZE},
    "IntervalInSeconds": ${BUFFER_INTERVAL}
  },
  "CompressionFormat": "UNCOMPRESSED",
  "EncryptionConfiguration": {
    "NoEncryptionConfig": "NoEncryption"
  },
  "CloudWatchLoggingOptions": {
    "Enabled": true,
    "LogGroupName": "${LOG_GROUP_NAME}",
    "LogStreamName": "${LOG_STREAM_NAME}"
  }
}
EOF

cat ${S3_DESTINATION_FILE_NAME}
結果
{
  "RoleARN": "arn:aws:iam::************:role/service-role-firehose",
  "BucketARN": "arn:aws:s3:::jawsug-cli-firehose-************",
  "Prefix": "",
  "BufferingHints": {
    "SizeInMBs": ,
    "IntervalInSeconds":
  },
  "CompressionFormat": "UNCOMPRESSED",
  "EncryptionConfiguration": {
    "NoEncryptionConfig": "NoEncryption"
  },
  "CloudWatchLoggingOptions": {
    "Enabled": true,
    "LogGroupName": "jawsug-cli-firehose",
    "LogStreamName": "handson"
  }
}

JSONファイルを検証

コマンド
jsonlint -q ${S3_DESTINATION_FILE_NAME}

1.2. Delivery Streamの作成

パラメータの確認

コマンド
cat << ETX

   DELIVERY_STREAM_NAME: "${DELIVERY_STREAM_NAME}"
   S3_DESTINATION_FILE_NAME: "${S3_DESTINATION_FILE_NAME}"

ETX
結果
   DELIVERY_STREAM_NAME: "jawsug-cli-stream"
   S3_DESTINATION_FILE_NAME: "s3-destination.json"

Delivery Streamの作成

コマンド
aws firehose create-delivery-stream \
    --delivery-stream-name ${DELIVERY_STREAM_NAME} \
    --s3-destination-configuration file://${S3_DESTINATION_FILE_NAME}
結果
{
    "DeliveryStreamARN": "arn:aws:firehose:us-west-2:************:deliverystream/jawsug-cli-stream"
}

Delivery Streamの確認

デリバリーストリームのステータスがACTIVEになってから次の手順を実行してください。

コマンド
aws firehose describe-delivery-stream \
    --delivery-stream-name ${DELIVERY_STREAM_NAME}
結果
{
    "DeliveryStreamDescription": {
        "HasMoreDestinations": false,
        "VersionId": "1",
        "CreateTimestamp": 1478329794.659,
        "DeliveryStreamARN": "arn:aws:firehose:us-west-2:************:deliverystream/jawsug-cli-stream",
        "DeliveryStreamStatus": "ACTIVE",
        "DeliveryStreamName": "jawsug-cli-stream",
        "Destinations": [
            {
                "DestinationId": "destinationId-000000000001",
                "S3DestinationDescription": {
                    "RoleARN": "arn:aws:iam::************:role/service-role-firehose",
                    "Prefix": "",
                    "BufferingHints": {
                        "IntervalInSeconds": 60,
                        "SizeInMBs": 1
                    },
                    "EncryptionConfiguration": {
                        "NoEncryptionConfig": "NoEncryption"
                    },
                    "CompressionFormat": "UNCOMPRESSED",
                    "CloudWatchLoggingOptions": {
                        "Enabled": true,
                        "LogStreamName": "handson",
                        "LogGroupName": "jawsug-cli-firehose"
                    },
                    "BucketARN": "arn:aws:s3:::jawsug-cli-firehose-************"
                }
            }
        ]
    }
}

以上

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした