Created
August 25, 2019 07:05
-
-
Save nivleshc/951ff2f235a89d58d4abec6de91ef738 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: sls-${self:custom.application} | |
plugins: | |
- serverless-python-requirements | |
- serverless-prune-plugin | |
custom: | |
pythonRequirements: | |
dockerizePip: true | |
slim: true | |
noDeploy: | |
- typing | |
stage: ${opt:stage, self:custom.defaults.stage} | |
region: ${opt:region, self:custom.defaults.region} | |
application: ${env:APPLICATION, self:custom.defaults.application} | |
logRetentionInDays: ${opt:logretentionindays, env:logretentionindays, self:custom.defaults.logretentionindays} | |
s3: | |
websiteBucket: sls-${self:custom.application}-website-${self:custom.stage} | |
dynamodb: | |
transportPositionTableName: transportPosition | |
billingMode: PAY_PER_REQUEST | |
defaults: | |
application: tps | |
stage: dev | |
region: ap-southeast-2 | |
logretentionindays: 14 | |
prune: | |
automatic: true | |
number: 1 | |
provider: | |
name: aws | |
runtime: python3.7 | |
endpointType: regional | |
stage: ${self:custom.stage} | |
region: ${self:custom.region} | |
memorySize: 256 | |
timeout: 300 | |
versionFunctions: false | |
deploymentBucket: sls-${self:custom.application}-deploymentbucket | |
logRetentionInDays: ${self:custom.logRetentionInDays} | |
environment: | |
STAGE: ${self:custom.stage} | |
REGION: ${self:custom.region} | |
# define IAM roles | |
iamRoleStatements: | |
- Effect: Allow | |
Action: | |
- s3:HeadObject | |
- s3:GetObject | |
- s3:GetObjectAcl | |
- s3:PutObject | |
- s3:PutObjectAcl | |
- s3:CreateMultiPartUpload | |
Resource: | |
- arn:aws:s3:::${self:custom.s3.websiteBucket}/* | |
- Effect: Allow | |
Action: | |
- dynamodb:* | |
Resource: | |
- !GetAtt transportPositionTable.Arn | |
- !Join | |
- '' | |
- - !GetAtt transportPositionTable.Arn | |
- '/index/TripDate-GSI' | |
# you can add packaging information here | |
package: | |
include: | |
- src/csv/*.csv | |
exclude: | |
- __cache__/** | |
- __pycache__/** | |
- events/** | |
- node_modules/** | |
- 'conf/**/*' | |
- 'gulp-libs/**/*' | |
- 'yarn.lock' | |
- 'package.json' | |
- '.dotenv' | |
functions: | |
tpsFindVehiclePositionsCron: | |
handler: src.tps_vehiclepos.run | |
memorySize: 3008 | |
timeout: 900 | |
environment: | |
BUCKET: ${self:custom.s3.websiteBucket} | |
TRANSPORTPOSITION_TABLE: ${self:custom.dynamodb.transportPositionTableName} | |
events: | |
- schedule: | |
rate: cron(0/5 * * * ? *) | |
enabled: true | |
resources: | |
Description: Transport Positioning System Resources | |
Resources: | |
websiteBucket: | |
Type: AWS::S3::Bucket | |
Properties: | |
BucketName: ${self:custom.s3.websiteBucket} | |
#DynamoDB will be used to store the label that each transport will be given | |
#The label will be used as the pushpin label on the map. | |
#DynamoDB will have attributes TripDate, TripId, VehicleId, ExpirationTime(TTL), | |
#TimeAdded, Latitude, Longitude, PushpinLabel, PushPinLabelDescr | |
transportPositionTable: | |
Type: AWS::DynamoDB::Table | |
Properties: | |
TableName: ${self:custom.dynamodb.transportPositionTableName} | |
AttributeDefinitions: | |
- AttributeName: TripDate | |
AttributeType: S | |
- AttributeName: VehicleId | |
AttributeType: S | |
KeySchema: | |
- AttributeName: TripDate | |
KeyType: HASH | |
- AttributeName: VehicleId | |
KeyType: RANGE | |
BillingMode: ${self:custom.dynamodb.billingMode} | |
GlobalSecondaryIndexes: | |
- IndexName: TripDate-GSI | |
KeySchema: | |
- AttributeName: TripDate | |
KeyType: HASH | |
Projection: | |
ProjectionType: ALL | |
TimeToLiveSpecification: | |
AttributeName: ExpirationTime | |
Enabled: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment