How do you guys name and organize your lambda functions

Recently I realized that I’m extremely terrible when it comes to naming lambda functions. I will put a sort of desc into a name such as getXxxItemFromAaaSource(), something. I don’t think it’s that good when we have to maintain 15-20 lambda functions.

Also when it comes to organizing the code inside the lambda, have come up with some defacto strategies so that the functions will remain consistent in terms of structure. Here how the default structure looks like:

# some sys imports

# some ext lib from layers imports

# some other file import

# config to gather all .env vars
config = {
    'var1': os.getenv('VAR1'),
    ...
}

# reusable global initializations for db, boto3, and other stuff
awsClient = boto3.get('awsService')
db = db.connect()

# reusable functions

# lambda handler
def lambda_handler() {
}

I think naming them for whatever function they serve is fine. However, consider adding Resource and Cost Allocation tags to your functions. It’ll be a good way to understand their function project/role-wise, but also help with any billing aspects.

We use the Serverless Framework, so the naming scheme includes string interpolation variables for the project, deployment stage, and sub-module (if applicable), in addition to the function purpose in the name.

These are also added as tags to each function so that we can find and cost allocate the functions as well.

I second using the Serverless Framework for organized lambda functions

I let CDK name them for me.

We do this. We also add a function Name and app tag for costing as well

For my needs I have some main categories (data pipeline, data validators, apis)

So I generally go with category + detail (data_pipeline_sweet_fruits) and try to be as explicit as possible.

I just routinely shout at the dashboard in a random language that it should have projects. Seems to work for me so far.

I name mine --<function_name> in my Terraform code.

gotta try serverless, currently we are still directly updating code to console. but we have some one to help out with adopting aws sam. how does serverless compares to sam?

wow we are also kinda working on data pipeline like stuff but for us mainly our lambda does the job to import the data to db. Would love to hear what kind of data pipelines u would use lambda for. also if there are any best practices and gotchas it would be awesome. Currently we are struggling with sqs and concurrency, we have bottleneck on both the side from API to provide data as well the the db to store it.

i’ld need to dive into the resource and cost allocation too. lately our lambdas are getting expensive as we try to increase the datapoints. would love if you share some tips to properly manage the costs

---
We also use tags.