-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
82 lines (75 loc) · 3.56 KB
/
template.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
lambda-dotnetcore3.1-step-otel
Sample SAM Template for lambda-dotnetcore3.1-step-otel
Resources:
StockTradingStateMachine:
Type: AWS::Serverless::StateMachine # More info about State Machine Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html
Properties:
DefinitionUri: statemachine/stockTrader.asl.json
DefinitionSubstitutions:
StockCheckerFunctionArn: !GetAtt StockCheckerFunction.Arn
StockSellerFunctionArn: !GetAtt StockSellerFunction.Arn
StockBuyerFunctionArn: !GetAtt StockBuyerFunction.Arn
DDBPutItem: !Sub arn:${AWS::Partition}:states:::dynamodb:putItem
DDBTable: !Ref TransactionTable
Events:
HourlyTradingSchedule:
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
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
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/StockChecker/
Handler: StockChecker::StockChecker.Function::FunctionHandler
Runtime: dotnetcore3.1
Architectures:
- x86_64
StockSellerFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./functions/StockSeller/
Handler: StockSeller::StockSeller.Function::FunctionHandler
Runtime: dotnetcore3.1
Architectures:
- x86_64
StockBuyerFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./functions/StockBuyer/
Handler: StockBuyer::StockBuyer.Function::FunctionHandler
Runtime: dotnetcore3.1
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
Properties:
PrimaryKey:
Name: Id
Type: String
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
Outputs:
# StockTradingStateMachineHourlyTradingSchedule is an implicit Schedule event rule created out of Events key under Serverless::StateMachine
# Find out more about other implicit resources you can reference within SAM
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html
StockTradingStateMachineArn:
Description: "Stock Trading State machine ARN"
Value: !Ref StockTradingStateMachine
StockTradingStateMachineRoleArn:
Description: "IAM Role created for Stock Trading State machine based on the specified SAM Policy Templates"
Value: !GetAtt StockTradingStateMachineRole.Arn