-
Notifications
You must be signed in to change notification settings - Fork 27
/
serverless.yml
164 lines (151 loc) · 4.17 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
frameworkVersion: '>=1.20.2'
plugins:
- environment-variables
- remove-storage
- serverless-webpack
- content-handling
- codebox-tools
- set-api-host
service: codebox-npm
provider:
name: aws
runtime: nodejs6.10
stage: ${opt:stage}
region: ${env:CODEBOX_REGION}
environment:
admins: ${env:CODEBOX_ADMINS}
restrictedOrgs: ${env:CODEBOX_RESTRICTED_ORGS}
registry: ${env:CODEBOX_REGISTRY}
githubUrl: ${env:CODEBOX_GITHUB_URL}
githubClientId: ${env:CODEBOX_GITHUB_CLIENT_ID}
githubSecret: ${env:CODEBOX_GITHUB_SECRET}
bucket: ${env:CODEBOX_BUCKET}-${self:provider.stage}
region: ${self:provider.region}
clientId: ${env:CODEBOX_INSIGHTS_CLIENT_ID}
secret: ${env:CODEBOX_INSIGHTS_SECRET}
iamRoleStatements:
- Effect: "Allow"
Action:
- "s3:ListBucket"
- "s3:GetObject"
- "s3:PutObject"
- "logs:CreateLogGroup"
- "logs:CreateLogStream"
- "logs:PutLogEvents"
- "sns:Publish"
Resource:
- "arn:aws:s3:::${self:provider.environment.bucket}*"
- "Fn::Join":
- ""
- - "arn:aws:sns:"
- Ref: "AWS::Region"
- ":"
- Ref: "AWS::AccountId"
- ":${self:service}-${opt:stage}-log"
functions:
authorizerGithub:
handler: authorizerGithub.default
put:
handler: put.default
events:
- http:
path: 'registry/{name}'
method: put
authorizer: authorizerGithub
get:
handler: get.default
events:
- http:
path: 'registry/{name}'
method: get
authorizer: authorizerGithub
distTagsGet:
handler: distTagsGet.default
events:
- http:
path: 'registry/-/package/{name}/dist-tags'
method: get
authorizer: authorizerGithub
distTagsPut:
handler: distTagsPut.default
events:
- http:
path: 'registry/-/package/{name}/dist-tags/{tag}'
method: put
authorizer: authorizerGithub
distTagsDelete:
handler: distTagsDelete.default
events:
- http:
path: 'registry/-/package/{name}/dist-tags/{tag}'
method: delete
authorizer: authorizerGithub
userPut:
handler: userPut.default
events:
- http:
path: 'registry/-/user/{id}'
method: put
userDelete:
handler: userDelete.default
events:
- http:
path: 'registry/-/user/token/{token}'
method: delete
authorizer: authorizerGithub
whoamiGet:
handler: whoamiGet.default
events:
- http:
path: 'registry/-/whoami'
method: get
authorizer: authorizerGithub
tarGet:
handler: tarGet.default
events:
- http:
integration: lambda
authorizer: authorizerGithub
path: 'registry/{name}/-/{tar}'
method: get
contentHandling: CONVERT_TO_BINARY
request:
template:
application/json: >
{
"name": "$input.params('name')",
"tar": "$input.params('tar')"
}
resources:
Resources:
PackageStorage:
Type: AWS::S3::Bucket
Properties:
AccessControl: Private
BucketName: ${self:provider.environment.bucket}
PackageStoragePolicy:
Type: "AWS::S3::BucketPolicy"
DependsOn: "PackageStorage"
Properties:
Bucket:
Ref: "PackageStorage"
PolicyDocument:
Statement:
- Sid: DenyIncorrectEncryptionHeader
Effect: Deny
Principal: "*"
Action: "s3:PutObject"
Resource: "arn:aws:s3:::${self:provider.environment.bucket}/*"
Condition:
StringNotEquals:
"s3:x-amz-server-side-encryption": AES256
- Sid: DenyUnEncryptedObjectUploads
Effect: Deny
Principal: "*"
Action: "s3:PutObject"
Resource: "arn:aws:s3:::${self:provider.environment.bucket}/*"
Condition:
"Null":
"s3:x-amz-server-side-encryption": true
custom:
webpackIncludeModules: true