Type: AWS::Serverless::StateMachine # More info about State Machine Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html
Type: Schedule # More info about Schedule Event Source: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-statemachine-schedule.html
Properties:
Description: Schedule to run the stock trading state machine every hour
Enabled: false # This schedule is disabled by default to avoid incurring charges.
Schedule: rate(1 hour)
Policies:
# Find out more about SAM policy templates: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html
- LambdaInvokePolicy:
FunctionName: !Ref StockCheckerFunction
- LambdaInvokePolicy:
FunctionName: !Ref StockSellerFunction
- LambdaInvokePolicy:
FunctionName: !Ref StockBuyerFunction
- DynamoDBWritePolicy:
TableName: !Ref TransactionTable
DefinitionUri: statemachine/stock_trader.asl.json
StockCheckerFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html
Properties:
CodeUri: functions/stock_checker/
Handler: app.lambda_handler
Runtime: python3.9
Architectures:
- x86_64
StockSellerFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: functions/stock_seller/
Handler: app.lambda_handler
Runtime: python3.9
Architectures:
- x86_64
StockBuyerFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: functions/stock_buyer/
Handler: app.lambda_handler
Runtime: python3.9
Architectures:
- x86_64
TransactionTable:
Type: AWS::Serverless::SimpleTable # More info about SimpleTable Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-simpletable.html