This repository has been archived by the owner on Oct 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
152 lines (140 loc) · 4.85 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
# Welcome to serverless. Read the docs
# https://serverless.com/framework/docs/
# Serverless.yml is the configuration the CLI
# uses to deploy your code to your provider of choice
# The `service` block is the name of the service
service: Office-Maker-Account
# The `provider` block defines where your service will be deployed
provider:
name: aws
runtime: nodejs6.10
stage: ${opt:stage, 'dev'}
region: ap-northeast-1
memorySize: 128
timeout: 15
stackTags:
Name: ${self:service}-${self:provider.stage}
iamRoleStatements:
- Effect: 'Allow'
Action:
- 'lambda:InvokeFunction'
Resource:
- Fn::Join:
- ':'
- - arn:aws:lambda
- Ref: AWS::Region
- Ref: AWS::AccountId
- function:${self:service}-${opt:stage, self:provider.stage}-*
- Effect: "Allow"
Action:
- "s3:PutObject"
- "s3:PutBucketPolicy"
Resource:
- "arn:aws:s3:::office-maker-account-storage-${self:provider.stage}"
custom:
external_file:
environment: ${file(./config.yml)}
storageBucketName: office-maker-account-storage-${self:provider.stage}
remover:
bucket:
- ${self:custom.storageBucketName}
package:
individually: true
exclude:
- ./**
# The `functions` block defines what code to deploy
functions:
authorizer:
handler: functions/authorizer/index.handler
name: ${self:service}-${self:provider.stage}-authorizer
package:
include:
- functions/authorizer/**
environment:
sourceIp: ${self:custom.external_file.environment.functions.sourceIp}
postAuthentication:
handler: functions/postAuthentication/index.handler
name: ${self:service}-${self:provider.stage}-postAuthentication
package:
include:
- ${self:custom.external_file.environment.privateKeyFile}
- functions/postAuthentication/**
environment:
privatekey: ${self:custom.external_file.environment.privateKeyFile}
ldapServer: ${self:custom.external_file.environment.functions.ldapServer}
ldapPort: ${self:custom.external_file.environment.functions.ldapPort}
dnsServer: ${self:custom.external_file.environment.functions.dnsServer}
searchBase: ${self:custom.external_file.environment.functions.searchBase}
searchFilter: ${self:custom.external_file.environment.functions.searchFilter}
groupSearchBase: ${self:custom.external_file.environment.functions.groupSearchBase}
groupSearchFilter: ${self:custom.external_file.environment.functions.groupSearchFilter}
logLeve: ${self:custom.external_file.environment.functions.logLevel}
# The `events` block defines how to trigger the handler.helloWorld code
warmup: prod
events:
- http:
path: authentication
method: post
integration: lambda-proxy
cors:
origin: '*'
headers:
- Content-Type
- X-Amz-Date
- Authorization
- X-Api-Key
- X-Amz-Security-Token
- X-Amz-User-Agent
- Pragma
- Cache-Control
- If-Modified-Since
allowCredentials: true
authorizer:
name: authorizer
type: Request
resultTtlInSecounds: 0
identitySource: context.identity.sourceIp
vpc:
securityGroupIds: ${self:custom.external_file.environment.provider.vpc.securityGroupIds}
subnetIds: ${self:custom.external_file.environment.provider.vpc.subnetIds}
batchCreateToken:
handler: functions/batchCreateToken/index.handler
name: ${self:service}-${self:provider.stage}-batchCreateToken
package:
include:
- ${self:custom.external_file.environment.privateKeyFile}
- functions/batchCreateToken/**
environment:
privatekey: ${self:custom.external_file.environment.privateKeyFile}
storageBucketName: ${self:custom.storageBucketName}
lambdaRole:
Fn::GetAtt: [ IamRoleLambdaExecution, Arn ]
arnWhichAllowedToAccessS3: ${self:custom.external_file.environment.arnWhichAllowedToAccessS3._${self:provider.stage}}
events:
- schedule:
name: ${self:service}-${self:provider.stage}-batchCreateToken-schedule
rate: cron(*/30 * ? * * *)
enabled: true
input:
key: value
resources:
Resources:
ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: ${self:service}-${self:provider.stage}
# S3
StorageBucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName: ${self:custom.storageBucketName}
CorsConfiguration:
CorsRules:
- AllowedHeaders: ['*']
AllowedMethods: [GET]
AllowedOrigins: ["*"]
Id: ${self:service}-storage-cors
MaxAge: '1'
plugins:
- serverless-plugin-warmup
- serverless-s3-remover