Skip to content

Instantly share code, notes, and snippets.

@igoralves1
Last active August 26, 2024 15:57
Show Gist options
  • Save igoralves1/c9923fb095abc4509f7f52890878ada8 to your computer and use it in GitHub Desktop.
Save igoralves1/c9923fb095abc4509f7f52890878ada8 to your computer and use it in GitHub Desktop.
POC
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
#
# Happy Coding!
app: hf-ctk-logger-service
service: ${self:app}-api
# app and org for use with dashboard.serverless.com
#app: your-app-name
#org: your-org-name
plugins:
- serverless-offline
# - serverless-sam
custom:
dynamodb:
# If you only want to use DynamoDB Local in some stages, declare them here
stages:
- dev
start:
port: 8000
inMemory: true
heapInitial: 200m
heapMax: 1g
migrate: true
seed: true
convertEmptyValues: true
# Uncomment only if you already have a DynamoDB running locally
# noStart: true
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
provider:
name: aws
runtime: nodejs18.x
region: us-east-1
stage: dev
role: arn:aws:iam::254161167246:role/Development-Lambda-Mktc
versionFunctions: false
deploymentBucket:
name: hf-dev-ctk-logger-service
# deploymentPrefix: ${self:app}-lambda
environment:
twilioAccountSid: AC9700ef2be8380ab9b66447b37436db66
dynatraceToken: dt0c01.5VOFMKMZHKJYLLLTFKCSG7EG.IBXS3JLRMEBYEA7OQJ7AUSVBWKG3UYCD5RXHJQK73YRDGRDDWHXU2YOEU66PNUR3
dynatraceUrl: https://lqs50241.live.dynatrace.com/api/v2/logs/ingest
environment: dev
logLevel: info
SHARD_ID: shardId-000000000000
STREAM_NAME: cde-twilio-stream-flex-dev
STREAM_NAME_CUSTOM: cde-twilio-stream-custom-dev
STREAM_ENDPOINT: http://0.0.0.0:4567
DB_ENDPOINT: http://localhost:8000
DB_TABLE_NAME: CdeTwilioStreamFlex
KITEWHEEL_BUCKET: hf-dev-cdp-kitewheel/ctk/
package:
individually: true
functions:
healthcheck:
handler: healthcheck.handler
#versionLambda: false
events:
- http:
path: /healthcheck
method: get
cors: true
sendEvents:
handler: sendEvents.handler
#versionLambda: false
events:
- http:
path: /log
method: post
cors: true
consumer:
handler: streamConsumer.handler
role: arn:aws:iam::254161167246:role/KinesisProcessStreamRole
#versionLambda: false
events:
- stream:
arn: arn:aws:kinesis:us-west-1:421808740284:stream/${self:provider.environment.STREAM_NAME}
batchSize: 100
startingPosition: TRIM_HORIZON
taskrouter:
handler: streamTaskrouter.handler
role: arn:aws:iam::254161167246:role/KinesisProcessStreamRole
#versionLambda: false
events:
- stream:
arn: arn:aws:kinesis:us-west-1:421808740284:stream/${self:provider.environment.STREAM_NAME}
batchSize: 100
startingPosition: TRIM_HORIZON
producer:
handler: streamProducer.handler
role: arn:aws:iam::254161167246:role/KinesisProcessStreamRole
events:
- http:
path: /customstream/log
method: post
cors: true
callLogSearch:
handler: callLogSearch.handler
events:
- http:
path: /call-log/search
method: post
cors: true
callLogDetail:
handler: callLogDetail.handler
events:
- http:
path: /call-log/detail/{id}
method: post
cors: true
blob-upload:
handler: blobUpload.handler
role: arn:aws:iam::254161167246:role/KinesisProcessStreamRole
events:
- http:
path: /blob/upload
method: post
cors: true
resources: # CloudFormation template syntax from here on.
Resources:
usersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: CdeTwilioStreamFlexDev
AttributeDefinitions:
- AttributeName: ShardId
AttributeType: S
- AttributeName: ApproximateArrivalTimestamp
AttributeType: N
KeySchema:
- AttributeName: ShardId
KeyType: HASH
- AttributeName: ApproximateArrivalTimestamp
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
KinesisProcessStreamRole:
Type: AWS::IAM::Role
Properties:
RoleName: KinesisProcessStreamRole # required if you want to use 'serverless deploy --function' later on
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
# note that these rights are needed if you want your function to be able to communicate with resources within your vpc
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole
Policies:
- PolicyName: KinesisProcessStreamPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow # note that these rights are given in the default policy and are required if you want logs out of your lambda(s)
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
- logs:TagResource
Resource:
- 'Fn::Join':
- ':'
-
- 'arn:aws:logs'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- 'log-group:/aws/lambda/*:*:*'
- Effect: "Allow"
Action:
- "kinesis:GetRecords"
- "kinesis:GetShardIterator"
- "kinesis:DescribeStream"
- "kinesis:ListStreams"
Resource:
- 'Fn::Join':
- ':'
-
- 'arn:aws:kinesis'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- 'stream/cde-twilio-stream-flex-dev'
- Effect: "Allow"
Action:
- "dynamodb:PutItem"
Resource:
- 'Fn::Join':
- ':'
-
- 'arn:aws:dynamodb'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- 'table/CdeTwilioStreamFlexDev'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment