demo_aws_lambda_function_hello_world_as_python

Demo AWS lambda function HelloWorld.py as python

https://github.com/joelparkerhenderson/demo_aws_lambda_function_hello_world_as_python

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (5.8%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Demo AWS lambda function HelloWorld.py as python

Basic Info
  • Host: GitHub
  • Owner: joelparkerhenderson
  • Language: Python
  • Default Branch: master
  • Size: 3.91 KB
Statistics
  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 7 years ago · Last pushed about 1 year ago
Metadata Files
Readme Code of conduct Citation

README.md

Demo AWS lambda function

Create a function

Write a simple function, for example a python script that says hello:

py def lambda_handler(event, context): print("Hello World")

Create a file HelloWorld.py with the function above.

Create a zip

Create a zip file that contains the function, which is necessary to upload to AWS:

sh $ zip HelloWorld.zip HelloWorld.py adding: HelloWorld.py (stored 0%)

Create the function

Create the function by using the AWS CLI:

sh aws lambda create-function \ --function-name HelloWorld \ --runtime python3.6 \ --role arn:aws:iam::048251220134:role/demo-aws-cloudwatch-lambda-role \ --handler HelloWorld.lambda_handler \ --zip-file fileb://HelloWorld.zip

Invoke

Invoke:

sh aws lambda invoke \ --function-name HelloWorld output.txt

Verify the output text:

sh cat output.txt

Troubleshooting: bad handler

If you get this reply:

  • {"errorMessage": "Bad handler 'lambda_handler'"}

Then you can see that 'lambda_handler' is wrong because it is missing the file name.

  • The handler must have the file name e.g. "HelloWord.lambda_handler".

Update the handler name:

sh aws lambda update-function-configuration \ --function-name HelloWorld \ --handler HelloWorld.lambda_handler

Troubleshooing: ResourceConflictException

If you get this:

  • An error occurred (ResourceConflictException) when calling the CreateFunction operation: Function already exist: HelloWorld

Then you probably need to update, not create:

sh aws lambda update-function-code \ --function-name HelloWorld \ --zip-file fileb://HelloWorld.zip

Thanks & Credits

Links:

Owner

  • Name: Joel Parker Henderson
  • Login: joelparkerhenderson
  • Kind: user
  • Location: California

Software developer. Technology consultant. Creator of GitAlias.com, NumCommand.com, SixArm.com, and many open source projects.

Citation (CITATION.cff)

cff-version: 1.2.0
title: Demo AWS lambda function
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Joel Parker
    family-names: Henderson
    email: joel@joelparkerhenderson.com
    affiliation: joelparkerhenderson.com
    orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
  - type: url
    value: 'https://github.com/joelparkerhenderson/demo_aws_lambda_function_hello_world_as_python/'
    description: Demo AWS lambda function
repository-code: 'https://github.com/joelparkerhenderson/demo_aws_lambda_function_hello_world_as_python/'
abstract: >-
  Demo AWS lambda function
license: See license file

GitHub Events

Total
  • Push event: 1
Last Year
  • Push event: 1

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 3
  • Total Committers: 1
  • Avg Commits per committer: 3.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Joel Parker Henderson j****l@j****m 3
Committer Domains (Top 20 + Academic)