- 浏览: 2550674 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
AMAZON Kinesis Firehose 2019(1)Firehose Buffer to S3
Some final references to create the project
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Firehose.html
https://github.com/danielsan/firehose-nodejs-example
https://forum.serverless.com/t/creating-a-kinesis-firehose-stream-in-serverless-yaml-with-iamrolelambdaexecution-role/2366
https://github.com/otofu-square/serverless-kinesis-firehose/blob/master/serverless.yml
https://github.com/mikepatrick/kinesis-log-aggregator-demo
https://github.com/phodal/serverless/blob/02a067088cb37d294074b334777a4ca4175f737c/firehose/handler.js
Examples
http://serverless.ink/#serverless-%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90kinesis-firehose-%E6%8C%81%E4%B9%85%E5%8C%96%E6%95%B0%E6%8D%AE%E5%88%B0-s3
http://serverless.ink/#serverless-kinesis-firehose-%E4%BB%A3%E7%A0%81
http://serverless.ink/#%E5%AE%89%E8%A3%85%E5%8F%8A%E6%B5%8B%E8%AF%95
Give region in the new construction
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Kinesis.html#constructor-property
More example here
https://github.com/phodal/serverless
Nothing special in the package.json for dependency
"devDependencies": {
"@types/aws-lambda": "^8.10.31",
"@types/node": "^8.0.57",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"aws-sdk": "^2.518.0",
"eslint": "^6.2.2",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-prettier": "^3.1.0",
"prettier": "^1.18.2",
"serverless": "^1.50.1",
"serverless-webpack": "^4.4.0",
"ts-loader": "^2.3.7",
"tslint": "^5.19.0",
"typescript": "^3.5.3",
"webpack": "^3.12.0"
}
Use the serverless.yml to create the resource
plugins:
- serverless-webpack
custom:
stage: ${opt:stage, 'stage'}
regionByStage:
int: us-west-1
stage: us-west-1
prod: us-west-2
resource_region: ${self:custom.regionByStage.${self:custom.stage}}
deploy_region: ${opt:region, self:custom.regionByStage.${self:custom.stage}}
eventBusArn: ${cf:eventBus-${opt:stage, self:provider.stage}.SNSTopic}
datawarehouses3: 'datawarehouse-${self:custom.stage}-events'
persists3bucketname: 'datawarehouse-${self:custom.stage}-events'
functions:
postEventHandler:
handler: src/eventHandler.postEvents
resources:
Resources:
FirehoseToS3Role:
Type: AWS::IAM::Role
Properties:
RoleName: FirehoseToS3Role
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- firehose.amazonaws.com
Action:
- sts:AssumeRole
Policies:
- PolicyName: FirehoseToS3Policy
PolicyDocument:
Statement:
- Effect: Allow
Action:
- s3:AbortMultipartUpload
- s3:GetBucketLocation
- s3:GetObject
- s3:ListBucket
- s3:ListBucketMultipartUploads
- s3:PutObject
Resource: '*'
ServerlessKinesisFirehoseBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Properties:
BucketName: ${self:provider.environment.PERSIST_S3_BUCKET_NAME}
ServerlessKinesisFirehose:
Type: AWS::KinesisFirehose::DeliveryStream
Properties:
DeliveryStreamName: ${self:provider.environment.DELIVERY_STREAM_NAME}
S3DestinationConfiguration:
BucketARN:
Fn::Join:
- ''
- - 'arn:aws:s3:::'
- Ref: ServerlessKinesisFirehoseBucket
BufferingHints:
IntervalInSeconds: "60"
SizeInMBs: "1"
CompressionFormat: "UNCOMPRESSED"
Prefix: "raw/"
RoleARN: { Fn::GetAtt: [ FirehoseToS3Role, Arn ] }
The util.ts to send out the string to firehose is as easy as follow:
import * as AWS from 'aws-sdk';
const region = process.env.REGION;
const deliveryStreamName = process.env.DELIVERY_STREAM_NAME;
const firehose = new AWS.Firehose( { region: region } );
export const sendFirehose = async (bodyMsg: string) => {
const params = {
DeliveryStreamName: deliveryStreamName,
Record: {
Data: new Buffer(bodyMsg)
}
};
return firehose.putRecord(params).promise()
};
Handler to receive the POST events
import { SNSEvent, Handler, APIGatewayEvent, Context, Callback } from 'aws-lambda';
import { get } from 'lodash';
import { EventAction } from ‘@sillycat/eventbus';
import { sendFirehose } from './util';
export const postEvents: Handler = async (event: APIGatewayEvent, context: Context, callBack: Callback) => {
console.log("event received:" + JSON.stringify(event));
try {
await sendFirehose(JSON.stringify(event.body));
callBack(null, { 'statusCode': 200, 'body': 'Successful POST' });
} catch (err) {
callBack(err);
}
}
References:
https://stackoverflow.com/questions/55714834/push-from-lambda-to-s3-or-push-from-lambda-to-kinesis-firehose-to-s3
https://fivetran.com/docs/files/aws-kinesis
https://github.com/SumoLogic/sumologic-aws-lambda/tree/master/kinesisfirehose-processor
https://towardsdatascience.com/delivering-real-time-streaming-data-to-amazon-s3-using-amazon-kinesis-data-firehose-2cda5c4d1efe
https://aws.amazon.com/blogs/compute/amazon-kinesis-firehose-data-transformation-with-aws-lambda/
https://aws.amazon.com/kinesis/data-firehose/faqs/
https://github.com/alexcasalboni/serverless-data-pipeline-sam
NodeJS Document
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Firehose.html
Old Example
https://github.com/otofu-square/serverless-kinesis-firehose
Some final references to create the project
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Firehose.html
https://github.com/danielsan/firehose-nodejs-example
https://forum.serverless.com/t/creating-a-kinesis-firehose-stream-in-serverless-yaml-with-iamrolelambdaexecution-role/2366
https://github.com/otofu-square/serverless-kinesis-firehose/blob/master/serverless.yml
https://github.com/mikepatrick/kinesis-log-aggregator-demo
https://github.com/phodal/serverless/blob/02a067088cb37d294074b334777a4ca4175f737c/firehose/handler.js
Examples
http://serverless.ink/#serverless-%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90kinesis-firehose-%E6%8C%81%E4%B9%85%E5%8C%96%E6%95%B0%E6%8D%AE%E5%88%B0-s3
http://serverless.ink/#serverless-kinesis-firehose-%E4%BB%A3%E7%A0%81
http://serverless.ink/#%E5%AE%89%E8%A3%85%E5%8F%8A%E6%B5%8B%E8%AF%95
Give region in the new construction
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Kinesis.html#constructor-property
More example here
https://github.com/phodal/serverless
Nothing special in the package.json for dependency
"devDependencies": {
"@types/aws-lambda": "^8.10.31",
"@types/node": "^8.0.57",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"aws-sdk": "^2.518.0",
"eslint": "^6.2.2",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-prettier": "^3.1.0",
"prettier": "^1.18.2",
"serverless": "^1.50.1",
"serverless-webpack": "^4.4.0",
"ts-loader": "^2.3.7",
"tslint": "^5.19.0",
"typescript": "^3.5.3",
"webpack": "^3.12.0"
}
Use the serverless.yml to create the resource
plugins:
- serverless-webpack
custom:
stage: ${opt:stage, 'stage'}
regionByStage:
int: us-west-1
stage: us-west-1
prod: us-west-2
resource_region: ${self:custom.regionByStage.${self:custom.stage}}
deploy_region: ${opt:region, self:custom.regionByStage.${self:custom.stage}}
eventBusArn: ${cf:eventBus-${opt:stage, self:provider.stage}.SNSTopic}
datawarehouses3: 'datawarehouse-${self:custom.stage}-events'
persists3bucketname: 'datawarehouse-${self:custom.stage}-events'
functions:
postEventHandler:
handler: src/eventHandler.postEvents
resources:
Resources:
FirehoseToS3Role:
Type: AWS::IAM::Role
Properties:
RoleName: FirehoseToS3Role
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- firehose.amazonaws.com
Action:
- sts:AssumeRole
Policies:
- PolicyName: FirehoseToS3Policy
PolicyDocument:
Statement:
- Effect: Allow
Action:
- s3:AbortMultipartUpload
- s3:GetBucketLocation
- s3:GetObject
- s3:ListBucket
- s3:ListBucketMultipartUploads
- s3:PutObject
Resource: '*'
ServerlessKinesisFirehoseBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Properties:
BucketName: ${self:provider.environment.PERSIST_S3_BUCKET_NAME}
ServerlessKinesisFirehose:
Type: AWS::KinesisFirehose::DeliveryStream
Properties:
DeliveryStreamName: ${self:provider.environment.DELIVERY_STREAM_NAME}
S3DestinationConfiguration:
BucketARN:
Fn::Join:
- ''
- - 'arn:aws:s3:::'
- Ref: ServerlessKinesisFirehoseBucket
BufferingHints:
IntervalInSeconds: "60"
SizeInMBs: "1"
CompressionFormat: "UNCOMPRESSED"
Prefix: "raw/"
RoleARN: { Fn::GetAtt: [ FirehoseToS3Role, Arn ] }
The util.ts to send out the string to firehose is as easy as follow:
import * as AWS from 'aws-sdk';
const region = process.env.REGION;
const deliveryStreamName = process.env.DELIVERY_STREAM_NAME;
const firehose = new AWS.Firehose( { region: region } );
export const sendFirehose = async (bodyMsg: string) => {
const params = {
DeliveryStreamName: deliveryStreamName,
Record: {
Data: new Buffer(bodyMsg)
}
};
return firehose.putRecord(params).promise()
};
Handler to receive the POST events
import { SNSEvent, Handler, APIGatewayEvent, Context, Callback } from 'aws-lambda';
import { get } from 'lodash';
import { EventAction } from ‘@sillycat/eventbus';
import { sendFirehose } from './util';
export const postEvents: Handler = async (event: APIGatewayEvent, context: Context, callBack: Callback) => {
console.log("event received:" + JSON.stringify(event));
try {
await sendFirehose(JSON.stringify(event.body));
callBack(null, { 'statusCode': 200, 'body': 'Successful POST' });
} catch (err) {
callBack(err);
}
}
References:
https://stackoverflow.com/questions/55714834/push-from-lambda-to-s3-or-push-from-lambda-to-kinesis-firehose-to-s3
https://fivetran.com/docs/files/aws-kinesis
https://github.com/SumoLogic/sumologic-aws-lambda/tree/master/kinesisfirehose-processor
https://towardsdatascience.com/delivering-real-time-streaming-data-to-amazon-s3-using-amazon-kinesis-data-firehose-2cda5c4d1efe
https://aws.amazon.com/blogs/compute/amazon-kinesis-firehose-data-transformation-with-aws-lambda/
https://aws.amazon.com/kinesis/data-firehose/faqs/
https://github.com/alexcasalboni/serverless-data-pipeline-sam
NodeJS Document
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Firehose.html
Old Example
https://github.com/otofu-square/serverless-kinesis-firehose
发表评论
-
Update Site will come soon
2021-06-02 04:10 1676I am still keep notes my tech n ... -
Stop Update Here
2020-04-28 09:00 314I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 474NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 367Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 367Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 335Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 429Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 434Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 373Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 453VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 384Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 475NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 421Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 336Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 246GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 450GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 325GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 312Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 317Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 291Serverless with NodeJS and Tenc ...
相关推荐
Amazon Kinesis Firehose具有简单,自动缩放和零操作要求,从而简化了向Amazon S3和Amazon Redshift的流数据交付。 在客户拥有基于流接口构建的现有系统的情况下,添加Firehose可以实现简单的存档,或用于促进对...
此模块创建Kinesis Firehose以及与之相关的所有资源以登录到S3。 用法 检出以了解如何使用此模块 作者 由管理的模块。 执照 麻省理工学院许可。 有关完整详细信息,请参见 。 要求 名称 版本 地貌 > = 0.13 ws 〜>...
此代码在AWS中创建[Kinesis Firehose]('(' '),以将CloudWatch日志数据发送到S3。 用法 module "kinesis-firehose" { source = "git::...
Amazon Kinesis Firehose 能够将消息转换、批处理、存档到 S3,并在目标不可用时重试。 Kafka-Kinesis-Connector for Kinesis 用于将消息从 Kafka 发布到 Amazon Kinesis Streams。 Kafka-Kinesis-Connector 可以...
Amazon Kinesis代理Amazon Kinesis Agent是一个独立的Java软件应用程序,它提供了一种更简便的方法来收集数据并将其吸收到服务中,包括和 。特征监视文件模式并将新的数据记录发送到传递流处理文件旋转,检查点并在...
一个使用nodejs和Amazon Kinesis Firehose的示例,您可以在阅读有关文章 启动服务器 npm start 执行测试 npm test 用运动学执行测试 NODE_AWS_KEY=********* NODE_AWS_SECRET=************************** NODE_AWS_...
雅典娜用例2019年7月更新目录概述你会完成什么先决条件创建您的Reddit机器人帐户设置一个S3存储桶在CloudFormation中部署AWS Glue数据目录设置Kinesis Firehose交付流为您的流服务器创建密钥对在CloudFormation中...
亚马逊运动数据生成器轻松将数据发送到您的Kinesis Stream或Kinesis Firehose关于Amazon Kinesis Data Generator是一个UI,可简化您将测试数据发送到Amazon Kinesis Streams或Amazon Kinesis Firehose的方式。...
通过Kinesis Firehose将CloudWatch日志发送到Splunk 此模块配置Kinesis Firehose,为Firehose设置所需CloudWatch Log Group的订阅,并将日志数据发送到Splunk。 需要Lambda函数才能将CloudWatch Log数据从“ Cloud...
amazon-kinesis-producer, 亚马逊Kinesis制作库 室Producer库简介在亚马逊 Kinesis Producer Producer Producer Producer Producer Producer Producer performs performs performs per
无服务器数据管道-由AWS SAM提供支持使用Amazon API Gateway,AWS Lambda,Amazon Kinesis Firehose,Amazon S3和Amazon Athena构建无服务器数据管道。如何部署堆栈请参阅scripts/deploy.sh (自定义部署存储桶和...
用于将 Amazon Kinesis 数据复制到 S3 的应用程序。 用法 配置您的应用程序(从模板KinesisToS3.SAMPLE.properties开始) 配置 AWS 访问凭证: 在本地,设置任一 环境变量AWS_ACCESS_KEY_ID=xxx和AWS_SECRET_KEY=...
一个示例项目,演示了如何通过Kinesis Firehose将Lambda和API Gateway Cloudwatch日志流式传输到S3。 部署: yarn sls deploy --stage dev IAM注意事项: API Gateway必须具有配置的角色,以允许其将日志推送到...
适用于出价请求的AWS无... 表中的内容架构概述先决条件实验部署下载必要的数据生成CDK应用程序部署堆栈并上传数据部署Amazon QuickSight 准备清单文件报名创建数据集探索演示启动实验启动制作人启动Kinesis Data Analyt
2017年最新的AWS实践类图书,理解云计算有帮助,英文版
我使用的一些AWS服务包括AWS IoT,Lambda,API Gateway,Kinesis Firehose,S3和QuickSight,用于处理,存储和可视化传入的医疗传感器数据,这些数据是使用AWS Boto3 Python软件包和AWS CLI进行模拟的。 在整个项目...
支持任意适配器的Amazon Kinesis Data Firehose可配置队列。 动机 当您想与Amazon Kinesis Data Firehose集成时,您很可能希望对您执行的请求进行批处理,以不超过Amazon的限制。 因此,理想情况下,您将拥有一个...
虽然您无法在AWS控制台中配置跨帐户Kinesis Firehose(尚未),但您可以设置跨帐户Firehoses(如我们在此处所做的那样)。 在竞选期间,Redhook负责向数据团队提供所有财务数据和Web分析。 它的运行成本几乎为零,...