- 指定 Timeline の Tweet の分析をする(感情など)
- AWS 上で構築する
Twitter Developer Platform で App を作る。
- Access token
- Access token secret
審査があるので説明は詳しく書く。
- raw
- sentiment
- entities
- Policy: Tweet-Dashboard-Firehose
- S3 bucket の List,Read,Write Action
- CloudWatch Logs の List,Write Action
- Role: Tweet-Dashboard-Firehose-Policy
- Create Delivery Stream in {raw/,sentiment/,entities/}
- Tweet-Dashboard-$prefix とする
- S3 bucket ARN + prefix: $prefix
- Buffer conditions: Interval 60sec
- TwitteAPI-Secrets を Generate する
- ConsumerApiKey
- ConsumerApiSecret
- AccessToken
- AccessTokenSecret
- Network gateway, routing, IAM policy など IaC で
- yaml
- Spec
- t4g.nano
- 設定
- npm init
- npm install aws-sdk twitter-lite
- node twitter_reader.js を systemd で回す
- /etc/systemd/system に twrd.service を配置
- systemctl enable twrd
- systemctl start twrd
- S3 bucket raw/ にデータが溜まっていく
- TweetAnalysisLambdaFunctionRole
- TweetAnalysisLambdaFunctionPolicy
- lambda_iam.yaml
- lambda_function.py
- S3 bucket を Comprehend にわたす
- Delivery Stream Name については SENTIMENT_STREAM, ENTITY_STREAM 環境変数にて渡
- TweetAnalysisLambdaFunctionRole をつける
- Timeout 5min
- S3 bucket sentiment, entities に結果が蓄積される
- 動的フレーム作成(Spark と違い初期 Schema 不要)
- glue_table.yaml
- Database: twitter_timeline_dashboard
- tweets
- tweet_sentiments
- tweet_entities
- s3://twitter_timeline_dashboard/
select * from tweet_sentiments limit 10;
select * from tweet_entities limit 10;- S3 bucket を選択
- 分析を作成
