forked from UrbanInstitute/ui-equity-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yml
137 lines (129 loc) · 3.86 KB
/
template.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
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
- AWS::CodeStar
Parameters:
ProjectId:
Type: String
Description: CodeStar projectId used to associate new resources to team members
CodeDeployRole:
Type: String
Description: IAM role to allow AWS CodeDeploy to manage deployment of AWS Lambda functions
Stage:
Type: String
Description: The name for a project pipeline stage, such as stg or Prod, for which resources are provisioned and deployed
Default: ""
Globals:
Function:
AutoPublishAlias: live
Environment:
Variables:
LD_LIBRARY_PATH: "local/lib:$LD_LIBRARY_PATH"
DATA_BUCKET: INSERT_BUCKET_HERE
DATA_BUCKET_REGION: INSERT_REGION_HERE
API_BUCKET: !Sub INSERT_BUCKET_HERE(should_match_name_of_EquityAssessmentBucket)
FILE_BUCKET_REGION: INSERT_REGION_HERE
DeploymentPreference:
Enabled: true
Type: AllAtOnce
Role: !Ref CodeDeployRole
Resources:
EquityAssessment:
Type: AWS::Serverless::Function
Properties:
Handler: equity_calculations.handler
Runtime: python3.7
Timeout: 900
MemorySize: 3008
CodeUri:
Bucket: INSERT_BUCKET_HERE
Key: INSERT_FILEPATH_TO_DEPLOYMENT_PKG_HERE
Role: INSERT_IAM_ROLE_ARN_HERE
Events:
CreateOutputEvent:
Type: S3
Properties:
Bucket: !Ref EquityAssessmentBucket # bucket must be created in the same template
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: prefix
Value: input-data/
- Name: suffix
Value: .csv
EquityToolBackendAPI:
Type: AWS::Serverless::Api
Properties:
StageName: !Sub "${Stage}"
Auth:
ApiKeyRequired: true # sets for all methods
UsagePlan:
CreateUsagePlan: PER_API
Description: Developer Usage plan for this API
UsagePlanName: INSERT_A_NAME_HERE
StatusChecker:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./scripts/lambda/
Handler: getstatus_and_getfile.handler
Runtime: python3.8
Timeout: 45
MemorySize: 1028
Role: INSERT_IAM_ROLE_ARN_HERE
Events:
GetStatusEvent:
Type: Api
Properties:
RestApiId: !Ref EquityToolBackendAPI
Path: /getstatus/{fileid}
Method: get
Auth:
ApiKeyRequired: true
SubmitJobEvent:
Type: Api
Properties:
RestApiId: !Ref EquityToolBackendAPI
Path: /getfile/{fileid}
Method: get
Auth:
ApiKeyRequired: true
EquityAssessmentBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: INSERT_BUCKET_NAME_HERE
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
LifecycleConfiguration:
Rules:
- Id: DeleteInputData
Prefix: input-data/
Status: Enabled
ExpirationInDays: "7"
- Id: DeleteDemoData
Prefix: output-data/demographic-bias/
Status: Enabled
ExpirationInDays: "7"
- Id: DeleteGeoData
Prefix: input-data/geo-bias/
Status: Enabled
ExpirationInDays: "7"
SampleBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: EquityAssessmentBucket
PolicyDocument:
Statement:
- Action:
- "s3:GetObject"
Effect: "Allow"
Resource:
Fn::Join:
- ""
- - "arn:aws:s3:::"
- Ref: EquityAssessmentBucket
- "/reference-data/sample-data/*"
Principal: "*"