This repository has been archived by the owner on Mar 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
serverless.yml
165 lines (152 loc) · 5.03 KB
/
serverless.yml
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
# // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# // SPDX-License-Identifier: Apache-2.0
service: sample-amplify
# package:
# individually: true
# excludeDevDependencies: true
# exclude:
# - node_modules/**
plugins:
modules:
- serverless-appsync-plugin
- aws-amplify-serverless-plugin
provider:
name: aws
region: ${opt:region, "us-east-1"}
stage: ${opt:stage, "dev"}
runtime: nodejs8.10
apiname: ${self:provider.stage}Notes
environment:
DYNAMODB_TABLE: ${self:service}-${self:provider.stage}
custom:
accountId: { Ref: AWS::AccountId }
amplify:
- filename: examples/awsconfiguration.json
type: native
appClient: AndroidUserPoolClient
s3bucket: UserFiles
- filename: examples/aws-exports.js
type: javascript
appClient: WebUserPoolClient
- filename: examples/aws-exports.ts
type: typescript
appClient: WebUserPoolClient
- filename: examples/schema.json
type: schema.json
- filename: examples/operations.graphql
type: graphql
- filename: examples/API.swift
type: appsync
appSync:
name: ${self:provider.apiname}
region: ${self:provider.region}
authenticationType: AMAZON_COGNITO_USER_POOLS
userPoolConfig:
awsRegion: { Ref: AWS::Region }
defaultAction: ALLOW
userPoolId: { Ref: UserPool }
schema: schema.graphql # In case you want to change it
serviceRole: "AppSyncServiceRole"
dataSources:
- type: AMAZON_DYNAMODB
name: "NotesTableDS"
description: "DynamoDB Notes Table"
config:
tableName: { Ref: NotesTable }
iamRoleStatements:
- Effect: Allow
Action:
- "dynamodb:GetItem"
- "dynamodb:PutItem"
- "dynamodb:DeleteItem"
- "dynamodb:Query"
Resource:
- { Fn::GetAtt: [ NotesTable, Arn ]}
- { Fn::Join: [ '', [ { Fn::GetAtt: [ NotesTable, Arn ] }, '/*' ] ] }
mappingTemplates:
- dataSource: NotesTableDS
type: Query
field: getNote
request: "getnote-request.vtl"
response: "common-response.vtl"
- dataSource: NotesTableDS
type: Mutation
field: saveNote
request: "savenote-request.vtl"
response: "common-response.vtl"
- dataSource: NotesTableDS
type: Mutation
field: deleteNote
request: "deletenote-request.vtl"
response: "common-response.vtl"
resources:
Resources:
# Amazon Cognito user pool - used for testing so that we can check the defaults section
FirstListedUserPool:
Type: "AWS::Cognito::UserPool"
Description: "An Amazon Cognito user pool for authenticating users"
Properties:
UserPoolName: ${self:provider.apiname}-fake-pool
# Amazon Cognito user pool
UserPool:
Type: "AWS::Cognito::UserPool"
Description: "An Amazon Cognito user pool for authenticating users"
Properties:
UserPoolName: ${self:provider.apiname}-user-pool
# An app client for the Amazon Cognito user pool
WebUserPoolClient:
Type: "AWS::Cognito::UserPoolClient"
Description: "App Client for Web Usage"
Properties:
ClientName: ${self:provider.apiname}-web-cognitoclient
GenerateSecret: false
UserPoolId: { Ref: UserPool }
AndroidUserPoolClient:
Type: "AWS::Cognito::UserPoolClient"
Description: "App Client for Android Client"
Properties:
ClientName: ${self:provider.apiname}-android-cognitoclient
GenerateSecret: true
UserPoolId: { Ref: UserPool }
iOSUserPoolClient:
Type: "AWS::Cognito::UserPoolClient"
Description: "App Client for iOS Client"
Properties:
ClientName: ${self:provider.apiname}-android-cognitoclient
GenerateSecret: true
UserPoolId: { Ref: UserPool }
# Identity Poool
IdentityPool:
Type: "AWS::Cognito::IdentityPool"
Properties:
IdentityPoolName: ${self:provider.apiname}_pool
AllowUnauthenticatedIdentities: true
SupportedLoginProviders:
accounts.google.com: "google-webclient-id"
graph.facebook.com: "facebook-app-id"
www.amazon.com: "amazon-client-id"
# S3 Bucket for User Files
UserFiles:
Type: "AWS::S3::Bucket"
Description: "User Files Bucket"
Properties:
BucketName: ${self:service.name}-userfiles
# DynamoDB Table
NotesTable:
Type: "AWS::DynamoDB::Table"
Description: "Data Store for AWS AppSync Notes Type"
Properties:
TableName: ${self:provider.environment.DYNAMODB_TABLE}
AttributeDefinitions:
- AttributeName: "NoteId"
AttributeType: "S"
- AttributeName: "UserId"
AttributeType: "S"
KeySchema:
- AttributeName: "NoteId"
KeyType: "HASH"
- AttributeName: "UserId"
KeyType: "RANGE"
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5