-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtemplate.yaml
More file actions
78 lines (73 loc) · 1.8 KB
/
Copy pathtemplate.yaml
File metadata and controls
78 lines (73 loc) · 1.8 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Runtime: go1.x
Handler: api
Environment:
Variables:
TABLE_NAME: !Ref EntryTable
Resources:
Api:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
Auth:
ApiKeyRequired: true
DefaultAuthorizer: ApiKeyAuthorizer
Authorizers:
ApiKeyAuthorizer:
FunctionArn: !GetAtt ApiKeyAuthFunction.Arn
Identity:
Header: x-api-key
Root:
Type: AWS::Serverless::Function
Properties:
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref EntryTable
Events:
RootHandler:
Type: Api
Properties:
RestApiId: !Ref Api
Path: '/{key}'
Method: get
Auth:
ApiKeyRequired: false
Authorizer: 'NONE'
ApiFunction:
Type: AWS::Serverless::Function
Properties:
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref EntryTable
Events:
CreateLink:
Type: Api
Properties:
RestApiId: !Ref Api
Path: '/api/v1/links'
Method: post
ApiKeyAuthFunction:
Type: AWS::Serverless::Function
Properties:
Handler: auth
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- apigateway:GET
Resource:
- arn:aws:apigateway:us-east-1::/apikeys
EntryTable:
Type: AWS::DynamoDB::Table
Properties:
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: entry_key
AttributeType: S
KeySchema:
- AttributeName: entry_key
KeyType: HASH