From 723ae1c740010dba4ba7c581c1f93938a8d0d46f Mon Sep 17 00:00:00 2001 From: jay verma Date: Mon, 16 Jun 2025 16:16:15 +1000 Subject: [PATCH 1/3] Commit to merge in tim's changes --- lambda.cfndsl.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lambda.cfndsl.rb b/lambda.cfndsl.rb index 9a92c99..b8104c7 100644 --- a/lambda.cfndsl.rb +++ b/lambda.cfndsl.rb @@ -68,6 +68,9 @@ if !lambda_config['named'].nil? && lambda_config['named'] FunctionName(function_name) end + if !lambda_config['dlq_target_arn'].nil? && lambda_config['dlq_target_arn'] + DeadLetterConfig({'TargetArn' => lambda_config['dlq_target_arn']}) + end Tags tags end @@ -138,6 +141,18 @@ SourceArn FnSub("arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/#{event['log_group']}:*") end + + when 's3' + + Lambda_Permission("#{function_name}#{name}Permissions") do + FunctionName Ref(function_name) + Action 'lambda:InvokeFunction' + Principal 's3.amazonaws.com' + SourceArn event['bucket'] + end + + + end end if lambda_config.has_key?('events') From 89b8775a4e888b2acb23e5e93bfbd42342311c8d Mon Sep 17 00:00:00 2001 From: jay verma Date: Thu, 26 Jun 2025 16:46:28 +1000 Subject: [PATCH 2/3] Update runtime --- README.md | 2 +- spec/function_spec.rb | 2 +- tests/function.test.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bd9c440..81f773f 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ functions: app1: handler: handler.lambda_handler - runtime: python3.6 + runtime: python3.10 code_uri: app1/src.zip timeout: 30 environment: diff --git a/spec/function_spec.rb b/spec/function_spec.rb index 16d9588..5a0a1dc 100644 --- a/spec/function_spec.rb +++ b/spec/function_spec.rb @@ -83,7 +83,7 @@ end it "to have property Runtime" do - expect(resource["Properties"]["Runtime"]).to eq("python3.9") + expect(resource["Properties"]["Runtime"]).to eq("python3.10") end it "to have property Timeout" do diff --git a/tests/function.test.yaml b/tests/function.test.yaml index b170c81..7b0527a 100644 --- a/tests/function.test.yaml +++ b/tests/function.test.yaml @@ -10,7 +10,7 @@ distribution: functions: myfunction: handler: handler.lambda_handler - runtime: python3.9 + runtime: python3.10 code_uri: myfunction/src.zip timeout: 30 environment: From 77cd0eadfc7dd556c58adc5d20ecd5d9c3591c2b Mon Sep 17 00:00:00 2001 From: jay verma Date: Mon, 30 Jun 2025 13:35:20 +1000 Subject: [PATCH 3/3] Add lambda layer functionality --- lambda.cfndsl.rb | 1 + spec/function_spec.rb | 4 ++++ tests/function.test.yaml | 2 ++ 3 files changed, 7 insertions(+) diff --git a/lambda.cfndsl.rb b/lambda.cfndsl.rb index b8104c7..4cc5e5c 100644 --- a/lambda.cfndsl.rb +++ b/lambda.cfndsl.rb @@ -56,6 +56,7 @@ Role(FnGetAtt("#{function_name}Role", 'Arn')) Runtime(lambda_config['runtime']) Timeout(lambda_config['timeout'] || 10) + Layers(lambda_config['layers']) if lambda_config.has_key?('layers') if (lambda_config.has_key? 'enable_eni') && (lambda_config['enable_eni']) VpcConfig({ SecurityGroupIds: [ diff --git a/spec/function_spec.rb b/spec/function_spec.rb index 5a0a1dc..7fdab4b 100644 --- a/spec/function_spec.rb +++ b/spec/function_spec.rb @@ -98,6 +98,10 @@ expect(resource["Properties"]["Tags"]).to eq([{"Key"=>"Environment", "Value"=>{"Ref"=>"EnvironmentName"}}, {"Key"=>"EnvironmentType", "Value"=>{"Ref"=>"EnvironmentType"}}]) end + it "to have property Layers" do + expect(resource["Properties"]["Layers"]).to eq(["arn:aws:lambda:us-east-1:123456789012:layer:my-layer:1"]) + end + end context "myfunctionLogGroup" do diff --git a/tests/function.test.yaml b/tests/function.test.yaml index 7b0527a..cd62f02 100644 --- a/tests/function.test.yaml +++ b/tests/function.test.yaml @@ -25,6 +25,8 @@ functions: - '*' enable_eni: true log_retention: 7 + layers: + - arn:aws:lambda:us-east-1:123456789012:layer:my-layer:1 events: cron: type: schedule