-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
177 lines (166 loc) · 5.17 KB
/
template.yaml
File metadata and controls
177 lines (166 loc) · 5.17 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: FAME Agent - FaaS-based Agentic MCP Engine for FinOps
Parameters:
BedrockApiKeyParameter:
Type: AWS::SSM::Parameter::Value<String>
Default: /finops/bedrock-api-key
Description: SSM Parameter containing Bedrock API key (create via: aws ssm put-parameter --name /finops/bedrock-api-key --value "ABSK..." --type SecureString)
Globals:
Function:
Runtime: python3.11
Timeout: 60
MemorySize: 256
Resources:
# --- DynamoDB Table ---
FameAgentMemoryTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: FameAgentMemory
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: session_id
AttributeType: S
- AttributeName: invocation_id
AttributeType: S
KeySchema:
- AttributeName: session_id
KeyType: HASH
- AttributeName: invocation_id
KeyType: RANGE
Tags:
- Key: Application
Value: FameAgent
# --- S3 Bucket for Actor Cache ---
FameCacheBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub "fame-agent-cache-${AWS::AccountId}-${AWS::Region}"
LifecycleConfiguration:
Rules:
- Id: ExpireCache
Status: Enabled
ExpirationInDays: 7
Prefix: cache/
Tags:
- Key: Application
Value: FameAgent
# --- Lambda: Planner ---
PlannerFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: FamePlanner
CodeUri: src/
Handler: handlers.planner.lambda_handler
Environment:
Variables:
FAME_MEMORY_TABLE: !Ref FameAgentMemoryTable
AWS_BEARER_TOKEN_BEDROCK: !Ref BedrockApiKeyParameter
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref FameAgentMemoryTable
- Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- bedrock:InvokeModel
Resource: "*"
- Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- ssm:GetParameter
- ssm:GetParameters
Resource: !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/finops/*"
# --- Lambda: Actor ---
ActorFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: FameActor
CodeUri: src/
Handler: handlers.actor.lambda_handler
Environment:
Variables:
FAME_CACHE_BUCKET: !Ref FameCacheBucket
Policies:
- S3CrudPolicy:
BucketName: !Ref FameCacheBucket
# --- Lambda: Evaluator ---
EvaluatorFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: FameEvaluator
CodeUri: src/
Handler: handlers.evaluator.lambda_handler
Environment:
Variables:
FAME_MEMORY_TABLE: !Ref FameAgentMemoryTable
AWS_BEARER_TOKEN_BEDROCK: !Ref BedrockApiKeyParameter
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref FameAgentMemoryTable
- Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- bedrock:InvokeModel
Resource: "*"
- Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- ssm:GetParameter
- ssm:GetParameters
Resource: !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/finops/*"
# --- Step Functions State Machine ---
FameStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
Name: FameAgentStateMachine
DefinitionUri: statemachine.asl.json
Role: !GetAtt FameStateMachineRole.Arn
DefinitionSubstitutions:
PlannerArn: !GetAtt PlannerFunction.Arn
ActorArn: !GetAtt ActorFunction.Arn
EvaluatorArn: !GetAtt EvaluatorFunction.Arn
Logging:
Level: ALL
IncludeExecutionData: true
Destinations:
- CloudWatchLogsLogGroup:
LogGroupArn: !GetAtt FameStateMachineLogGroup.Arn
Policies:
- Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- lambda:InvokeFunction
Resource:
- !GetAtt PlannerFunction.Arn
- !GetAtt ActorFunction.Arn
- !GetAtt EvaluatorFunction.Arn
FameStateMachineRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: states.amazonaws.com
Action: sts:AssumeRole
FameStateMachineLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "/aws/stepfunctions/${FameStateMachine}"
RetentionInDays: 7
Outputs:
FameStateMachineArn:
Description: Step Functions state machine ARN
Value: !Ref FameStateMachine
FameCacheBucketName:
Description: S3 bucket for Actor cache
Value: !Ref FameCacheBucket
FameMemoryTableName:
Description: DynamoDB table for session memory
Value: !Ref FameAgentMemoryTable