Repository navigation
Expand file tree
/
Copy pathserverless.yml
More file actions
104 lines (97 loc) · 3.08 KB
/
Copy pathserverless.yml
File metadata and controls
104 lines (97 loc) · 3.08 KB
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
service: sparcs-auth-service
custom:
projectName: sparcs-events
serviceName: auth
stage: ${opt:stage, self:provider.stage}
entities: ${self:custom.stage}-${self:custom.projectName}-entities
emailQueue: !ImportValue EmailQueue-${self:custom.stage}
frontendUrl: ${ssm:/techtix/frontend-url-${self:custom.stage}}
signinCallback: ${ssm:/techtix/cognito-signin-redirect-${self:custom.stage}}
createApiGatewayRole: ${env:CREATE_API_GW_ROLE, 'true'}
pythonRequirements:
dockerizePip: non-linux
noDeploy:
- requests
- boto3
- botocore
layer:
name: ${self:custom.projectName}-${self:custom.serviceName}-${self:custom.stage}-python-requirements
compatibleRuntimes:
- python3.8
slim: true
package: ${file(resources/package.yml)}
provider:
name: aws
runtime: python3.8
stage: dev
region: ap-southeast-1
memorySize: 256
versionFunctions: false
timeout: 30
apiGateway:
resourcePolicy:
- Effect: Allow
Action: execute-api:Invoke
Principal: "*"
Resource: execute-api:/*/*/*
environment:
REGION: ${self:provider.region}
STAGE: ${self:custom.stage}
ENTITIES_TABLE: ${self:custom.entities}
EMAIL_QUEUE: ${self:custom.emailQueue}
FRONTEND_URL: ${self:custom.frontendUrl}
logs:
restApi:
role: !GetAtt ApiGatewayCloudWatchRole.Arn
resources:
- ${file(resources/cognito.yml)}
- Resources:
ApiGatewayCloudWatchRole:
Type: AWS::IAM::Role
Properties:
RoleName: serverlessApiGatewayCloudWatchRole-${self:custom.serviceName}-${self:custom.stage}
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: apigateway.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: AllowCloudWatchLogs
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:DescribeLogGroups
- logs:DescribeLogStreams
- logs:PutLogEvents
Resource: "*"
AuthServiceApiEndpointParameter:
Type: AWS::SSM::Parameter
Properties:
Name: /techtix/auth-api-url-${self:custom.stage}
Type: String
Value:
Fn::Join:
- ""
- - "https://"
- Ref: ApiGatewayRestApi
- ".execute-api."
- ${self:provider.region}
- ".amazonaws.com/"
- ${self:custom.stage}
Outputs:
ApiGatewayCloudWatchRoleArn:
Value: !GetAtt ApiGatewayCloudWatchRole.Arn
Export:
Name: ApiGatewayCloudWatchRole-${self:custom.serviceName}-${self:custom.stage}
functions:
- ${file(resources/api.yml)}
plugins:
- serverless-better-credentials
- serverless-python-requirements
- serverless-iam-roles-per-function