Closed mcuervoe closed 3 years ago
Are you having babashka layer in template.yml
?
EDIT: It seems to me that you are mixing native/java runtime with babashka layer.
Regarding babashka limit please create a separate issue for it.
This is the template.yml file that I am using
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Example basic lambda using `holy-lambda` micro library
Parameters:
Runtime:
Type: String
Default: <HOLY_LAMBDA_RUNTIME>
Timeout:
Type: Number
Default: 30
MemorySize:
Type: Number
Default: 256
CodeUri:
Type: String
Default: <HOLY_LAMBDA_CODE_URI>
Entrypoint:
Type: String
Default: <HOLY_LAMBDA_ENTRYPOINT>
Globals:
Function:
Runtime: !Ref Runtime
Timeout: !Ref Timeout
MemorySize: !Ref MemorySize
CodeUri: !Ref CodeUri
Environment:
Variables:
Entrypoint: !Ref Entrypoint
Resources:
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
Policies:
- PolicyName: root
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:*
Resource: arn:aws:logs:*:*:*
- Effect: Allow
Action:
- ec2:DescribeInstances
- ec2:RebootInstances
- ec2:DescribeNetworkInterfaces
- ec2:CreateNetworkInterface
- ec2:DeleteNetworkInterface
- ec2:DescribeInstances
- ec2:AttachNetworkInterface
Resource: "*"
- Effect: Allow
Action:
- s3:GetObject
Resource: arn:aws:s3:::123456789-config/*
ServerMonitorFunctionDev:
Type: AWS::Serverless::Function
Properties:
FunctionName: ServerMonitorDev
Handler: com.nubizzi.normon-monitor.core.ServerMonitor
Layers:
- arn:aws:lambda:eu-west-3:395496933615:layer:holy-lambda-babashka-runtime:2
Environment:
Variables:
S3_CONFIG_BUCKET: 123456789-config
S3_CONFIG_KEY: servers-dev.edn
Role: !GetAtt
- LambdaExecutionRole
- Arn
Events:
RebootEvent:
Type: SNS
Properties:
Topic: !Ref SNSTopicAlarmDev
PeriodicEvent:
Type: Schedule
Properties:
Schedule: 'rate(1 minute)'
Name: MonitorNormonDev
Description: Schedule to monitor apps in dev
Enabled: true
EventInvokeConfig:
MaximumRetryAttempts: 0
VpcConfig:
SecurityGroupIds:
- sg-abcdec
SubnetIds:
- subnet-777222111
SNSTopicAlarmDev:
Type: AWS::SNS::Topic
Properties:
DisplayName: Alarm Dev
Tags:
- Key: Environment
Value: DEV
TopicName: AlarmDev
@mcuervoe You cannot use:
Layers:
- arn:aws:lambda:eu-west-3:395496933615:layer:holy-lambda-babashka-runtime:2
with java/native runtime.
Thank Karol! That solves the problem.
The development cycle is much faster now when I do not have to wait for the compilation of the native image to test the lambda in my local environment
You welcome @mcuervoe :) I will close this issue since it's not the issue with HL :)
If you would like to use babashka
runtime you would have to use https://github.com/tzzh/pod-tzzh-aws instead of aws-api
pod.
Describe the bug A correct code, one that can be deployed in AWS with the native or java runtime, fails when called with
bb stack:invoke
using java runtime. The lambda function uses the cognitect/aws-lib libraryNOTE: I can not guarantee is correct with babashka runtime because the layers + application is bigger than 250Mb limit imposed by AWS, so the code can't be deployed in AWS.
To Reproduce
This produces this output:
Expected behavior The same behavior that I have with native runtime
Extra information:
OS
: Ubuntu 18.04 on WSL2holy-lambda
version: 0.2.1bb stack:doctor
output:[holy-lambda] --------------------------------------- [holy-lambda] Checking health of holy-lambda stack [holy-lambda] Home directory is: /home/miguel [holy-lambda] Project directory is: /home/miguel/git/onetech/normon-monitor [holy-lambda] AWS SAM version: SAM CLI, version 1.23.0 [holy-lambda] AWS CLI version: aws-cli/2.0.42 Python/3.7.3 Linux/4.19.128-microsoft-standard exe/x86_64.ubuntu.18 [holy-lambda] AWS directory is: /home/miguel/.aws [holy-lambda] AWS directory exists?: true [holy-lambda] Docker version: Docker version 20.10.6, build 370c289 [holy-lambda] Babashka tasks sha: 50c055b1b9addf6bfc25bca8a1deecfd3af5c36f [holy-lambda] Babashka tasks version: 0.1.49 [holy-lambda] Babashka version: babashka v0.4.4 [holy-lambda] Runtime: :native [holy-lambda] Runtime entrypoint: com.nubizzi.normon-monitor.core [holy-lambda] Stack name: normon-monitor-96661897a56449f1954de8a4627c40d1-stack [holy-lambda] S3 Bucket name: normon-monitor-96661897a56449f1954de8a4627c [holy-lambda] S3 Bucket prefix: holy-lambda [holy-lambda] S3 Bucket exists?: true [holy-lambda] ---------------------------------------
[holy-lambda] :runtime looks good [holy-lambda] :runtime:entrypoint looks good [holy-lambda] :stack:capabilities looks good [holy-lambda] :runtime:bootstrap-file does not exists. Default bootstrap file for :native runtime will be used! [holy-lambda] :runtime:version is supported only for :babashka runtime [holy-lambda] :runtime:pods are supported only for :babashka runtime [holy-lambda] :stack:name looks good [holy-lambda] property :mvn/local-repo in file deps.edn is correct [holy-lambda] property :mvn/local-repo in file bb.edn is correct [holy-lambda] Syncing stack is not required [holy-lambda] :infra:region definition looks good [holy-lambda] :infra:bucket-prefix looks good [holy-lambda] :stack:template looks good [holy-lambda] :infra:bucket-name looks good [holy-lambda] Required commands ["aws" "sam" "bb" "docker" "clojure" "zip" "id" "clj-kondo" "bash"] installed!
[holy-lambda] Validating template.yml 2021-06-22 16:47:51 Loading policies from IAM... 2021-06-22 16:47:55 Finished loading policies from IAM. /home/miguel/git/onetech/normon-monitor/template.yml is a valid SAM Template