-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless.yml
114 lines (109 loc) · 3.44 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
service: serverless-appsync-lambda-httpresource-example
provider:
name: aws
runtime: nodejs10.x
region: eu-west-1
plugins:
- serverless-webpack
- serverless-appsync-plugin
- serverless-appsync-offline
- serverless-offline
functions:
graphql:
handler: src/handler.graphqlHandler
custom:
accountId: 123456789 # use correct AWS accountId
webpack:
includeModules: true
packager: 'yarn'
excludeFiles:
- '**/*.spec.*'
appsync-offline:
port: 62222
dynamodb:
client:
endpoint: "http://localhost:8000"
appsync-emulator:
buildPrefix: .webpack/service
appSync:
name: ${self:service}
authenticationType: API_KEY
logConfig:
loggingRoleArn: { Fn::GetAtt: [AppSyncLoggingServiceRole, Arn] }
level: ALL
mappingTemplates:
- dataSource: myDataSource
type: Query
field: getWeatherWithHTTPResource
request: "getWeatherWithHTTPResource-request-mapping-template.vtl"
response: "getWeatherWithHTTPResource-response-mapping-template.vtl"
- dataSource: myLambda
type: Query
field: getWeatherWithLambda
request: "getWeatherWithLambda-request-mapping-template.vtl"
response: "getWeatherWithLambda-response-mapping-template.vtl"
serviceRole: "AppSyncServiceRole"
dataSources:
- type: AWS_LAMBDA
name: myLambda
description: 'Lambda DataSource'
config:
functionName: graphql
lambdaFunctionArn: { Fn::GetAtt: [GraphqlLambdaFunction, Arn] }
serviceRoleArn: { Fn::GetAtt: [AppSyncLambdaServiceRole, Arn] }
- type: HTTP
name: myDataSource
description: 'HTTP Endpoint'
config:
endpoint: 'https://wttr.in/'
resources:
Resources:
AppSyncLambdaServiceRole:
Type: "AWS::IAM::Role"
Properties:
RoleName: "${self:service}-Lambda-AppSyncServiceRole"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
- "appsync.amazonaws.com"
Action:
- "sts:AssumeRole"
Policies:
- PolicyName: "Lambda-AppSyncServiceRole-Policy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "lambda:invokeFunction"
Resource:
- "arn:aws:lambda:eu-west-1:${self:custom.accountId}:function:${self:service}"
- "arn:aws:lambda:eu-west-1:${self:custom.accountId}:function:${self:service}:*"
AppSyncLoggingServiceRole:
Type: "AWS::IAM::Role"
Properties:
RoleName: "${self:service}-Logging-AppSyncLoggingServiceRole"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
- "appsync.amazonaws.com"
Action:
- "sts:AssumeRole"
Policies:
- PolicyName: "Logging-AppSyncLoggingServiceRole"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "logs:CreateLogGroup"
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Resource:
- "*"