-
Notifications
You must be signed in to change notification settings - Fork 4
/
api.template
84 lines (73 loc) · 2.08 KB
/
api.template
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
---
AWSTemplateFormatVersion: "2010-09-09"
Description: BigOrange.Cloud Updates API
Transform: AWS::Serverless-2016-10-31
Parameters:
ParameterScope:
Type: String
Description: The top-level scope for parameters in SM PS
ActiveTableName:
Type: AWS::SSM::Parameter::Value<String>
Description: The DDB table name
Resources:
HttpApi:
Type: AWS::Serverless::HttpApi
Properties:
AccessLogSettings:
DestinationArn: !GetAtt AccessLogs.Arn
Format: $context.requestId
CorsConfiguration:
AllowOrigins:
- https://bigorange.cloud
- http://localhost:8080 # TODO: Remove/Make configurable
AllowMethods:
- GET
AccessLogs:
Type: AWS::Logs::LogGroup
GetItemsFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./functions/getItems
Handler: index.handler
MemorySize: 512
Timeout: 5
Runtime: nodejs16.x
Environment:
Variables:
ACTIVE_TABLE_NAME: !Ref ActiveTableName
Events:
HttpApi:
Type: HttpApi
Properties:
ApiId: !Ref HttpApi
Path: /items
Method: get
Policies:
- Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:Query
Resource:
- !Sub
arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${ActiveTableName}
- !Sub
arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${ActiveTableName}/*
HttpApiId:
Type: AWS::SSM::Parameter
Properties:
Description: HTTP API ID
Name: !Sub ${ParameterScope}/api/id
Type: String
Value: !Ref HttpApi
HttpApiUrl:
Type: AWS::SSM::Parameter
Properties:
Description: HTTP API URL
Name: !Sub ${ParameterScope}/api/url
Type: String
Value: !Sub https://${HttpApi}.execute-api.${AWS::Region}.amazonaws.com
# Outputs:
# GraphQLUrl:
# Value: !GetAtt GraphQLApi.GraphQLUrl