-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
104 lines (88 loc) · 2.31 KB
/
template.yaml
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
---
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Globals:
Api:
OpenApiVersion: 3.0.1
Parameters:
Stage:
Type: String
Default: staging
ServiceName:
Type: String
Default: s3Consumer
ArtifactStore:
Description: S3 Bucket, which will hold the artifacts and open api specs
Type: String
Default: uchenchostorage
Resources:
S3ConsumerBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub s3-consumer-bucket-${Stage}
ApiGateway:
Type: AWS::Serverless::Api
Properties:
StageName: !Ref Stage
DefinitionBody:
"Fn::Transform":
Name: AWS::Include
Parameters:
Location: !Sub s3://${ArtifactStore}/open-api/${ServiceName}/open-api-integrated.yaml
Function:
Type: AWS::Serverless::Function
Properties:
Handler: main
Timeout: 180
MemorySize: 512
Runtime: go1.x
FunctionName: !Sub ${ServiceName}-${Stage}
Environment:
Variables:
S3_BUCKET: !Ref S3ConsumerBucket
Policies:
- VPCAccessPolicy: {}
- S3CrudPolicy:
BucketName: !Ref S3ConsumerBucket
Events:
Upload:
Type: Api
Properties:
RestApiId: !Ref ApiGateway
Path: /upload
Method: post
ConsumerFunction:
Type: AWS::Serverless::Function
Properties:
Handler: main-consumer
Timeout: 300
MemorySize: 512
Runtime: go1.x
FunctionName: !Sub ${ServiceName}-consumer-${Stage}
Environment:
Variables:
S3_BUCKET: !Ref S3ConsumerBucket
Policies:
- VPCAccessPolicy: {}
- S3CrudPolicy:
BucketName: !Ref S3ConsumerBucket
Outputs:
Endpoint:
Description: Api endpoint for GeraldAccount
Value: !Sub https://${ApiGateway}.execute-api.${AWS::Region}.amazonaws.com/${Stage}/
Export:
Name: !Sub ${ServiceName}-endpoint
FunctionName:
Description: Service Function Name
Value: !Sub ${ServiceName}-${Stage}
Export:
Name: !Sub ${ServiceName}-name
FunctionArn:
Description: Service Function ARN
Value: !GetAtt Function.Arn
Export:
Name: !Sub ${ServiceName}-arn
S3ConsumerBucketName:
Value: !Ref S3ConsumerBucket
Export:
Name: s3-consumer-bucket