forked from awslabs/aws-lambda-web-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
79 lines (72 loc) · 2.44 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sam-app
Sample SAM Template for sam-app
Globals:
Function:
Timeout: 10
Resources:
PetstoreFunction:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
MemorySize: 2048
Tracing: Active
Environment:
Variables:
RUST_LOG: info
READINESS_CHECK_PATH: /healthz
REMOVE_BASE_PATH: /v1
AutoPublishAlias: live
DeploymentPreference:
Type: AllAtOnce
ProvisionedConcurrencyConfig:
ProvisionedConcurrentExecutions: 1
Events:
Root:
Type: HttpApi
Properties:
Path: /v1
Method: ANY
Petstore:
Type: HttpApi
Properties:
Path: /v1/{proxy+}
Method: ANY
Metadata:
DockerTag: java8.al2-maven-v1
DockerContext: ./app
Dockerfile: Dockerfile
MyScalableTarget:
Type: AWS::ApplicationAutoScaling::ScalableTarget
Properties:
MaxCapacity: 100
MinCapacity: 1
ResourceId: !Sub function:${PetstoreFunction}:live # You need to specify an alis or version here
RoleARN: !Sub arn:aws:iam::${AWS::AccountId}:role/aws-service-role/lambda.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_LambdaConcurrency
ScalableDimension: lambda:function:ProvisionedConcurrency
ServiceNamespace: lambda
DependsOn: PetstoreFunctionAliaslive # This is your function logical ID + "Alias" + what you use for AutoPublishAlias
MyTargetTrackingScalingPolicy:
Type: AWS::ApplicationAutoScaling::ScalingPolicy
Properties:
PolicyName: utilization
PolicyType: TargetTrackingScaling
ScalingTargetId: !Ref MyScalableTarget
TargetTrackingScalingPolicyConfiguration:
TargetValue: 0.70 # Any value between 0 and 1 can be used here
CustomizedMetricSpecification:
Dimensions:
- Name: FunctionName
Value: !Ref PetstoreFunction
- Name: Resource
Value: !Sub "${PetstoreFunction}:live"
MetricName: ProvisionedConcurrencyUtilization
Namespace: AWS/Lambda
Statistic: Maximum
Unit: Count
Outputs:
PetstoreApi:
Description: "API Gateway endpoint URL for Prod stage for Petstore function"
Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/v1/pets"