From 1e8eb25501ca3c7edd4a7a5a0fb4e9e71481cb45 Mon Sep 17 00:00:00 2001 From: t-takahashi Date: Mon, 20 May 2024 11:12:52 +0900 Subject: [PATCH] add sam file --- .aws-sam/build.toml | 5 +++ template.yml | 75 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .aws-sam/build.toml create mode 100644 template.yml diff --git a/.aws-sam/build.toml b/.aws-sam/build.toml new file mode 100644 index 0000000..678bce4 --- /dev/null +++ b/.aws-sam/build.toml @@ -0,0 +1,5 @@ +# This file is auto generated by SAM CLI build command + +[function_build_definitions] + +[layer_build_definitions] diff --git a/template.yml b/template.yml new file mode 100644 index 0000000..fadefa6 --- /dev/null +++ b/template.yml @@ -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"