forked from F3-Nation/archive-slackblast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
191 lines (184 loc) · 6.27 KB
/
Copy pathtemplate.yaml
File metadata and controls
191 lines (184 loc) · 6.27 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: slackblast-build-template
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 10
MemorySize: 128
Tracing: Active
Api:
TracingEnabled: true
Parameters:
SlackToken:
Description: Slack token that is passed by the bot
Type: String
Default: "123"
SlackSigningSecret:
Description: Auth token used to pass to the controller to get the commands
Type: String
Default: "123"
SlackClientSecret:
Description: Auth token used to pass to the controller to get the commands
Type: String
Default: "123"
SlackOauthScopes:
Description: Auth token used to pass to the controller to get the commands
Type: String
Default: "chat:write,chat:write.customize,chat:write.public,im:write,commands,team:read,users:read,channels:read,files:read,files:write"
Stage:
Description: Parameter for getting the deployment stage
Type: String
Default: staging
DatabaseHost:
Description: RDS Database Host
Type: String
Default: "123"
DatabaseUser:
Description: RDS Database User
Type: String
Default: "moneyball"
DatabasePassword:
Description: RDS Database Password
Type: String
Default: "123"
DatabaseSchema:
Description: RDS Database Schema
Type: String
Default: "slackblast"
PasswordEncryptKey:
Description: Hash encrypt key for decrypting email passwords
Type: String
Default: "123"
StravaClientID:
Description: Strava Client ID
Type: String
Default: "123"
StravaClientSecret:
Description: Strava Client Secret
Type: String
Default: "123"
Mappings:
StagesMap:
staging:
SlackClientID: "3135457248691.4852586913543"
SlackStateS3Bucket: "slack-state-bucket"
SlackInstallS3Bucket: "slack-installation-bucket"
KeepWarmName: "SlackblastKeepWarmTest"
prod:
SlackClientID: "3135457248691.3241841713426"
SlackStateS3Bucket: "slack-state-bucket"
SlackInstallS3Bucket: "slack-installation-bucket"
KeepWarmName: "SlackblastKeepWarmProd"
Resources:
SlackblastFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: slackblast/
Handler: app.handler
Runtime: python3.12
Architectures:
- x86_64
Policies:
- AmazonS3FullAccess
- AWSLambdaRole
- AmazonEventBridgeFullAccess
Timeout: 400
Events:
Slackblast:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /slack/events
Method: post
SlackblastInstall:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /slack/install
Method: get
SlackblastKeepWarm:
Type: ScheduleV2
Properties:
ScheduleExpression: "rate(5 minutes)"
Name: !FindInMap
- StagesMap
- Ref: Stage
- KeepWarmName
StravaExchange:
Type: Api
Properties:
Path: /exchange_token
Method: get
Environment:
Variables:
SLACK_BOT_TOKEN: !Ref SlackToken
SLACK_SIGNING_SECRET: !Ref SlackSigningSecret
ENV_SLACK_CLIENT_SECRET: !Ref SlackClientSecret
ENV_SLACK_SCOPES: !Ref SlackOauthScopes
DATABASE_HOST: !Ref DatabaseHost
ADMIN_DATABASE_USER: !Ref DatabaseUser
ADMIN_DATABASE_PASSWORD: !Ref DatabasePassword
ADMIN_DATABASE_SCHEMA: !Ref DatabaseSchema
PASSWORD_ENCRYPT_KEY: !Ref PasswordEncryptKey
ENV_SLACK_CLIENT_ID: !FindInMap
- StagesMap
- Ref: Stage
- SlackClientID
ENV_SLACK_STATE_S3_BUCKET_NAME: !FindInMap
- StagesMap
- Ref: Stage
- SlackStateS3Bucket
ENV_SLACK_INSTALLATION_S3_BUCKET_NAME: !FindInMap
- StagesMap
- Ref: Stage
- SlackInstallS3Bucket
STRAVA_CLIENT_ID: !Ref StravaClientID
STRAVA_CLIENT_SECRET: !Ref StravaClientSecret
# EventRule:
# Type: AWS::Events::Rule
# Properties:
# Description: Keep the slackblast Lambda warm
# EventBusName: default
# Name: slackblast-warm
# ScheduleExpression: rate(5 minutes)
# State: ENABLED
# Targets:
# - Id: 'slackblast-warm'
# Arn: !GetAtt SlackblastFunction.Arn
# S3Bucket:
# Type: AWS::S3::Bucket
# ApplicationResourceGroup:
# Type: AWS::ResourceGroups::Group
# Properties:
# Name:
# Fn::Join:
# - ''
# - - ApplicationInsights-SAM-
# - Ref: AWS::StackName
# ResourceQuery:
# Type: CLOUDFORMATION_STACK_1_0
# ApplicationInsightsMonitoring:
# Type: AWS::ApplicationInsights::Application
# Properties:
# ResourceGroupName:
# Fn::Join:
# - ''
# - - ApplicationInsights-SAM-
# - Ref: AWS::StackName
# AutoConfigurationEnabled: 'true'
# DependsOn: ApplicationResourceGroup
Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
SlackblastApi:
Description: API Gateway endpoint URL for Prod stage for Slackblast function
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/slack/events/"
SlackblastFunction:
Description: Slackblast Lambda Function ARN
Value: !GetAtt SlackblastFunction.Arn
SlackblastFunctionIamRole:
Description: Implicit IAM Role created for Hello World function
Value: !GetAtt SlackblastFunctionRole.Arn
# S3Bucket:
# Description: Bucket Created using this template.
# Value: !Ref S3Bucket