-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtemplate.yaml
More file actions
104 lines (102 loc) · 2.88 KB
/
template.yaml
File metadata and controls
104 lines (102 loc) · 2.88 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
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: An AWS Serverless Specification template for the AWS Python Serverless Template
Parameters:
ServiceName:
Type: String
Default: serverless
ApiNameSuffix:
Type: String
Default: prod
S3Bucket:
Type: String
Default: bucket value will be overriden in buildspec
Globals:
Function:
Runtime: python3.7
Timeout: 3
MemorySize: 256
Layers:
- !Ref CommonCodeLayer
#Conditions:
# CreateProdResources: !Equals [ !Ref ApiNameSuffix, prod ]
Resources:
CommonCodeLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: !Sub ${ServiceName}-${AWS::Region}-${ApiNameSuffix}-common-layer
ContentUri: ./lambda_layer
CompatibleRuntimes:
- python3.7
RetentionPolicy: Delete
Metadata:
BuildMethod: python3.7
ALambda:
Type: AWS::Serverless::Function
Properties:
Handler: a_lambda.handler
Description: some random work
Events:
ALambdaApi:
Type: Api
Properties:
RestApiId: !Ref ApiGateway
Path: /alambda
Method: GET
CodeUri: ./a_lambda
BLambda:
Type: AWS::Serverless::Function
Properties:
Handler: b_lambda.handler
Description: some random work
Events:
BLambdaApi:
Type: Api
Properties:
RestApiId: !Ref ApiGateway
Path: /blambda
Method: GET
CodeUri: ./b_lambda
ApiGateway:
Type: AWS::Serverless::Api
Properties:
Name: !Sub ${ServiceName}-apis-${ApiNameSuffix}
EndpointConfiguration: REGIONAL
TracingEnabled: true
DefinitionBody:
Fn::Transform:
Name: AWS::Include
Parameters:
Location: !Sub s3://${S3Bucket}/api-contract.yaml
StageName: Prod
# # WAF
# ApiGatewayWebACL:
## Condition: CreateProdResources
# DependsOn: ApiGateway
# Type: AWS::WAFv2::WebACL
# Properties:
# DefaultAction:
# Allow: { }
# # no rules defined, allow all for now.
# # See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafv2-webacl.html#cfn-wafv2-webacl-rules
# Scope: REGIONAL
# VisibilityConfig:
# CloudWatchMetricsEnabled: True
# MetricName: ApiGatewayWAFMetric
# SampledRequestsEnabled: False
#
# ApiGatewayACLAssociation:
## Condition: CreateProdResources
# DependsOn: ApiGateway
# Type: AWS::WAFv2::WebACLAssociation
# Properties:
# ResourceArn: !Sub arn:aws:apigateway:${AWS::Region}::/restapis/${ApiGateway}/stages/Prod
# WebACLArn: !GetAtt ApiGatewayWebACL.Arn
ALambdaLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${ALambda}
BLambdaLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${BLambda}