Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to change loggroup / function (resource) name for Lambdas #179

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions cfndsl_ext/lambda_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ def render_lambda_functions(cfndsl, lambdas, lambda_metadata, distribution)
end

lambdas['functions'].each do |key, lambda_config|
name = key
if lambda_config['name_override'].nil?
name = key
else
name = lambda_config['name_override']
end

environment = lambda_config['environment'] || {}



# Create Lambda function
function_name = name
Lambda_Function(function_name) do
Expand Down Expand Up @@ -103,7 +110,11 @@ def render_lambda_functions(cfndsl, lambdas, lambda_metadata, distribution)

if lambda_config.has_key?('log_retention')
Logs_LogGroup("#{name}LogGroup") do
LogGroupName "/aws/lambda/#{name}"
if lambda_config['function_name'].nil?
LogGroupName "/aws/lambda/#{name}"
Copy link
Member

@Guslington Guslington Oct 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

providing the ability to set the log group name could lead to confusion as the log group name has to match the function name.

i think this should change to something like

LogGroupName FnSub("/aws/lambda/${#{function_name}}")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the below commit :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it will be implemented?

else
LogGroupName FnJoin('/',['/aws/lambda',lambda_config['function_name']])
end
RetentionInDays lambda_config['log_retention'].to_i
end
end
Expand Down