{"id":17005348,"url":"https://github.com/matisszilard/aws-cli-lambda-intro","last_synced_at":"2025-03-22T10:45:29.533Z","repository":{"id":230388485,"uuid":"288713577","full_name":"matisszilard/aws-cli-lambda-intro","owner":"matisszilard","description":"AWS cli playground project for serverless applications","archived":false,"fork":false,"pushed_at":"2020-08-19T14:04:51.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-27T10:29:01.221Z","etag":null,"topics":["aws","aws-cli","serverless"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matisszilard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-08-19T11:28:59.000Z","updated_at":"2020-08-19T14:06:21.000Z","dependencies_parsed_at":"2024-04-01T10:46:50.457Z","dependency_job_id":null,"html_url":"https://github.com/matisszilard/aws-cli-lambda-intro","commit_stats":null,"previous_names":["matisszilard/aws-cli-lambda-intro"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matisszilard%2Faws-cli-lambda-intro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matisszilard%2Faws-cli-lambda-intro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matisszilard%2Faws-cli-lambda-intro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matisszilard%2Faws-cli-lambda-intro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matisszilard","download_url":"https://codeload.github.com/matisszilard/aws-cli-lambda-intro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244945594,"owners_count":20536295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-cli","serverless"],"created_at":"2024-10-14T04:46:05.665Z","updated_at":"2025-03-22T10:45:29.514Z","avatar_url":"https://github.com/matisszilard.png","language":"Makefile","readme":"# Introduction to AWS lambda function using AWS cli\n\nThis is a playground project for learning how to use the AWS cli to create\nlambda functions, give them proper permissions and test them using the cli.\n\nIt is heavily inspired by the [Using AWS Lambda with the AWS Command Line Interface](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-awscli.html) documentation.\n\n## Setup AWS cli\n\nDownload the AWS cli from the original website: https://aws.amazon.com/cli/ .\n\n```sh\naws configure\n```\n\nSet the following parameters accordingly: `AWS Access key ID`, `AWS Secret access key`,\n`Default region name`, `Default output format`.\n\n## Create an execution role for the lambda function\n\nRoles can be created under the IAM (Identity and Access Management). The available\nroles can be viewed on the web UI under the WebConsole-\u003eIAM-\u003eRoles.\n\nThe roles can listed with the CLI as well:\n\n```sh\naws iam list-roles\n```\n\nWe can create a role using the aws cli:\n\n```sh\naws iam create-role --role-name my-specific-role --assume-role-policy-document file://roles/lambda-trust-policy.json\n```\n\nThe `lambda-trust-policy.json` is an example policy json. It allows the lambda function to use the role's permission.\n\nTo add permissions to the role, use the attach-policy-to-role command. Start by adding the AWSLambdaBasicExecutionRole managed policy.\n\n```sh\naws iam attach-role-policy --role-name my-specific-role --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole\n```\n\nOne can get information about a specific role:\n\n```sh\naws iam get-role --role-name my-specific-role\n```\n\nFor more information please run:\n\n```sh\naws iam help\n```\n\n## Create lambda function\n\n```sh\nmake create-lambda arn=arn:aws:iam::12345678901234:role/mszg-demo-lamda-role lambda_name=mszg-demo-lamda\n```\n\n## Test lambda function\n\nWe can test out our newly created lambda function using the aws cli:\n\n```\naws lambda invoke --function-name mszg-demo-lamda out --log-type Tail\n```\n\nIn the response we get base64 encode log messages up to 4 kb.\n\n```sh\n#!/bin/bash\naws lambda invoke --function-name my-function --payload '{\"key\": \"value\"}' out\nsed -i'' -e 's/\"//g' out\nsleep 15\naws logs get-log-events --log-group-name /aws/lambda/my-function --log-stream-name $(cat out) --limit 5\n```\n\n## Useful links\n\n- https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-awscli.html\n- https://www.tutorialspoint.com/aws_lambda/aws_lambda_creating_and_deploying_using_aws_cli.htm\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatisszilard%2Faws-cli-lambda-intro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatisszilard%2Faws-cli-lambda-intro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatisszilard%2Faws-cli-lambda-intro/lists"}