-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.yaml
73 lines (68 loc) · 2.18 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
github-activity-server
Sample SAM Template for github-activity-server
# SAM spec: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md
# SAM is CF, therefore Cloud Formation spec: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html
# SAM Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Runtime: nodejs14.x
Timeout: 5
Api:
EndpointConfiguration: EDGE
Cors:
AllowMethods: "'GET'"
AllowHeaders: "'*'"
AllowOrigin: "'*'"
Parameters:
GithubClientId:
Type: String
Description: Github issued OAuth client ID
GithubClientSecret:
Type: String
NoEcho: true
Description: Github issued OAuth client secret
GithubOauthCallbackUrl:
Type: String
Description: Access token will be appended as parameter after which redirect will follow to this URL
Resources:
OauthGithubAuthorizeFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: api/
Handler: githubAuthorization.handler
Events:
Gateway:
Type: Api
Properties:
Path: /oauth/github/login
Method: get
Environment:
Variables:
CLIENT_ID: !Ref GithubClientId
OauthGithubCallbackFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: api/
Handler: githubAuthorizationCallback.handler
Events:
Gateway:
Type: Api
Properties:
Path: /oauth/github/login/callback
Method: get
Environment:
Variables:
CLIENT_ID: !Ref GithubClientId
CLIENT_SECRET: !Ref GithubClientSecret
OAUTH_CALLBACK_URL: !Ref GithubOauthCallbackUrl
Outputs:
# here /Prod refers to implicitly created Prod stage
ApiUrl:
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
OauthGithubAuthorizeFunction:
Value: !GetAtt OauthGithubAuthorizeFunction.Arn
OauthGithubCallbackFunction:
Value: !GetAtt OauthGithubCallbackFunction.Arn