-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
122 lines (116 loc) · 3.25 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
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: 'Py Spotty api'
Parameters:
DEBUG:
Type: String
Default: "true"
AllowedValues:
- "true"
- "false"
JwtSecret:
Type: String
Default: '{{resolve:ssm:JafJwtSecret:1}}'
AllowedValues:
- '{{resolve:ssm:JafJwtSecret:1}}'
SpotifyClientId:
Type: String
Default: '{{resolve:ssm:JafSpotifyClientId:1}}'
AllowedValues:
- '{{resolve:ssm:JafSpotifyClientId:1}}'
SpotifyClientSecret:
Type: String
Default: '{{resolve:ssm:JafSpotifySecret:1}}'
AllowedValues:
- '{{resolve:ssm:JafSpotifySecret:1}}'
# will update this as required
SpotifyRedirectUri:
Type: String
Default: http://jaf-unwrapped.site.s3-website-ap-southeast-2.amazonaws.com
# AllowedValues:
# - https://jaf-unwrapped.com
Globals:
Function:
Timeout: 15
MemorySize: 128
Runtime: python3.9
Environment:
Variables:
DEBUG: !Ref DEBUG
JwtSecret: !Ref JwtSecret
SpotifyClientId: !Ref SpotifyClientId
SpotifyClientSecret: !Ref SpotifyClientSecret
SpotifyRedirectUri: !Ref SpotifyRedirectUri
Resources:
HttpApiGateway:
Type: AWS::Serverless::Api
Properties:
Cors:
AllowHeaders: "*"
AllowMethods: "*"
AllowOrigin: "*"
StageName: v1
# Domain:
# DomainName: py-auth.jaf-unwrapped.com
# # CertificateArn: arn:aws:acm:ap-southeast-2:355151872526:certificate/12c34da1-c039-4fc4-9636-05571fdb3df9
# CertificateArn: arn:aws:acm:eu-west-2:355151872526:certificate/692a3b22-81bb-4c1c-a600-a1eac3cb32cb
# Route53:
# HostedZoneId: Z05897963LYPVXX455E44
LoginFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: functions/login.handler
Policies:
- DynamoDBCrudPolicy:
TableName: SpotifyProfile
Events:
PostLogin:
Type: Api
Properties:
Path: /login
Method: get
RestApiId: !Ref HttpApiGateway
RequestParameters:
- method.request.querystring.spotifyCode:
Required: true
OptionsLogin:
Type: Api
Properties:
Path: /login
Method: options
RestApiId: !Ref HttpApiGateway
SessionFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: functions/session.handler
Policies:
- DynamoDBCrudPolicy:
TableName: SpotifyProfile
Events:
GetSession:
Type: Api
Properties:
Path: /session
Method: get
RestApiId: !Ref HttpApiGateway
RequestParameters:
- method.request.header.Authorization:
Required: true
OptionsSession:
Type: Api
Properties:
Path: /session
Method: options
RestApiId: !Ref HttpApiGateway
Outputs:
LoginFunction:
Description: Python login function
Value: !Ref LoginFunction
SessionFunction:
Description: Python Session function
Value: !Ref SessionFunction
HttpApiGateway:
Description: Py Api Gateway
Value: !Ref HttpApiGateway