-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtemplate.yaml
More file actions
156 lines (142 loc) · 4.44 KB
/
Copy pathtemplate.yaml
File metadata and controls
156 lines (142 loc) · 4.44 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
auto-pr-bot
Automates open source contributions by forking, modifying, and creating PRs
Globals:
Function:
Timeout: 300 # 5 minutes for git operations
MemorySize: 1024 # Increased for git operations and LLM calls
LoggingConfig:
LogFormat: JSON
Resources:
# DynamoDB Table for Status Tracking and Rate Limiting
StatusTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: auto-pr-bot-status
AttributeDefinitions:
- AttributeName: requestId
AttributeType: S
- AttributeName: ipAddress
AttributeType: S
- AttributeName: timestamp
AttributeType: N
KeySchema:
- AttributeName: requestId
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: IpAddressIndex
KeySchema:
- AttributeName: ipAddress
KeyType: HASH
- AttributeName: timestamp
KeyType: RANGE
Projection:
ProjectionType: ALL
BillingMode: PAY_PER_REQUEST
TimeToLiveSpecification:
Enabled: true
AttributeName: expiresAt
AutoPRBotFunction:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
Architectures:
- x86_64
Events:
ProcessRepository:
Type: Api
Properties:
Path: /process
Method: POST
RestApiId: !Ref AutoPRBotApi
Policies:
- Statement:
- Effect: Allow
Action:
- lambda:InvokeFunction
Resource: !Sub 'arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AWS::StackName}-AutoPRBotFunction-*'
- Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:Query
Resource:
- !GetAtt StatusTable.Arn
- !Sub '${StatusTable.Arn}/index/*'
Environment:
Variables:
GITHUB_TOKEN: "" # Will be overridden by env.json locally or Parameter Store in production
OPENAI_API_KEY: "" # Will be overridden by env.json locally or Parameter Store in production
STATUS_TABLE_NAME: !Ref StatusTable
Metadata:
DockerTag: go1.x-v1
DockerContext: ./hello-world
Dockerfile: Dockerfile
StatusFunction:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
Architectures:
- x86_64
Events:
GetStatus:
Type: Api
Properties:
Path: /status/{requestId}
Method: GET
RestApiId: !Ref AutoPRBotApi
Policies:
- Statement:
- Effect: Allow
Action:
- dynamodb:GetItem
Resource: !GetAtt StatusTable.Arn
Environment:
Variables:
STATUS_TABLE_NAME: !Ref StatusTable
Metadata:
DockerTag: go1.x-v1
DockerContext: ./hello-world
Dockerfile: Dockerfile
AutoPRBotApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
Cors:
AllowMethods: "'GET, POST, OPTIONS'"
AllowHeaders: "'Content-Type'"
AllowOrigin: "'*'"
ApplicationResourceGroup:
Type: AWS::ResourceGroups::Group
Properties:
Name:
Fn::Sub: ApplicationInsights-SAM-${AWS::StackName}
ResourceQuery:
Type: CLOUDFORMATION_STACK_1_0
ApplicationInsightsMonitoring:
Type: AWS::ApplicationInsights::Application
Properties:
ResourceGroupName:
Ref: ApplicationResourceGroup
AutoConfigurationEnabled: 'true'
Outputs:
AutoPRBotAPI:
Description: API Gateway endpoint URL for Auto PR Bot
Value: !Sub "https://${AutoPRBotApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/process"
StatusAPI:
Description: API Gateway endpoint URL for Status checks
Value: !Sub "https://${AutoPRBotApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/status/{requestId}"
AutoPRBotFunction:
Description: Auto PR Bot Lambda Function ARN
Value: !GetAtt AutoPRBotFunction.Arn
StatusFunction:
Description: Status Lambda Function ARN
Value: !GetAtt StatusFunction.Arn
AutoPRBotFunctionIamRole:
Description: Implicit IAM Role created for Auto PR Bot function
Value: !GetAtt AutoPRBotFunctionRole.Arn
StatusTable:
Description: DynamoDB table for status tracking
Value: !Ref StatusTable