Skip to content

Commit

Permalink
add sam file
Browse files Browse the repository at this point in the history
  • Loading branch information
tttol committed May 20, 2024
1 parent 020fb84 commit 1e8eb25
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .aws-sam/build.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is auto generated by SAM CLI build command

[function_build_definitions]

[layer_build_definitions]
75 changes: 75 additions & 0 deletions template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
mrls in AWS Lambda
Globals:
Function:
Timeout: 10

Resources:
MrlsFunction:
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
Mrls:
Type: HttpApi
Properties:
Path: /v1/{proxy+}
Method: ANY
# Metadata:
# DockerTag: java17.gradle-v1
# DockerContext: ./app
# Dockerfile: Dockerfile

MyScalableTarget:
Type: AWS::ApplicationAutoScaling::ScalableTarget
Properties:
MaxCapacity: 100
MinCapacity: 1
ResourceId: !Sub function:${MrlsFunction}: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: MrlsFunctionAliaslive # 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 MrlsFunction
- Name: Resource
Value: !Sub "${MrlsFunction}:live"
MetricName: ProvisionedConcurrencyUtilization
Namespace: AWS/Lambda
Statistic: Maximum
Unit: Count

Outputs:
MrlsApi:
Description: "API Gateway endpoint URL for Prod stage for Mrls function"
Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/v1/mrls"

0 comments on commit 1e8eb25

Please sign in to comment.